Skip to content

Commit 7dc1aec

Browse files
committed
wip: testing for cdk versions
1 parent da0f16d commit 7dc1aec

File tree

3 files changed

+178
-2
lines changed

3 files changed

+178
-2
lines changed

.github/workflows/test.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Regression Tests (Python)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: '0 5 * * *' # once daily at 5AM
12+
workflow_dispatch:
13+
inputs:
14+
cdk-version:
15+
description: Upstream aws-cdk version to use in tests
16+
required: false
17+
env:
18+
AWS_ACCESS_KEY_ID: test
19+
AWS_SECRET_ACCESS_KEY: test
20+
21+
jobs:
22+
integration-python-test:
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
matrix:
27+
node-version: ['22.x']
28+
python-version: ['3.12']
29+
region: ['us-east-1']
30+
cdk-version: ${{ fromJson(inputs.cdk-version || '[ "2.166.0", "2.167.0"]') }}
31+
fail-fast: true
32+
33+
env:
34+
AWS_REGION: ${{ matrix.region }}
35+
AWS_DEFAULT_REGION: ${{ matrix.region }}
36+
37+
steps:
38+
- uses: actions/checkout@v2
39+
with:
40+
path: repo
41+
42+
- name: Use Node.js ${{ matrix.node-version }}
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: ${{ matrix.node-version }}
46+
47+
- name: Setup Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: '${{ matrix.python-version }}'
51+
52+
- name: Install dependencies for aws-cdk-local
53+
working-directory: repo
54+
run: |
55+
npm install
56+
echo "$(pwd)/bin" >> $GITHUB_PATH
57+
58+
- name: Install specific aws-cdk version
59+
working-directory: repo
60+
run: |
61+
if [ -n "${{ matrix.cdk-version }}" ]; then
62+
npm install aws-cdk@${{ matrix.cdk-version }}
63+
else
64+
npm install aws-cdk
65+
fi
66+
67+
- name: Verify specific aws-cdk version is used by cdklocal
68+
run: |
69+
if [ -n "${{ matrix.cdk-version }}" ]; then
70+
[[ $(cdklocal --version) =~ ^${{ matrix.cdk-version }}.* ]] || exit 1
71+
else
72+
echo "Latest version installed, skipping version verification."
73+
fi
74+
75+
- name: Install AWS CLI
76+
run: pip install awscli
77+
78+
- name: Install localstack CLI
79+
run: pip install localstack
80+
81+
- name: Start and wait for localstack (Community)
82+
timeout-minutes: 10
83+
run: |
84+
# Check if the localstack-main container is already running
85+
if ! docker ps --filter "name=localstack-main" --filter "status=running" -q; then
86+
echo "LocalStack container is not running. Starting LocalStack..."
87+
docker pull localstack/localstack:latest
88+
localstack start -d
89+
localstack wait -t 30
90+
else
91+
echo "LocalStack container is already running. Skipping start."
92+
fi
93+
94+
- name: Set up unique folder
95+
run: |
96+
export WORK_DIR="cdk-test-$GITHUB_RUN_NUMBER"
97+
export STACK_NAME="CdkTest${GITHUB_RUN_NUMBER}Stack"
98+
mkdir -p $WORK_DIR
99+
echo "WORK_DIR=$WORK_DIR" >> $GITHUB_ENV
100+
echo "STACK_NAME=$STACK_NAME" >> $GITHUB_ENV
101+
102+
- name: Initialize new CDK app
103+
run: |
104+
cd $WORK_DIR
105+
cdklocal init app --language=python
106+
107+
- name: Install python libs
108+
run: |
109+
cd $WORK_DIR
110+
source .venv/bin/activate
111+
pip install -r requirements.txt
112+
113+
- name: Run bootstrap
114+
timeout-minutes: 1
115+
run: |
116+
cd $WORK_DIR
117+
source .venv/bin/activate
118+
cdklocal bootstrap
119+
120+
- name: Deploy
121+
timeout-minutes: 1
122+
run: |
123+
cd $WORK_DIR
124+
source .venv/bin/activate
125+
cdklocal deploy --require-approval=never
126+
127+
- name: Clean up
128+
if: always()
129+
run: rm -rf $WORK_DIR
130+
131+
- name: Verify successful deployment
132+
run: |
133+
[ $(aws cloudformation describe-stacks --stack-name $STACK_NAME --endpoint-url http://localhost:4566 | jq '[ .Stacks[] | select(.StackStatus == "CREATE_COMPLETE") ] | length') -eq 1 ] || exit 1

package-lock.json

Lines changed: 44 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"license": "Apache-2.0",
1717
"dependencies": {
18+
"aws-cdk": "^2.171.1",
1819
"diff": "^5.0.0"
1920
},
2021
"devDependencies": {

0 commit comments

Comments
 (0)