Skip to content

Commit 6e96515

Browse files
author
Rares Polenciuc
committed
ci: add end-to-end testing with backend deployment to integration workflow
Add e2e-tests job that deploys and tests examples against backend infrastructure. Runs after unit tests pass with proper cleanup.
1 parent b5496ca commit 6e96515

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
permissions:
88
contents: read
9+
id-token: write
910

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

0 commit comments

Comments
 (0)