|
| 1 | +name: Regression Tests (Python) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + upstream-version: |
| 13 | + description: Upstream aws-cdk version to use in tests |
| 14 | + required: false |
| 15 | +env: |
| 16 | + AWS_ACCESS_KEY_ID: test |
| 17 | + AWS_SECRET_ACCESS_KEY: test |
| 18 | + |
| 19 | +jobs: |
| 20 | + integration-python: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - { language: python, node-version: '16.x', python-version: '3.10', region: us-east-1} |
| 27 | + - { language: python, node-version: '16.x', python-version: '3.9', region: us-east-1} |
| 28 | + - { language: python, node-version: '16.x', python-version: '3.8', region: us-east-1} |
| 29 | + - { language: python, node-version: '16.x', python-version: '3.7', region: us-east-1} |
| 30 | + |
| 31 | + env: |
| 32 | + AWS_REGION: ${{ matrix.region }} |
| 33 | + AWS_DEFAULT_REGION: ${{ matrix.region }} |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v2 |
| 37 | + with: |
| 38 | + path: repo |
| 39 | + |
| 40 | + - name: Use Node.js ${{ matrix.node-version }} |
| 41 | + uses: actions/setup-node@v2 |
| 42 | + with: |
| 43 | + node-version: ${{ matrix.node-version }} |
| 44 | + |
| 45 | + - name: Setup Python ${{ matrix.python-version }} |
| 46 | + uses: actions/setup-python@v2 |
| 47 | + with: |
| 48 | + python-version: '${{ matrix.python-version }}' |
| 49 | + |
| 50 | + - name: Install dependencies for aws-cdk-local |
| 51 | + working-directory: repo |
| 52 | + run: | |
| 53 | + npm install |
| 54 | + npm install aws-cdk |
| 55 | + echo "$(pwd)/bin" >> $GITHUB_PATH |
| 56 | +
|
| 57 | + - name: Install specific aws-cdk version |
| 58 | + working-directory: repo |
| 59 | + if: inputs.upstream-version |
| 60 | + run: npm install aws-cdk@${{ inputs.upstream-version }} |
| 61 | + |
| 62 | + - name: Verify specific aws-cdk version is used by cdklocal |
| 63 | + if: inputs.upstream-version |
| 64 | + run: | |
| 65 | + [[ $(cdklocal --version) =~ ^${{ inputs.upstream-version }}.* ]] || exit 1 |
| 66 | +
|
| 67 | + - name: Install localstack CLI |
| 68 | + run: pip install localstack |
| 69 | + |
| 70 | + - name: Create temporary directory for test |
| 71 | + run: mkdir cdk-test |
| 72 | + |
| 73 | + - name: Initialize new CDK app |
| 74 | + working-directory: cdk-test |
| 75 | + run: cdklocal init app --language=${{ matrix.language }} |
| 76 | + |
| 77 | + - name: Start and wait for localstack (Community) |
| 78 | + timeout-minutes: 10 |
| 79 | + run: | |
| 80 | + docker pull localstack/localstack:latest |
| 81 | + localstack start -d |
| 82 | + localstack wait -t 30 |
| 83 | +
|
| 84 | + - name: Install python libs |
| 85 | + working-directory: cdk-test |
| 86 | + run: | |
| 87 | + source .venv/bin/activate |
| 88 | + pip install -r requirements.txt |
| 89 | +
|
| 90 | + - name: Run bootstrap |
| 91 | + working-directory: cdk-test |
| 92 | + timeout-minutes: 1 |
| 93 | + run: | |
| 94 | + source .venv/bin/activate |
| 95 | + cdklocal bootstrap |
| 96 | +
|
| 97 | + - name: Deploy |
| 98 | + working-directory: cdk-test |
| 99 | + timeout-minutes: 1 |
| 100 | + run: | |
| 101 | + source .venv/bin/activate |
| 102 | + cdklocal deploy --require-approval=never |
| 103 | +
|
| 104 | + - name: Verify successful deployment |
| 105 | + run: | |
| 106 | + [ $(aws cloudformation describe-stacks --endpoint-url http://localhost:4566 | jq '[ .Stacks[] | select(.StackStatus == "CREATE_COMPLETE") ] | length') -eq 2 ] || exit 1 |
| 107 | + [ $(aws cloudformation describe-stacks --endpoint-url http://localhost:4566 | jq '[ .Stacks[] | select(.StackStatus == "CREATE_FAILED") ] | length') -eq 0 ] || exit 1 |
0 commit comments