|
6 | 6 |
|
7 | 7 | permissions: |
8 | 8 | contents: read |
| 9 | + id-token: write |
9 | 10 |
|
10 | 11 | jobs: |
11 | 12 | integration-tests: |
|
19 | 20 | - name: Parse testing SDK branch from PR body |
20 | 21 | id: parse |
21 | 22 | run: | |
22 | | - BODY="${{ github.event.pull_request.body }}" |
23 | 23 | # Look for a line like: TESTING_SDK_BRANCH: feature/foo |
24 | | - REF=$(printf "%s\n" "$BODY" | sed -n 's/^TESTING_SDK_BRANCH:[[:space:]]*//p' | head -n1) |
| 24 | + REF=$(printf '%s\n' '${{ github.event.pull_request.body }}' | sed -n 's/^TESTING_SDK_BRANCH:[[:space:]]*//p' | head -n1) |
25 | 25 | if [ -z "$REF" ]; then REF="main"; fi |
26 | 26 | echo "testing_ref=$REF" >> "$GITHUB_OUTPUT" |
27 | 27 | echo "Using testing SDK branch: $REF" |
@@ -60,3 +60,131 @@ jobs: |
60 | 60 | hatch run test:cov |
61 | 61 | hatch run test:examples |
62 | 62 | hatch build |
| 63 | +
|
| 64 | + e2e-tests: |
| 65 | + needs: integration-tests |
| 66 | + runs-on: ubuntu-latest |
| 67 | + if: github.event_name == 'pull_request' |
| 68 | + env: |
| 69 | + AWS_REGION: us-west-2 |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Parse testing SDK branch from PR body |
| 73 | + id: parse |
| 74 | + run: | |
| 75 | + # Look for a line like: TESTING_SDK_BRANCH: feature/foo |
| 76 | + REF=$(printf '%s\n' '${{ github.event.pull_request.body }}' | sed -n 's/^TESTING_SDK_BRANCH:[[:space:]]*//p' | head -n1) |
| 77 | + if [ -z "$REF" ]; then REF="main"; fi |
| 78 | + echo "testing_ref=$REF" >> "$GITHUB_OUTPUT" |
| 79 | + echo "Using testing SDK branch: $REF" |
| 80 | +
|
| 81 | + - name: Checkout Language SDK (this PR) |
| 82 | + uses: actions/checkout@v5 |
| 83 | + with: |
| 84 | + path: language-sdk |
| 85 | + |
| 86 | + - name: Checkout Testing SDK |
| 87 | + uses: actions/checkout@v5 |
| 88 | + with: |
| 89 | + repository: aws/aws-durable-execution-sdk-python-testing |
| 90 | + ref: ${{ steps.parse.outputs.testing_ref }} |
| 91 | + token: ${{ secrets.CROSS_REPO_PAT }} |
| 92 | + path: testing-sdk |
| 93 | + |
| 94 | + - name: Set up Python 3.13 |
| 95 | + uses: actions/setup-python@v6 |
| 96 | + with: |
| 97 | + python-version: '3.13' |
| 98 | + |
| 99 | + - name: Configure AWS credentials |
| 100 | + uses: aws-actions/configure-aws-credentials@v4 |
| 101 | + with: |
| 102 | + role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}" |
| 103 | + role-session-name: languageSDKIntegrationTest |
| 104 | + aws-region: ${{ env.AWS_REGION }} |
| 105 | + |
| 106 | + - name: Install custom Lambda model |
| 107 | + working-directory: testing-sdk |
| 108 | + run: | |
| 109 | + aws configure add-model --service-model file://.github/model/lambda.json --service-name lambda |
| 110 | +
|
| 111 | + - name: Install Hatch and setup Testing SDK |
| 112 | + working-directory: testing-sdk |
| 113 | + env: |
| 114 | + AWS_DURABLE_SDK_URL: file://${{ github.workspace }}/language-sdk |
| 115 | + run: | |
| 116 | + pip install hatch |
| 117 | + python -m pip install -e . |
| 118 | +
|
| 119 | + - name: Get integration examples |
| 120 | + id: get-examples |
| 121 | + working-directory: testing-sdk/examples |
| 122 | + run: | |
| 123 | + echo "examples=$(jq -c '.examples | map(select(.integration == true)) | .[0:2]' examples-catalog.json)" >> $GITHUB_OUTPUT |
| 124 | +
|
| 125 | + - name: Deploy and test examples |
| 126 | + working-directory: testing-sdk |
| 127 | + env: |
| 128 | + AWS_DURABLE_SDK_URL: file://${{ github.workspace }}/language-sdk |
| 129 | + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} |
| 130 | + LAMBDA_ENDPOINT: ${{ secrets.LAMBDA_ENDPOINT }} |
| 131 | + INVOKE_ACCOUNT_ID: ${{ secrets.INVOKE_ACCOUNT_ID }} |
| 132 | + KMS_KEY_ARN: ${{ secrets.KMS_KEY_ARN }} |
| 133 | + run: | |
| 134 | + echo "Building examples..." |
| 135 | + hatch run examples:build |
| 136 | + |
| 137 | + # Get first integration example for testing |
| 138 | + EXAMPLE_NAME=$(echo '${{ steps.get-examples.outputs.examples }}' | jq -r '.[0].name') |
| 139 | + EXAMPLE_NAME_CLEAN=$(echo "$EXAMPLE_NAME" | sed 's/ //g') |
| 140 | + FUNCTION_NAME="${EXAMPLE_NAME_CLEAN}-LanguageSDK-PR-${{ github.event.number }}" |
| 141 | + |
| 142 | + echo "Deploying example: $EXAMPLE_NAME as $FUNCTION_NAME" |
| 143 | + hatch run examples:deploy "$EXAMPLE_NAME" --function-name "$FUNCTION_NAME" |
| 144 | + |
| 145 | + QUALIFIED_FUNCTION_NAME="$FUNCTION_NAME:\$LATEST" |
| 146 | + |
| 147 | + echo "Waiting for function to be ready..." |
| 148 | + aws lambda wait function-active --function-name "$FUNCTION_NAME" --endpoint-url "$LAMBDA_ENDPOINT" --region "${{ env.AWS_REGION }}" |
| 149 | + |
| 150 | + echo "Invoking Lambda function: $QUALIFIED_FUNCTION_NAME" |
| 151 | + aws lambda invoke \ |
| 152 | + --function-name "$QUALIFIED_FUNCTION_NAME" \ |
| 153 | + --cli-binary-format raw-in-base64-out \ |
| 154 | + --payload '{"name": "World"}' \ |
| 155 | + --region "${{ env.AWS_REGION }}" \ |
| 156 | + --endpoint-url "$LAMBDA_ENDPOINT" \ |
| 157 | + /tmp/response.json \ |
| 158 | + > /tmp/invoke_response.json |
| 159 | + |
| 160 | + echo "Response:" |
| 161 | + cat /tmp/response.json |
| 162 | + |
| 163 | + # Check for function errors |
| 164 | + FUNCTION_ERROR=$(jq -r '.FunctionError // empty' /tmp/invoke_response.json) |
| 165 | + if [ -n "$FUNCTION_ERROR" ]; then |
| 166 | + echo "ERROR: Lambda function failed with error: $FUNCTION_ERROR" |
| 167 | + cat /tmp/response.json |
| 168 | + exit 1 |
| 169 | + fi |
| 170 | + |
| 171 | + echo "Getting durable executions..." |
| 172 | + aws lambda list-durable-executions-by-function \ |
| 173 | + --function-name "$QUALIFIED_FUNCTION_NAME" \ |
| 174 | + --statuses SUCCEEDED \ |
| 175 | + --region "${{ env.AWS_REGION }}" \ |
| 176 | + --endpoint-url "$LAMBDA_ENDPOINT" \ |
| 177 | + --cli-binary-format raw-in-base64-out \ |
| 178 | + > /tmp/executions.json |
| 179 | + |
| 180 | + echo "Durable Executions:" |
| 181 | + cat /tmp/executions.json |
| 182 | + |
| 183 | + # Cleanup |
| 184 | + echo "Cleaning up function: $FUNCTION_NAME" |
| 185 | + aws lambda delete-function \ |
| 186 | + --function-name "$FUNCTION_NAME" \ |
| 187 | + --endpoint-url "$LAMBDA_ENDPOINT" \ |
| 188 | + --region "${{ env.AWS_REGION }}" || echo "Function cleanup failed or already deleted" |
| 189 | +
|
| 190 | +
|
0 commit comments