|
| 1 | +--- |
| 2 | +############### |
| 3 | +## Run tests ## |
| 4 | +############### |
| 5 | + |
| 6 | +# |
| 7 | +# Documentation: |
| 8 | +# https://help.github.com/en/articles/workflow-syntax-for-github-actions |
| 9 | +# |
| 10 | + |
| 11 | +name: Test |
| 12 | +on: |
| 13 | + pull_request: |
| 14 | + push: |
| 15 | + branches: [ main ] |
| 16 | + |
| 17 | +########################## |
| 18 | +# Prevent duplicate jobs # |
| 19 | +########################## |
| 20 | +concurrency: |
| 21 | + group: ${{ github.repository }} |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +permissions: |
| 25 | + id-token: write |
| 26 | + contents: read |
| 27 | + |
| 28 | +############### |
| 29 | +# Run the job # |
| 30 | +############### |
| 31 | +jobs: |
| 32 | + self-test: |
| 33 | + name: Testing |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + ############################ |
| 37 | + # Checkout the source code # |
| 38 | + ############################ |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + ############################# |
| 43 | + # Configure AWS credentials # |
| 44 | + ############################# |
| 45 | + - name: Configure AWS credentials |
| 46 | + uses: aws-actions/configure-aws-credentials@v4 |
| 47 | + with: |
| 48 | + role-to-assume: arn:aws:iam::${{ vars.AWS_TESTING_ACCOUNT_ID }}:role/${{ vars.AWS_TESTING_ROLE }} |
| 49 | + aws-region: ${{ vars.AWS_TESTING_REGION }} |
| 50 | + mask-aws-account-id: false |
| 51 | + |
| 52 | + ###################### |
| 53 | + # Test Action itself # |
| 54 | + ###################### |
| 55 | + - name: Test With Log Tail |
| 56 | + uses: ./ |
| 57 | + with: |
| 58 | + # Pre created |
| 59 | + cluster: github-gha |
| 60 | + task-definition: arn:aws:ecs:${{ vars.AWS_TESTING_REGION }}:${{ vars.AWS_TESTING_ACCOUNT_ID }}:task-definition/github-gha-alpine |
| 61 | + |
| 62 | + assign-public-ip: 'ENABLED' |
| 63 | + security-group-ids: | |
| 64 | + sg-09a0ccb78d5be2a25 |
| 65 | + subnet-ids: | |
| 66 | + subnet-08bbfd6c53b0c1049 |
| 67 | + subnet-0fef13a6bef01f61a |
| 68 | + subnet-0a676289b4a27a7fa |
| 69 | +
|
| 70 | + tail-logs: true |
| 71 | + override-container: alpine |
| 72 | + override-container-command: | |
| 73 | + /bin/sh |
| 74 | + -c |
| 75 | + echo "Hello, World!" && \ |
| 76 | + echo "$TEST_VAR" && \ |
| 77 | + x=0; while [ $x -le 10 ]; do echo "Sleeping... $x" && x=$(( $x + 1 )) && sleep 2; done |
| 78 | + override-container-environment: | |
| 79 | + TEST_VAR=foobar123 |
| 80 | +
|
| 81 | + ###################### |
| 82 | + # Test Action itself # |
| 83 | + ###################### |
| 84 | + - name: Test Failure Exit Code |
| 85 | + id: expect-fail |
| 86 | + continue-on-error: true |
| 87 | + uses: ./ |
| 88 | + with: |
| 89 | + # Pre created |
| 90 | + cluster: github-gha |
| 91 | + task-definition: arn:aws:ecs:${{ vars.AWS_TESTING_REGION }}:${{ vars.AWS_TESTING_ACCOUNT_ID }}:task-definition/github-gha-alpine |
| 92 | + |
| 93 | + assign-public-ip: 'ENABLED' |
| 94 | + security-group-ids: | |
| 95 | + sg-09a0ccb78d5be2a25 |
| 96 | + subnet-ids: | |
| 97 | + subnet-08bbfd6c53b0c1049 |
| 98 | + subnet-0fef13a6bef01f61a |
| 99 | + subnet-0a676289b4a27a7fa |
| 100 | +
|
| 101 | + override-container: alpine |
| 102 | + override-container-command: | |
| 103 | + /bin/sh |
| 104 | + -c |
| 105 | + exit 1 |
| 106 | +
|
| 107 | + ########################## |
| 108 | + # Check expected failure # |
| 109 | + ########################## |
| 110 | + - name: Check previous for Failure |
| 111 | + if: steps.expect-fail.outcome == 'success' |
| 112 | + run: | |
| 113 | + echo "Expected a failure. Outcome: ${{ steps.expect-fail.outcome }}" |
| 114 | + exit 1 |
| 115 | +
|
| 116 | + ###################### |
| 117 | + # Test Action itself # |
| 118 | + ###################### |
| 119 | + - name: Test Fire and Forget |
| 120 | + uses: ./ |
| 121 | + with: |
| 122 | + # Pre created |
| 123 | + cluster: github-gha |
| 124 | + task-definition: arn:aws:ecs:${{ vars.AWS_TESTING_REGION }}:${{ vars.AWS_TESTING_ACCOUNT_ID }}:task-definition/github-gha-alpine |
| 125 | + |
| 126 | + assign-public-ip: 'ENABLED' |
| 127 | + security-group-ids: | |
| 128 | + sg-09a0ccb78d5be2a25 |
| 129 | + subnet-ids: | |
| 130 | + subnet-08bbfd6c53b0c1049 |
| 131 | + subnet-0fef13a6bef01f61a |
| 132 | + subnet-0a676289b4a27a7fa |
| 133 | +
|
| 134 | + task-wait-until-stopped: false |
| 135 | + override-container: alpine |
| 136 | + override-container-command: | |
| 137 | + /bin/sh |
| 138 | + -c |
| 139 | + x=0; while [ $x -le 10 ]; do echo "Sleeping... $x" && x=$(( $x + 1 )) && sleep 10; done |
0 commit comments