Skip to content

Commit 3ae645a

Browse files
committed
ci: deploy examples with sam stack
1 parent 99b482e commit 3ae645a

14 files changed

Lines changed: 404 additions & 2171 deletions

File tree

.github/workflows/cloud-tests.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Cloud tests
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
inputs:
8+
lambda_endpoint:
9+
description: "Optional Lambda endpoint URL for deploying and running cloud tests"
10+
required: false
11+
type: string
12+
13+
env:
14+
AWS_REGION: us-west-2
15+
16+
permissions:
17+
id-token: write
18+
contents: read
19+
20+
jobs:
21+
example-tests:
22+
name: example-tests (${{ matrix.python-version }})
23+
runs-on: ubuntu-latest
24+
concurrency:
25+
group: cloud-tests-${{ matrix.python-prefix }}
26+
cancel-in-progress: false
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- python-version: "3.11"
32+
python-prefix: Py311
33+
- python-version: "3.12"
34+
python-prefix: Py312
35+
- python-version: "3.13"
36+
python-prefix: Py313
37+
- python-version: "3.14"
38+
python-prefix: Py314
39+
steps:
40+
- uses: actions/checkout@v7
41+
42+
- name: Setup Python
43+
uses: actions/setup-python@v6
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
- name: Configure AWS credentials
48+
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
49+
uses: aws-actions/configure-aws-credentials@v6
50+
with:
51+
role-to-assume: "${{ secrets.TEST_ROLE_ARN }}"
52+
role-session-name: pythonTestingLibraryGitHubIntegrationTest
53+
aws-region: ${{ env.AWS_REGION }}
54+
55+
- name: Verify AWS test account
56+
if: github.event_name != 'workflow_dispatch' || github.actor != 'nektos/act'
57+
env:
58+
TEST_ACCOUNT_ID: ${{ secrets.TEST_ACCOUNT_ID }}
59+
run: |
60+
ACTUAL_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
61+
if [ "$ACTUAL_ACCOUNT_ID" != "$TEST_ACCOUNT_ID" ]; then
62+
echo "Expected AWS account $TEST_ACCOUNT_ID but assumed into $ACTUAL_ACCOUNT_ID"
63+
exit 1
64+
fi
65+
echo "Using AWS test account $ACTUAL_ACCOUNT_ID"
66+
67+
- name: Install Hatch
68+
run: pip install hatch
69+
70+
- name: Setup SAM CLI
71+
uses: aws-actions/setup-sam@v2
72+
73+
- name: Build examples
74+
run: |
75+
hatch run -- examples:pip install -e packages/aws-durable-execution-sdk-python packages/aws-durable-execution-sdk-python-otel packages/aws-durable-execution-sdk-python-testing
76+
hatch run examples:build
77+
hatch run examples:generate-sam-template
78+
79+
- name: Deploy all examples with SAM
80+
id: deploy
81+
env:
82+
LAMBDA_EXECUTION_ROLE_ARN: ${{ secrets.TEST_LAMBDA_EXECUTION_ROLE_ARN }}
83+
LAMBDA_ENDPOINT_OVERRIDE: ${{ github.event.inputs.lambda_endpoint || vars.TEST_LAMBDA_ENDPOINT }}
84+
PYTHON_PREFIX: ${{ matrix.python-prefix }}
85+
PYTHON_RUNTIME: python${{ matrix.python-version }}
86+
run: |
87+
STACK_NAME="${PYTHON_PREFIX}-python-examples"
88+
FUNCTION_NAME_PREFIX="${PYTHON_PREFIX}-"
89+
90+
STACK_NAME=$(echo "$STACK_NAME" | tr -cd '[:alnum:]-' | cut -c1-128)
91+
export STACK_NAME FUNCTION_NAME_PREFIX
92+
echo "STACK_NAME=$STACK_NAME" >> $GITHUB_ENV
93+
94+
echo "Building SAM application"
95+
sam build --template-file packages/aws-durable-execution-sdk-python-examples/template.generated.json
96+
97+
PARAMETER_OVERRIDES=(
98+
PythonRuntime="$PYTHON_RUNTIME"
99+
FunctionNamePrefix="$FUNCTION_NAME_PREFIX"
100+
LambdaExecutionRoleArn="$LAMBDA_EXECUTION_ROLE_ARN"
101+
)
102+
if [ -n "$LAMBDA_ENDPOINT_OVERRIDE" ]; then
103+
PARAMETER_OVERRIDES+=(LambdaEndpoint="$LAMBDA_ENDPOINT_OVERRIDE")
104+
echo "LAMBDA_ENDPOINT=$LAMBDA_ENDPOINT_OVERRIDE" >> $GITHUB_ENV
105+
echo "Using custom Lambda endpoint override"
106+
fi
107+
108+
echo "Deploying stack $STACK_NAME with function prefix $FUNCTION_NAME_PREFIX and runtime $PYTHON_RUNTIME"
109+
sam deploy \
110+
--template-file .aws-sam/build/template.yaml \
111+
--stack-name "$STACK_NAME" \
112+
--resolve-s3 \
113+
--no-confirm-changeset \
114+
--no-fail-on-empty-changeset \
115+
--region "$AWS_REGION" \
116+
--parameter-overrides "${PARAMETER_OVERRIDES[@]}"
117+
118+
PYTEST_FUNCTION_NAME_MAP=$(
119+
python packages/aws-durable-execution-sdk-python-examples/scripts/generate_function_name_map.py \
120+
--function-name-prefix "$FUNCTION_NAME_PREFIX"
121+
)
122+
123+
echo "PYTEST_FUNCTION_NAME_MAP=$PYTEST_FUNCTION_NAME_MAP" >> $GITHUB_ENV
124+
125+
- name: Run Integration Tests
126+
env:
127+
AWS_REGION: ${{ env.AWS_REGION }}
128+
run: |
129+
echo "Running integration tests for all deployed examples"
130+
echo "AWS Region: ${AWS_REGION}"
131+
echo "Configured function map: ${PYTEST_FUNCTION_NAME_MAP}"
132+
133+
hatch run test:examples-integration -n 8 --dist loadfile

.github/workflows/deploy-examples.yml

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)