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