|
| 1 | +name: "All Pull Request Tests" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + types: [opened, synchronize, reopened, ready_for_review] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # We use a single job to ensure that all steps run in the same environment and |
| 11 | + # reduce the number of minutes used. |
| 12 | + pr-tests: |
| 13 | + # Don't run on draft PRs |
| 14 | + if: github.event.pull_request.draft == false |
| 15 | + # Timeout after 10 minutes |
| 16 | + timeout-minutes: 10 |
| 17 | + # Define a matrix of PHP/WordPress versions to test against |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + php: [8.2, 8.3, 8.4] |
| 21 | + wordpress: ["latest"] |
| 22 | + runs-on: ubuntu-latest |
| 23 | + # Cancel any existing runs of this workflow |
| 24 | + concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-P${{ matrix.php }}-WP${{ matrix.wordpress }} |
| 26 | + cancel-in-progress: true |
| 27 | + # Name the job in the matrix |
| 28 | + name: "PR Tests PHP ${{ matrix.php }} WordPress ${{ matrix.wordpress }}" |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Run General Tests |
| 33 | + # See https://github.com/alleyinteractive/action-test-general for more options |
| 34 | + uses: alleyinteractive/action-test-general@develop |
| 35 | + |
| 36 | + - name: Run PHP Tests |
| 37 | + # See https://github.com/alleyinteractive/action-test-php for more options |
| 38 | + uses: alleyinteractive/action-test-php@develop |
| 39 | + with: |
| 40 | + php-version: '${{ matrix.php }}' |
| 41 | + wordpress-version: '${{ matrix.wordpress }}' |
| 42 | + skip-wordpress-install: 'true' |
| 43 | + # This required job ensures that all PR checks have passed before merging. |
| 44 | + all-pr-checks-passed: |
| 45 | + name: All PR checks passed |
| 46 | + needs: |
| 47 | + - pr-tests |
| 48 | + runs-on: ubuntu-latest |
| 49 | + if: always() |
| 50 | + steps: |
| 51 | + - name: Check job statuses |
| 52 | + run: | |
| 53 | + if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then |
| 54 | + echo "One or more jobs failed" |
| 55 | + exit 1 |
| 56 | + elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then |
| 57 | + echo "One or more jobs were cancelled" |
| 58 | + exit 1 |
| 59 | + else |
| 60 | + echo "All jobs passed or were skipped" |
| 61 | + exit 0 |
| 62 | + fi |
0 commit comments