Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workflow to test against multiple aws-cdk versions #98

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
58a8a53
wip: testing for cdk versions
pinzon Dec 2, 2024
d7423b1
change job name
pinzon Dec 2, 2024
27f4b4b
change job name title
pinzon Dec 2, 2024
84b8829
disable fast fail and add latest version
pinzon Dec 2, 2024
28729b7
use fake credentials
pinzon Dec 2, 2024
278ff0c
set path after aws-cdk installation
pinzon Dec 2, 2024
8b4672f
merge installation
pinzon Dec 2, 2024
dcbe2d8
test
pinzon Dec 3, 2024
e8634be
test
pinzon Dec 3, 2024
46f9e4a
test
pinzon Dec 3, 2024
df76582
test
pinzon Dec 3, 2024
4458e85
test
pinzon Dec 3, 2024
1483273
test
pinzon Dec 3, 2024
932f40a
test
pinzon Dec 3, 2024
d19257e
matrix generation
pinzon Dec 5, 2024
1bfd52f
resource provider
pinzon Dec 5, 2024
8c9be4d
fix empty array
pinzon Dec 5, 2024
d50edd6
add output
pinzon Dec 5, 2024
49d944c
use output
pinzon Dec 5, 2024
f401be4
use output
pinzon Dec 5, 2024
8a4319a
use output
pinzon Dec 5, 2024
5c8c328
use output
pinzon Dec 5, 2024
5ef7e93
use output
pinzon Dec 5, 2024
1e63c74
use output
pinzon Dec 5, 2024
50bf646
use output
pinzon Dec 5, 2024
69ee1e5
use output
pinzon Dec 5, 2024
d4b1454
use output
pinzon Dec 5, 2024
ba8f7f6
use output
pinzon Dec 5, 2024
a91245e
use a preselected versions list by the default
pinzon Dec 16, 2024
69e6c88
fix
pinzon Dec 16, 2024
d80800e
fix
pinzon Dec 16, 2024
e66c588
fix
pinzon Dec 16, 2024
40f6ef9
fix
pinzon Dec 16, 2024
edf769b
fix
pinzon Dec 16, 2024
64c2c50
fix
pinzon Dec 16, 2024
32d026c
fix
pinzon Dec 16, 2024
602fe3c
remove older v1 versions
dominikschubert Dec 18, 2024
81a1388
add acknowledgement
pinzon Dec 18, 2024
2896a69
only npm install once
pinzon Dec 18, 2024
6fd0283
fix
pinzon Dec 18, 2024
3d0d586
fix
pinzon Dec 18, 2024
ee96c04
fix
pinzon Dec 18, 2024
7ebccfd
fix
pinzon Dec 18, 2024
6a98540
fix
pinzon Dec 18, 2024
4dc26a6
remove all v1 versions for now
dominikschubert Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Dynamic CDK version testing

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
node-version:
required: false
default: "22.x"
python-version:
required: false
default: "3.12"
run-all-latest-cdk-versions:
required: false
type: boolean
default: false

env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_REGION: us-east-1
AWS_DEFAULT_REGION: us-east-1

jobs:
generate-cdk-version-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.MATRIX }}
steps:
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}
- name: Obtain all aws-cdk latest versions
id: heavy-matrix
if: ${{ inputs.run-all-latest-cdk-versions == true }}
run: |
export VERSIONS_ARRAY=$(npm view aws-cdk versions --json | jq -c '.[-256:]' )
echo "VERSIONS_ARRAY=$VERSIONS_ARRAY" >> $GITHUB_ENV

- name: Obtain default list of aws-cdk versions
id: simple-matrix
if: ${{ inputs.run-all-latest-cdk-versions == false }}
run: |
export VERSIONS_ARRAY='["2.30.0", "2.50.0", "2.75.0", "2.120.0", "2.166.0", "2.167.0", ""]'
echo "VERSIONS_ARRAY=$VERSIONS_ARRAY" >> $GITHUB_ENV

- name: Generate matrix
id: set-matrix
run: |
export MATRIX="{\"cdk-version\":$VERSIONS_ARRAY}"
echo "MATRIX=$MATRIX" >> $GITHUB_OUTPUT

version-testing:
runs-on: ubuntu-latest
needs: generate-cdk-version-matrix
strategy:
matrix: ${{fromJson(needs.generate-cdk-version-matrix.outputs.matrix)}}

steps:
- uses: actions/checkout@v2
with:
path: repo

- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node-version }}

- name: Setup Python ${{ inputs.python-version }}
uses: actions/setup-python@v2
with:
python-version: "${{ inputs.python-version }}"

- name: Install dependencies for aws-cdk-local
working-directory: repo
run: |
npm install
if [ -n "${{ matrix.cdk-version }}" ]; then
npm install aws-cdk@${{ matrix.cdk-version }}
else
npm install aws-cdk
fi
echo "$(pwd)/bin" >> $GITHUB_PATH

- name: Verify specific aws-cdk version is used by cdklocal
run: |
cdklocal --version

- name: Install localstack CLI
run: pip install localstack

- name: Set up unique folder
run: |
export WORK_DIR="cdk-test-$GITHUB_RUN_NUMBER"
export STACK_NAME="CdkTest${GITHUB_RUN_NUMBER}Stack"
mkdir -p $WORK_DIR
echo "WORK_DIR=$WORK_DIR" >> $GITHUB_ENV
echo "STACK_NAME=$STACK_NAME" >> $GITHUB_ENV

- name: Initialize new CDK app
working-directory: ${{env.WORK_DIR}}
run: cdklocal init app --language=python

- name: Start and wait for localstack (Community)
timeout-minutes: 10
run: |
docker pull localstack/localstack:latest
localstack start -d
localstack wait -t 30

- name: Install python libs
working-directory: ${{env.WORK_DIR}}
run: |
source .venv/bin/activate
pip install -r requirements.txt

- name: Run bootstrap
timeout-minutes: 1
working-directory: ${{env.WORK_DIR}}
run: |
source .venv/bin/activate
if [ "${{ matrix.cdk-version }}" = "1.150.0" ]; then
cdklocal acknowledge 19836
fi
cdklocal bootstrap

- name: Deploy
timeout-minutes: 1
working-directory: ${{env.WORK_DIR}}
run: |
source .venv/bin/activate
cdklocal deploy --require-approval=never

- name: Verify successful deployment
run: |
[ $(aws cloudformation describe-stacks --stack-name $STACK_NAME --endpoint-url http://localhost:4566 | jq '[ .Stacks[] | select(.StackStatus == "CREATE_COMPLETE") ] | length') -eq 1 ] || exit 1
Loading