From 93a67d8a3806f560ead950e6d8898e53c4c4f9df Mon Sep 17 00:00:00 2001 From: Tony Knapp <5892063+texastony@users.noreply.github.com> Date: Mon, 30 Oct 2023 18:44:26 -0700 Subject: [PATCH] feat: test Python 3.12 in CI (#623) --- .github/workflows/ci_test-vector-handler.yaml | 1 - .github/workflows/ci_tests.yaml | 3 +- buildspec.yml | 49 +++++++++++++++++++ codebuild/py310/awses_local.yml | 4 +- codebuild/py310/examples.yml | 4 +- codebuild/py310/integ.yml | 4 +- codebuild/py311/awses_local.yml | 25 ++++++++++ codebuild/py311/examples.yml | 22 +++++++++ codebuild/py311/integ.yml | 22 +++++++++ codebuild/py312/awses_local.yml | 30 ++++++++++++ codebuild/py312/examples.yml | 27 ++++++++++ codebuild/py312/integ.yml | 27 ++++++++++ codebuild/py37/awses_local.yml | 4 +- codebuild/py37/examples.yml | 4 +- codebuild/py37/integ.yml | 4 +- codebuild/py38/awses_local.yml | 4 +- codebuild/py38/examples.yml | 4 +- codebuild/py38/integ.yml | 4 +- codebuild/py39/awses_1.7.1.yml | 4 +- codebuild/py39/awses_2.0.0.yml | 4 +- codebuild/py39/awses_latest.yml | 4 +- codebuild/py39/examples.yml | 4 +- codebuild/py39/integ.yml | 4 +- dev_requirements/ci-requirements.txt | 1 + test/unit/test_caches_base.py | 24 +++++---- test/unit/test_material_managers_base.py | 13 +++-- tox.ini | 2 +- 27 files changed, 237 insertions(+), 65 deletions(-) create mode 100644 codebuild/py311/awses_local.yml create mode 100644 codebuild/py311/examples.yml create mode 100644 codebuild/py311/integ.yml create mode 100644 codebuild/py312/awses_local.yml create mode 100644 codebuild/py312/examples.yml create mode 100644 codebuild/py312/integ.yml diff --git a/.github/workflows/ci_test-vector-handler.yaml b/.github/workflows/ci_test-vector-handler.yaml index 81ad1fa09..12ecf8f93 100644 --- a/.github/workflows/ci_test-vector-handler.yaml +++ b/.github/workflows/ci_test-vector-handler.yaml @@ -21,7 +21,6 @@ jobs: - windows-latest - macos-latest python: - - 3.7 - 3.8 - 3.x architecture: diff --git a/.github/workflows/ci_tests.yaml b/.github/workflows/ci_tests.yaml index f537491fc..9d491203c 100644 --- a/.github/workflows/ci_tests.yaml +++ b/.github/workflows/ci_tests.yaml @@ -33,7 +33,8 @@ jobs: - 3.9 - "3.10" - "3.11" - - 3.x # Ideally, we would skip if 3.x is 3.11 + - "3.12" + - 3.x architecture: - x64 - x86 diff --git a/buildspec.yml b/buildspec.yml index 2f2571f64..f92d203a0 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -5,32 +5,81 @@ batch: build-list: - identifier: py37_integ buildspec: codebuild/py37/integ.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py37_examples buildspec: codebuild/py37/examples.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py37_awses_local buildspec: codebuild/py37/awses_local.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py38_integ buildspec: codebuild/py38/integ.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py38_examples buildspec: codebuild/py38/examples.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py38_awses_local buildspec: codebuild/py38/awses_local.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py39_integ buildspec: codebuild/py39/integ.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py39_examples buildspec: codebuild/py39/examples.yml + env: + image: aws/codebuild/standard:5.0 - identifier: py39_awses_latest + env: + image: aws/codebuild/standard:5.0 - identifier: py310_integ buildspec: codebuild/py310/integ.yml + env: + image: aws/codebuild/standard:6.0 - identifier: py310_examples buildspec: codebuild/py310/examples.yml + env: + image: aws/codebuild/standard:6.0 - identifier: py310_awses_latest buildspec: codebuild/py310/awses_local.yml + env: + image: aws/codebuild/standard:6.0 + - identifier: py311_integ + buildspec: codebuild/py311/integ.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: py311_examples + buildspec: codebuild/py311/examples.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: py311_awses_latest + buildspec: codebuild/py311/awses_local.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: py312_integ + buildspec: codebuild/py312/integ.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: py312_examples + buildspec: codebuild/py312/examples.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: py312_awses_latest + buildspec: codebuild/py312/awses_local.yml + env: + image: aws/codebuild/standard:7.0 + - identifier: code_coverage buildspec: codebuild/coverage/coverage.yml diff --git a/codebuild/py310/awses_local.yml b/codebuild/py310/awses_local.yml index beb967f47..df2fcf318 100644 --- a/codebuild/py310/awses_local.yml +++ b/codebuild/py310/awses_local.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.10 build: commands: - - pyenv install 3.10.0 - - pyenv local 3.10.0 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py310/examples.yml b/codebuild/py310/examples.yml index 4d64f5c6c..b495a327c 100644 --- a/codebuild/py310/examples.yml +++ b/codebuild/py310/examples.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.10 build: commands: - - pyenv install 3.10.0 - - pyenv local 3.10.0 - pip install "tox < 4.0" - tox diff --git a/codebuild/py310/integ.yml b/codebuild/py310/integ.yml index 1a2ca5022..6b557e709 100644 --- a/codebuild/py310/integ.yml +++ b/codebuild/py310/integ.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.10 build: commands: - - pyenv install 3.10.0 - - pyenv local 3.10.0 - pip install "tox < 4.0" - tox diff --git a/codebuild/py311/awses_local.yml b/codebuild/py311/awses_local.yml new file mode 100644 index 000000000..1b00712d5 --- /dev/null +++ b/codebuild/py311/awses_local.yml @@ -0,0 +1,25 @@ +version: 0.2 + +env: + variables: + TOXENV: "py311-awses_local" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_API_DEPLOYMENT_ID: "xi1mwx3ttb" + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_REGION: "us-west-2" + +phases: + install: + runtime-versions: + python: 3.11 + build: + commands: + - pip install "tox < 4.0" + - cd test_vector_handlers + - tox diff --git a/codebuild/py311/examples.yml b/codebuild/py311/examples.yml new file mode 100644 index 000000000..6efcd26d2 --- /dev/null +++ b/codebuild/py311/examples.yml @@ -0,0 +1,22 @@ +version: 0.2 + +env: + variables: + TOXENV: "py311-examples" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: 3.11 + build: + commands: + - pip install "tox < 4.0" + - tox diff --git a/codebuild/py311/integ.yml b/codebuild/py311/integ.yml new file mode 100644 index 000000000..9606bee12 --- /dev/null +++ b/codebuild/py311/integ.yml @@ -0,0 +1,22 @@ +version: 0.2 + +env: + variables: + TOXENV: "py311-integ" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: 3.11 + build: + commands: + - pip install "tox < 4.0" + - tox diff --git a/codebuild/py312/awses_local.yml b/codebuild/py312/awses_local.yml new file mode 100644 index 000000000..50638c6e9 --- /dev/null +++ b/codebuild/py312/awses_local.yml @@ -0,0 +1,30 @@ +version: 0.2 + +env: + variables: + TOXENV: "py312-awses_local" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_API_DEPLOYMENT_ID: "xi1mwx3ttb" + AWS_ENCRYPTION_SDK_PYTHON_DECRYPT_ORACLE_REGION: "us-west-2" + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - cd /root/.pyenv/plugins/python-build/../.. && git pull && cd - + - pyenv install 3.12.0 + - pyenv local 3.12.0 + - pip install --upgrade pip + - pip install setuptools + - pip install "tox < 4.0" + - cd test_vector_handlers + - tox diff --git a/codebuild/py312/examples.yml b/codebuild/py312/examples.yml new file mode 100644 index 000000000..aee933e00 --- /dev/null +++ b/codebuild/py312/examples.yml @@ -0,0 +1,27 @@ +version: 0.2 + +env: + variables: + TOXENV: "py312-examples" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - cd /root/.pyenv/plugins/python-build/../.. && git pull && cd - + - pyenv install 3.12.0 + - pyenv local 3.12.0 + - pip install --upgrade pip + - pip install setuptools + - pip install "tox < 4.0" + - tox diff --git a/codebuild/py312/integ.yml b/codebuild/py312/integ.yml new file mode 100644 index 000000000..156c185d9 --- /dev/null +++ b/codebuild/py312/integ.yml @@ -0,0 +1,27 @@ +version: 0.2 + +env: + variables: + TOXENV: "py312-integ" + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >- + arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >- + arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >- + arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >- + arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7 + +phases: + install: + runtime-versions: + python: latest + build: + commands: + - cd /root/.pyenv/plugins/python-build/../.. && git pull && cd - + - pyenv install 3.12.0 + - pyenv local 3.12.0 + - pip install --upgrade pip + - pip install setuptools + - pip install "tox < 4.0" + - tox diff --git a/codebuild/py37/awses_local.yml b/codebuild/py37/awses_local.yml index c4265fc71..02dfe5d0b 100644 --- a/codebuild/py37/awses_local.yml +++ b/codebuild/py37/awses_local.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.7 build: commands: - - pyenv install 3.7.12 - - pyenv local 3.7.12 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py37/examples.yml b/codebuild/py37/examples.yml index 14b220524..0b240c768 100644 --- a/codebuild/py37/examples.yml +++ b/codebuild/py37/examples.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.7 build: commands: - - pyenv install 3.7.12 - - pyenv local 3.7.12 - pip install "tox < 4.0" - tox diff --git a/codebuild/py37/integ.yml b/codebuild/py37/integ.yml index 6306c20e2..b702d45cb 100644 --- a/codebuild/py37/integ.yml +++ b/codebuild/py37/integ.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.7 build: commands: - - pyenv install 3.7.12 - - pyenv local 3.7.12 - pip install "tox < 4.0" - tox diff --git a/codebuild/py38/awses_local.yml b/codebuild/py38/awses_local.yml index 936a9ca6c..9876de247 100644 --- a/codebuild/py38/awses_local.yml +++ b/codebuild/py38/awses_local.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.8 build: commands: - - pyenv install 3.8.12 - - pyenv local 3.8.12 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py38/examples.yml b/codebuild/py38/examples.yml index 221ad4f80..4dff71d65 100644 --- a/codebuild/py38/examples.yml +++ b/codebuild/py38/examples.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.8 build: commands: - - pyenv install 3.8.12 - - pyenv local 3.8.12 - pip install "tox < 4.0" - tox diff --git a/codebuild/py38/integ.yml b/codebuild/py38/integ.yml index 088a2c7ba..8b7acafe1 100644 --- a/codebuild/py38/integ.yml +++ b/codebuild/py38/integ.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.8 build: commands: - - pyenv install 3.8.12 - - pyenv local 3.8.12 - pip install "tox < 4.0" - tox diff --git a/codebuild/py39/awses_1.7.1.yml b/codebuild/py39/awses_1.7.1.yml index c61024409..22267ad8f 100644 --- a/codebuild/py39/awses_1.7.1.yml +++ b/codebuild/py39/awses_1.7.1.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.9 build: commands: - - pyenv install 3.9.7 - - pyenv local 3.9.7 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_2.0.0.yml b/codebuild/py39/awses_2.0.0.yml index df6cd489c..d35e7e98c 100644 --- a/codebuild/py39/awses_2.0.0.yml +++ b/codebuild/py39/awses_2.0.0.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.9 build: commands: - - pyenv install 3.9.7 - - pyenv local 3.9.7 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py39/awses_latest.yml b/codebuild/py39/awses_latest.yml index 0675cbb0a..719ab2238 100644 --- a/codebuild/py39/awses_latest.yml +++ b/codebuild/py39/awses_latest.yml @@ -17,11 +17,9 @@ env: phases: install: runtime-versions: - python: latest + python: 3.9 build: commands: - - pyenv install 3.9.7 - - pyenv local 3.9.7 - pip install "tox < 4.0" - cd test_vector_handlers - tox diff --git a/codebuild/py39/examples.yml b/codebuild/py39/examples.yml index 6f07efcea..3d1399251 100644 --- a/codebuild/py39/examples.yml +++ b/codebuild/py39/examples.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.9 build: commands: - - pyenv install 3.9.7 - - pyenv local 3.9.7 - pip install "tox < 4.0" - tox diff --git a/codebuild/py39/integ.yml b/codebuild/py39/integ.yml index 1e9743e39..6dec85b07 100644 --- a/codebuild/py39/integ.yml +++ b/codebuild/py39/integ.yml @@ -15,10 +15,8 @@ env: phases: install: runtime-versions: - python: latest + python: 3.9 build: commands: - - pyenv install 3.9.7 - - pyenv local 3.9.7 - pip install "tox < 4.0" - tox diff --git a/dev_requirements/ci-requirements.txt b/dev_requirements/ci-requirements.txt index 57e3871e0..4335988fd 100644 --- a/dev_requirements/ci-requirements.txt +++ b/dev_requirements/ci-requirements.txt @@ -1 +1,2 @@ +setuptools tox==3.27.1 diff --git a/test/unit/test_caches_base.py b/test/unit/test_caches_base.py index c3aa2369b..c24b1b04c 100644 --- a/test/unit/test_caches_base.py +++ b/test/unit/test_caches_base.py @@ -19,18 +19,16 @@ def test_abstracts(): - with pytest.raises(TypeError) as excinfo: + with pytest.raises(TypeError, match='instantiate abstract class CryptoMaterialsCache') as excinfo: CryptoMaterialsCache() - excinfo.match( - r"Can't instantiate abstract class CryptoMaterialsCache with abstract methods {}".format( - ", ".join( - [ - "get_decryption_materials", - "get_encryption_materials", - "put_decryption_materials", - "put_encryption_materials", - ] - ) - ) - ) + exception = str(excinfo.value) + method_names = [ + "get_decryption_materials", + "get_encryption_materials", + "put_decryption_materials", + "put_encryption_materials" + ] + for name in method_names: + if exception.rfind(name) == -1: + raise AssertionError("{} missing from Exception Message".format(name)) diff --git a/test/unit/test_material_managers_base.py b/test/unit/test_material_managers_base.py index 792118979..34501e59a 100644 --- a/test/unit/test_material_managers_base.py +++ b/test/unit/test_material_managers_base.py @@ -19,11 +19,10 @@ def test_abstracts(): - with pytest.raises(TypeError) as excinfo: + with pytest.raises(TypeError, match='instantiate abstract class CryptoMaterialsManager') as excinfo: CryptoMaterialsManager() - - excinfo.match( - r"Can't instantiate abstract class CryptoMaterialsManager with abstract methods {}".format( - ", ".join(["decrypt_materials", "get_encryption_materials"]) - ) - ) + method_names = ["decrypt_materials", "get_encryption_materials"] + exception = str(excinfo.value) + for name in method_names: + if exception.rfind(name) == -1: + raise AssertionError("{} missing from Exception Message".format(name)) diff --git a/tox.ini b/tox.ini index 48421de50..9ca7a0cd6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{37,38,39,310,311}-{local,integ,accept,examples}, nocmk, + py{37,38,39,310,311,312}-{local,integ,accept,examples}, nocmk, bandit, doc8, readme, docs, {flake8,pylint}{,-tests,-examples}, isort-check, black-check,