|
| 1 | +# Description: This workflow runs test suite against PRs that are not from forks. |
| 2 | +# |
| 3 | +# Triggers: |
| 4 | +# - When a PR is opened, updated, or labeled against specific branches |
| 5 | +# - Only runs when the PR has the 'run-tests' label |
| 6 | +# - Only runs for internal PRs (not from forks) |
| 7 | + |
| 8 | +name: Test / Internal PRs |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: push-e2e-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +on: |
| 15 | + pull_request: |
| 16 | + branches: [main, release] |
| 17 | + types: [opened, synchronize, labeled] |
| 18 | + |
| 19 | +jobs: |
| 20 | + setup: |
| 21 | + if: | |
| 22 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 23 | + contains(github.event.pull_request.labels.*.name, 'run-tests') |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + statuses: write # This is required for running set-status actions |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017 |
| 29 | + - name: Update status to pending prior to starting tests |
| 30 | + uses: ./.github/actions/set-status |
| 31 | + with: |
| 32 | + sha: ${{ github.event.pull_request.head.sha }} |
| 33 | + state: 'pending' |
| 34 | + context: 'Run PR e2e checks' |
| 35 | + description: 'PR e2e checks are now running' |
| 36 | + # URL below is a link to the current workflow run to allow users to see the status of the workflow. |
| 37 | + target-url: https://github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }} |
| 38 | + |
| 39 | + prebuild: |
| 40 | + needs: setup |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + platform: [ubuntu-latest, macos-latest] |
| 44 | + uses: ./.github/workflows/callable-prebuild-amplify-js.yml |
| 45 | + with: |
| 46 | + runs_on: ${{ matrix.platform }} |
| 47 | + |
| 48 | + prebuild-samples-staging: |
| 49 | + needs: setup |
| 50 | + secrets: inherit |
| 51 | + uses: ./.github/workflows/callable-prebuild-samples-staging.yml |
| 52 | + |
| 53 | + e2e: |
| 54 | + needs: [setup, prebuild, prebuild-samples-staging] |
| 55 | + secrets: inherit |
| 56 | + uses: ./.github/workflows/callable-e2e-tests.yml |
| 57 | + |
| 58 | + update-success-status: |
| 59 | + if: ${{ success() }} |
| 60 | + needs: [setup, prebuild, prebuild-samples-staging, e2e] |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + statuses: write # This is required for running set-status actions |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017 |
| 66 | + - name: Update status when tests are successful |
| 67 | + uses: ./.github/actions/set-status |
| 68 | + with: |
| 69 | + sha: ${{ github.event.pull_request.head.sha }} |
| 70 | + state: 'success' |
| 71 | + context: 'Run PR e2e checks' |
| 72 | + description: 'PR e2e checks have finished running' |
| 73 | + target-url: https://github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }} |
| 74 | + |
| 75 | + update-failure-status: |
| 76 | + if: ${{ failure() }} |
| 77 | + needs: [setup, prebuild, prebuild-samples-staging, e2e] |
| 78 | + runs-on: ubuntu-latest |
| 79 | + permissions: |
| 80 | + statuses: write # This is required for running set-status actions |
| 81 | + steps: |
| 82 | + - uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62 # v4.1.3 https://github.com/actions/checkout/commit/cd7d8d697e10461458bc61a30d094dc601a8b017 |
| 83 | + - name: Update status when tests are not successful |
| 84 | + uses: ./.github/actions/set-status |
| 85 | + with: |
| 86 | + sha: ${{ github.event.pull_request.head.sha }} |
| 87 | + state: 'failure' |
| 88 | + context: 'Run e2e PR checks' |
| 89 | + description: 'PR e2e checks have failed' |
| 90 | + target-url: https://github.com/${{ github.event.repository.owner.login }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }} |
0 commit comments