Skip to content

Commit 80e1d80

Browse files
committed
chore: validate release
1 parent cbfab66 commit 80e1d80

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed

.github/workflows/ci_codebuild_batch.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,25 @@ jobs:
12981298
buildspec-override: codebuild/py312/decrypt_golden_manifest_with_masterkey.yml
12991299
image-override: aws/codebuild/standard:7.0
13001300

1301+
# Python Release Validation with examples as alternate
1302+
python_release_examples_validation:
1303+
name: Python Release Validation with Examples
1304+
runs-on: ubuntu-latest
1305+
steps:
1306+
- name: Configure AWS Credentials
1307+
uses: aws-actions/configure-aws-credentials@v2
1308+
with:
1309+
role-to-assume: ${{ secrets.CI_AWS_ROLE_ARN }}
1310+
aws-region: us-west-2
1311+
role-duration-seconds: 7200
1312+
- name: Run CodeBuild
1313+
uses: aws-actions/aws-codebuild-run-build@v1
1314+
timeout-minutes: 120
1315+
with:
1316+
project-name: python-esdk
1317+
buildspec-override: codebuild/release/validate_with_examples.yml
1318+
image-override: aws/codebuild/standard:7.0
1319+
13011320
# Code Coverage and Compliance jobs
13021321
code_coverage:
13031322
name: Code Coverage
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
version: 0.2
2+
3+
env:
4+
variables:
5+
# Default VERSION if not provided externally
6+
VERSION: 4.0.2
7+
REGION: "us-west-2"
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
9+
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
10+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
11+
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
12+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
13+
arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
14+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >-
15+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
16+
17+
phases:
18+
install:
19+
runtime-versions:
20+
python: 3.11
21+
commands:
22+
- pip install "tox < 4.0"
23+
- pip install --upgrade pip
24+
build:
25+
commands:
26+
# Set initial retry count
27+
- NUM_RETRIES=3
28+
29+
# Run non-MPL-specific tests with the MPL installed
30+
- |
31+
while [ $NUM_RETRIES -gt 0 ]
32+
do
33+
VERSION=$VERSION tox -e validate-pypi-release
34+
if [ $? -eq 0 ]; then
35+
echo "Standard examples successful"
36+
break
37+
fi
38+
NUM_RETRIES=$((NUM_RETRIES-1))
39+
if [ $NUM_RETRIES -eq 0 ]; then
40+
echo "All standard example attempts failed, stopping"
41+
exit 1
42+
else
43+
echo "Standard examples failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
44+
fi
45+
done
46+
47+
# Assume special role for MPL-specific tests
48+
- echo "Running tests with special role for MPL features"
49+
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-ValidateReleased")
50+
- export TMP_ROLE
51+
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
52+
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
53+
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
54+
- aws sts get-caller-identity
55+
56+
# Run MPL examples with a fresh retry count
57+
- NUM_RETRIES=3
58+
- |
59+
while [ $NUM_RETRIES -gt 0 ]
60+
do
61+
VERSION=$VERSION tox -e validate-pypi-release-mpl
62+
if [ $? -eq 0 ]; then
63+
echo "MPL examples successful"
64+
break
65+
fi
66+
NUM_RETRIES=$((NUM_RETRIES-1))
67+
if [ $NUM_RETRIES -eq 0 ]; then
68+
echo "All MPL example attempts failed, stopping"
69+
exit 1
70+
else
71+
echo "MPL examples failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60
72+
fi
73+
done

tox.ini

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ envlist =
5252
# build :: Builds source and wheel dist files.
5353
# test-release :: Builds dist files and uploads to testpypi pypirc profile.
5454
# release :: Builds dist files and uploads to pypi pypirc profile.
55+
# validate-pypi-release :: Tests a released version from PyPI instead of source.
56+
# validate-pypi-release-mpl :: Tests a released version with MPL features.
5557

5658
# Reporting environments:
5759
#
@@ -395,3 +397,48 @@ passenv =
395397
commands =
396398
{[testenv:release-base]commands}
397399
twine upload --skip-existing --repository pypi {toxinidir}/dist/*
400+
401+
# Test the PyPI released version (not local source code)
402+
[testenv:py-validate-base]
403+
basepython = python3
404+
skip_install = true
405+
passenv = {[testenv]passenv}
406+
deps =
407+
pytest
408+
pytest-mock
409+
mock
410+
coverage
411+
# Add dev requirements for testing
412+
-rdev_requirements/test-requirements.txt
413+
414+
# Standard test environment for PyPI-released version (no MPL)
415+
[testenv:validate-pypi-release]
416+
basepython = {[testenv:py-validate-base]basepython}
417+
skip_install = {[testenv:py-validate-base]skip_install}
418+
passenv = {[testenv:py-validate-base]passenv}
419+
deps = {[testenv:py-validate-base]deps}
420+
setenv =
421+
VERSION = {env:VERSION:latest}
422+
commands =
423+
# Install the specified version from PyPI (without MPL extras)
424+
pip install "aws-encryption-sdk=={env:VERSION}" --force-reinstall
425+
# Run non-MPL examples
426+
{[testenv:base-command]commands} examples/test/legacy/ -m examples
427+
428+
# MPL test environment for PyPI-released version
429+
[testenv:validate-pypi-release-mpl]
430+
basepython = {[testenv:py-validate-base]basepython}
431+
skip_install = {[testenv:py-validate-base]skip_install}
432+
passenv = {[testenv:py-validate-base]passenv}
433+
deps =
434+
{[testenv:py-validate-base]deps}
435+
boto3
436+
setenv =
437+
VERSION = {env:VERSION:latest}
438+
commands =
439+
# Install the specified version from PyPI with MPL extras
440+
pip install "aws-encryption-sdk[MPL]=={env:VERSION}" --force-reinstall
441+
# Install MPL requirements needed for MPL examples
442+
pip install -r requirements_mpl.txt
443+
# Run MPL-specific examples
444+
{[testenv:base-command]commands} examples/test/ -m examples --ignore examples/test/legacy/

0 commit comments

Comments
 (0)