-
Notifications
You must be signed in to change notification settings - Fork 19
203 lines (170 loc) · 7.32 KB
/
Copy pathintegration-tests.yml
File metadata and controls
203 lines (170 loc) · 7.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Integration Tests
on:
pull_request:
branches: [ main ]
permissions:
contents: read
id-token: write
jobs:
integration-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.13"]
steps:
- name: Checkout Language SDK (this PR)
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: language-sdk
- name: Checkout the latest Testing SDK
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: aws/aws-durable-execution-sdk-python-testing
path: language-sdk/packages/testing-sdk
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
run: python -m pip install hatch==1.16.5
- name: Setup and run tests
working-directory: language-sdk
run: |
echo "Running SDK tests..."
hatch run -- test:pip install -e packages/testing-sdk
hatch run types:check
hatch run test:cov
- name: Verify package build
working-directory: language-sdk/packages/aws-durable-execution-sdk-python
run: hatch build
e2e-tests:
needs: integration-tests
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
env:
AWS_REGION: us-west-2
SAM_CLI_TELEMETRY: 0
steps:
- name: Checkout Language SDK (this PR)
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: language-sdk
- name: Checkout the latest Testing SDK
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: aws/aws-durable-execution-sdk-python-testing
path: language-sdk/packages/testing-sdk
- name: Set up Python 3.13
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.13'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: "${{ secrets.ACTIONS_INTEGRATION_ROLE_NAME }}"
role-session-name: languageSDKIntegrationTest
aws-region: ${{ env.AWS_REGION }}
- name: Install Hatch
run: python -m pip install hatch==1.16.5
- name: Set up SAM CLI
uses: aws-actions/setup-sam@v2
- name: Get integration examples
id: get-examples
working-directory: language-sdk/packages/aws-durable-execution-sdk-python-examples
run: |
echo "examples=$(jq -c '.examples | map(select(.integration == true)) | .[0:2]' examples-catalog.json)" >> $GITHUB_OUTPUT
- name: Install AWS CLI v2
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "/tmp/awscliv2.zip"
unzip -q /tmp/awscliv2.zip -d /tmp
rm /tmp/awscliv2.zip
sudo /tmp/aws/install --update
rm -rf /tmp/aws/
- name: Deploy and test examples
working-directory: language-sdk
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
LAMBDA_ENDPOINT: "https://lambda.us-west-2.amazonaws.com"
INVOKE_ACCOUNT_ID: ${{ secrets.INVOKE_ACCOUNT_ID }}
KMS_KEY_ARN: ${{ secrets.KMS_KEY_ARN }}
run: |
hatch run -- examples:pip install -e packages/testing-sdk
# Get first integration example for testing
EXAMPLE_NAME=$(echo '${{ steps.get-examples.outputs.examples }}' | jq -r '.[0].name')
EXAMPLE_NAME_CLEAN=$(echo "$EXAMPLE_NAME" | sed 's/ //g')
FUNCTION_NAME="${EXAMPLE_NAME_CLEAN}-LanguageSDK-PR-${{ github.event.number }}"
STACK_NAME="${FUNCTION_NAME}-stack"
SOURCE_DIR="$PWD/packages/aws-durable-execution-sdk-python-examples/.aws-sam/source"
TEMPLATE_FILE="$PWD/packages/aws-durable-execution-sdk-python-examples/.aws-sam/template.generated.json"
BUILD_DIR="$PWD/packages/aws-durable-execution-sdk-python-examples/.aws-sam/build"
# Remove a legacy directly-created Lambda only when no SAM stack owns it.
if ! aws cloudformation describe-stacks --stack-name "$STACK_NAME" --region "${{ env.AWS_REGION }}" >/dev/null 2>&1; then
echo "Cleaning up legacy function if present..."
aws lambda delete-function \
--function-name "$FUNCTION_NAME" \
--endpoint-url "$LAMBDA_ENDPOINT" \
--region "${{ env.AWS_REGION }}" 2>/dev/null || echo "No legacy function to clean up"
sleep 5
fi
echo "Deploying example: $EXAMPLE_NAME as $FUNCTION_NAME"
python packages/aws-durable-execution-sdk-python-examples/scripts/build_deployment_artifacts.py "$SOURCE_DIR"
python packages/aws-durable-execution-sdk-python-examples/scripts/generate_sam_template.py \
--example-name "$EXAMPLE_NAME" \
--function-name "$FUNCTION_NAME" \
--code-uri "$SOURCE_DIR" \
--output "$TEMPLATE_FILE"
sam build \
--template-file "$TEMPLATE_FILE" \
--build-dir "$BUILD_DIR" \
--use-container
PARAMETER_OVERRIDES=("LambdaEndpoint=$LAMBDA_ENDPOINT")
if [ -n "${KMS_KEY_ARN:-}" ]; then
PARAMETER_OVERRIDES+=("KmsKeyArn=$KMS_KEY_ARN")
fi
sam deploy \
--template-file "$BUILD_DIR/template.yaml" \
--stack-name "$STACK_NAME" \
--capabilities CAPABILITY_IAM \
--resolve-s3 \
--no-confirm-changeset \
--no-fail-on-empty-changeset \
--region "${{ env.AWS_REGION }}" \
--parameter-overrides "${PARAMETER_OVERRIDES[@]}"
QUALIFIED_FUNCTION_NAME="$FUNCTION_NAME:\$LATEST"
echo "Waiting for function to be ready..."
aws lambda wait function-active --function-name "$FUNCTION_NAME" --endpoint-url "$LAMBDA_ENDPOINT" --region "${{ env.AWS_REGION }}"
echo "Invoking Lambda function: $QUALIFIED_FUNCTION_NAME"
aws lambda invoke \
--function-name "$QUALIFIED_FUNCTION_NAME" \
--cli-binary-format raw-in-base64-out \
--payload '{"name": "World"}' \
--region "${{ env.AWS_REGION }}" \
--endpoint-url "$LAMBDA_ENDPOINT" \
/tmp/response.json \
> /tmp/invoke_response.json
echo "Response:"
cat /tmp/response.json
# Check for function errors
FUNCTION_ERROR=$(jq -r '.FunctionError // empty' /tmp/invoke_response.json)
if [ -n "$FUNCTION_ERROR" ]; then
echo "ERROR: Lambda function failed with error: $FUNCTION_ERROR"
cat /tmp/response.json
exit 1
fi
echo "Getting durable executions..."
aws lambda list-durable-executions-by-function \
--function-name "$QUALIFIED_FUNCTION_NAME" \
--statuses SUCCEEDED \
--region "${{ env.AWS_REGION }}" \
--endpoint-url "$LAMBDA_ENDPOINT" \
--cli-binary-format raw-in-base64-out \
> /tmp/executions.json
echo "Durable Executions:"
cat /tmp/executions.json
# Cleanup
echo "Cleaning up stack: $STACK_NAME"
sam delete \
--stack-name "$STACK_NAME" \
--region "${{ env.AWS_REGION }}" \
--no-prompts || echo "Stack cleanup failed or already deleted"