Add execution error handling using OperationId from LastOperations #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Integration Tests | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| test-modes: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test-case: | |
| - name: "create-and-execute" | |
| mode: "create-and-execute" | |
| - name: "create-only" | |
| mode: "create-only" | |
| - name: "drift-revert" | |
| mode: "create-only" | |
| deployment-mode: "REVERT_DRIFT" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Test ${{ matrix.test-case.name }} | |
| id: deploy | |
| uses: ./ | |
| with: | |
| mode: ${{ matrix.test-case.mode }} | |
| name: test-${{ matrix.test-case.name }}-${{ github.run_number }} | |
| template: | | |
| AWSTemplateFormatVersion: '2010-09-09' | |
| Parameters: | |
| BucketPrefix: | |
| Type: String | |
| Default: test | |
| Resources: | |
| TestBucket: | |
| Type: AWS::S3::Bucket | |
| Properties: | |
| BucketName: !Sub '${BucketPrefix}-bucket-${AWS::StackId}' | |
| Outputs: | |
| BucketName: | |
| Value: !Ref TestBucket | |
| parameter-overrides: "BucketPrefix=integration-test" | |
| deployment-mode: ${{ matrix.test-case.deployment-mode }} | |
| no-fail-on-empty-changeset: "1" | |
| - name: Verify outputs | |
| run: | | |
| echo "Stack ID: ${{ steps.deploy.outputs.stack-id }}" | |
| echo "Bucket Name: ${{ steps.deploy.outputs.BucketName }}" | |
| if [ "${{ matrix.test-case.mode }}" = "create-only" ]; then | |
| echo "Change Set ID: ${{ steps.deploy.outputs.change-set-id }}" | |
| echo "Has Changes: ${{ steps.deploy.outputs.has-changes }}" | |
| echo "Changes Count: ${{ steps.deploy.outputs.changes-count }}" | |
| fi | |
| test-execute-only: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Create change set | |
| id: create-cs | |
| uses: ./ | |
| with: | |
| mode: "create-only" | |
| name: test-execute-${{ github.run_number }} | |
| template: | | |
| AWSTemplateFormatVersion: '2010-09-09' | |
| Resources: | |
| TestBucket: | |
| Type: AWS::S3::Bucket | |
| - name: Execute change set | |
| uses: ./ | |
| with: | |
| mode: "execute-only" | |
| name: test-execute-${{ github.run_number }} | |
| execute-change-set-id: ${{ steps.create-cs.outputs.change-set-id }} | |
| test-advanced-features: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Test with all features | |
| uses: ./ | |
| with: | |
| name: test-advanced-${{ github.run_number }} | |
| template: | | |
| AWSTemplateFormatVersion: '2010-09-09' | |
| Parameters: | |
| Environment: | |
| Type: String | |
| Resources: | |
| TestBucket: | |
| Type: AWS::S3::Bucket | |
| Properties: | |
| Tags: | |
| - Key: Environment | |
| Value: !Ref Environment | |
| parameter-overrides: "Environment=test" | |
| capabilities: "CAPABILITY_IAM,CAPABILITY_NAMED_IAM" | |
| tags: '[{"Key": "Project", "Value": "Integration-Test"}]' | |
| timeout-in-minutes: 10 | |
| include-nested-stacks-change-set: "1" | |
| change-set-name: "custom-changeset-name" | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| needs: [test-modes, test-execute-only, test-advanced-features] | |
| if: always() | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Cleanup test stacks | |
| run: | | |
| aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE --query "StackSummaries[?contains(StackName, 'test-') && contains(StackName, '${{ github.run_number }}')].StackName" --output text | tr '\t' '\n' | while read stack; do | |
| if [ ! -z "$stack" ]; then | |
| echo "Deleting stack: $stack" | |
| aws cloudformation delete-stack --stack-name "$stack" || true | |
| fi | |
| done |