From 7dc1aec7fd23086b656fa1c658cb20e0c9cba22d Mon Sep 17 00:00:00 2001 From: Cristopher Pinzon Date: Mon, 2 Dec 2024 15:21:11 -0500 Subject: [PATCH] wip: testing for cdk versions --- .github/workflows/test.yml | 133 +++++++++++++++++++++++++++++++++++++ package-lock.json | 46 ++++++++++++- package.json | 1 + 3 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3c553fa --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,133 @@ +name: Regression Tests (Python) + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 5 * * *' # once daily at 5AM + workflow_dispatch: + inputs: + cdk-version: + description: Upstream aws-cdk version to use in tests + required: false +env: + AWS_ACCESS_KEY_ID: test + AWS_SECRET_ACCESS_KEY: test + +jobs: + integration-python-test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: ['22.x'] + python-version: ['3.12'] + region: ['us-east-1'] + cdk-version: ${{ fromJson(inputs.cdk-version || '[ "2.166.0", "2.167.0"]') }} + fail-fast: true + + env: + AWS_REGION: ${{ matrix.region }} + AWS_DEFAULT_REGION: ${{ matrix.region }} + + steps: + - uses: actions/checkout@v2 + with: + path: repo + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: '${{ matrix.python-version }}' + + - name: Install dependencies for aws-cdk-local + working-directory: repo + run: | + npm install + echo "$(pwd)/bin" >> $GITHUB_PATH + + - name: Install specific aws-cdk version + working-directory: repo + run: | + if [ -n "${{ matrix.cdk-version }}" ]; then + npm install aws-cdk@${{ matrix.cdk-version }} + else + npm install aws-cdk + fi + + - name: Verify specific aws-cdk version is used by cdklocal + run: | + if [ -n "${{ matrix.cdk-version }}" ]; then + [[ $(cdklocal --version) =~ ^${{ matrix.cdk-version }}.* ]] || exit 1 + else + echo "Latest version installed, skipping version verification." + fi + + - name: Install AWS CLI + run: pip install awscli + + - name: Install localstack CLI + run: pip install localstack + + - name: Start and wait for localstack (Community) + timeout-minutes: 10 + run: | + # Check if the localstack-main container is already running + if ! docker ps --filter "name=localstack-main" --filter "status=running" -q; then + echo "LocalStack container is not running. Starting LocalStack..." + docker pull localstack/localstack:latest + localstack start -d + localstack wait -t 30 + else + echo "LocalStack container is already running. Skipping start." + fi + + - 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 + run: | + cd $WORK_DIR + cdklocal init app --language=python + + - name: Install python libs + run: | + cd $WORK_DIR + source .venv/bin/activate + pip install -r requirements.txt + + - name: Run bootstrap + timeout-minutes: 1 + run: | + cd $WORK_DIR + source .venv/bin/activate + cdklocal bootstrap + + - name: Deploy + timeout-minutes: 1 + run: | + cd $WORK_DIR + source .venv/bin/activate + cdklocal deploy --require-approval=never + + - name: Clean up + if: always() + run: rm -rf $WORK_DIR + + - 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 diff --git a/package-lock.json b/package-lock.json index 6dfd444..be2b819 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "aws-cdk-local", - "version": "2.18.1", + "version": "2.19.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "aws-cdk-local", - "version": "2.18.1", + "version": "2.19.0", "license": "Apache-2.0", "dependencies": { + "aws-cdk": "^2.171.1", "diff": "^5.0.0" }, "bin": { @@ -125,6 +126,20 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/aws-cdk": { + "version": "2.171.1", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.171.1.tgz", + "integrity": "sha512-IWENyT4F5UcLr1szLsbipUdjIHn8FD3d/RvaIvhs2+qCamkfEV5mqv/ChMvRJ8H2jebhIZ2iz74or9O5Ismp+Q==", + "bin": { + "cdk": "bin/cdk" + }, + "engines": { + "node": ">= 14.15.0" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -471,6 +486,19 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", @@ -1001,6 +1029,14 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "aws-cdk": { + "version": "2.171.1", + "resolved": "https://registry.npmjs.org/aws-cdk/-/aws-cdk-2.171.1.tgz", + "integrity": "sha512-IWENyT4F5UcLr1szLsbipUdjIHn8FD3d/RvaIvhs2+qCamkfEV5mqv/ChMvRJ8H2jebhIZ2iz74or9O5Ismp+Q==", + "requires": { + "fsevents": "2.3.2" + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1266,6 +1302,12 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", diff --git a/package.json b/package.json index 5ca3ae7..9274276 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "license": "Apache-2.0", "dependencies": { + "aws-cdk": "^2.171.1", "diff": "^5.0.0" }, "devDependencies": {