|
| 1 | +version: 0.2 |
| 2 | + |
| 3 | +env: |
| 4 | + variables: |
| 5 | + # VERSION should be passed in from the build environment |
| 6 | + # Example: VERSION=4.02 |
| 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 | + # Ensure VERSION is set |
| 23 | + - | |
| 24 | + if [ -z "$VERSION" ]; then |
| 25 | + echo "ERROR: VERSION environment variable is not set" |
| 26 | + echo "Please set VERSION to the released version to validate (e.g. VERSION=4.02)" |
| 27 | + exit 1 |
| 28 | + fi |
| 29 | + # Install the released package instead of the source |
| 30 | + - echo "Installing aws-encryption-sdk version $VERSION" |
| 31 | + - pip install "aws-encryption-sdk==$VERSION" |
| 32 | + - pip install "tox < 4.0" |
| 33 | + build: |
| 34 | + commands: |
| 35 | + # Create a simple tox.ini file for running examples with the installed package |
| 36 | + - | |
| 37 | + cat > release_validation_tox.ini << 'EOF' |
| 38 | + [tox] |
| 39 | + envlist = py311 |
| 40 | + skipsdist = True |
| 41 | +
|
| 42 | + [testenv] |
| 43 | + passenv = |
| 44 | + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID |
| 45 | + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2 |
| 46 | + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1 |
| 47 | + AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2 |
| 48 | + AWS_ACCESS_KEY_ID |
| 49 | + AWS_SECRET_ACCESS_KEY |
| 50 | + AWS_SESSION_TOKEN |
| 51 | + AWS_CONTAINER_CREDENTIALS_RELATIVE_URI |
| 52 | + AWS_PROFILE |
| 53 | + deps = |
| 54 | + pytest |
| 55 | + pytest-mock |
| 56 | + mock |
| 57 | + coverage |
| 58 | + pyyaml |
| 59 | + moto |
| 60 | + boto3 |
| 61 | + cryptography |
| 62 | + commands = |
| 63 | + # Run non-MPL examples |
| 64 | + pytest examples/test/legacy/ -m examples |
| 65 | + # Run all other examples |
| 66 | + pytest examples/test/ -m examples --ignore examples/test/legacy/ |
| 67 | + EOF |
| 68 | +
|
| 69 | + # Run the examples with NUM_RETRIES to handle transient failures |
| 70 | + - NUM_RETRIES=3 |
| 71 | + - | |
| 72 | + while [ $NUM_RETRIES -gt 0 ] |
| 73 | + do |
| 74 | + tox -c release_validation_tox.ini -e py311 |
| 75 | + if [ $? -eq 0 ]; then |
| 76 | + break |
| 77 | + fi |
| 78 | + NUM_RETRIES=$((NUM_RETRIES-1)) |
| 79 | + if [ $NUM_RETRIES -eq 0 ]; then |
| 80 | + echo "All validation attempts failed, stopping" |
| 81 | + exit 1; |
| 82 | + else |
| 83 | + echo "Validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60 |
| 84 | + fi |
| 85 | + done |
| 86 | +
|
| 87 | + # Assume special role for MPL-specific tests |
| 88 | + - echo "Running tests with special role for MPL features" |
| 89 | + - 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") |
| 90 | + - export TMP_ROLE |
| 91 | + - export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId') |
| 92 | + - export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey') |
| 93 | + - export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken') |
| 94 | + - aws sts get-caller-identity |
| 95 | + |
| 96 | + # Also install MPL requirements |
| 97 | + - pip install -r requirements_mpl.txt |
| 98 | + |
| 99 | + # Run MPL-specific examples |
| 100 | + - NUM_RETRIES=3 |
| 101 | + - | |
| 102 | + while [ $NUM_RETRIES -gt 0 ] |
| 103 | + do |
| 104 | + # Only run the MPL-specific tests that require special permissions |
| 105 | + # These would normally be run with py311-mplexamples-mpl |
| 106 | + python -m pytest examples/test/ -m examples --ignore examples/test/legacy/ |
| 107 | + if [ $? -eq 0 ]; then |
| 108 | + break |
| 109 | + fi |
| 110 | + NUM_RETRIES=$((NUM_RETRIES-1)) |
| 111 | + if [ $NUM_RETRIES -eq 0 ]; then |
| 112 | + echo "All MPL validation attempts failed, stopping" |
| 113 | + exit 1; |
| 114 | + else |
| 115 | + echo "MPL validation failed, retrying in 60 seconds; will retry $NUM_RETRIES more times" && sleep 60 |
| 116 | + fi |
| 117 | + done |
0 commit comments