|
1 | 1 | name: PHPUnit |
2 | | -permissions: |
3 | | - contents: read |
4 | 2 |
|
5 | 3 | on: |
6 | 4 | push: |
|
11 | 9 | branches: |
12 | 10 | - develop |
13 | 11 |
|
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
14 | 15 | jobs: |
15 | | - check-diffs: |
| 16 | + phpunit: |
| 17 | + name: Test PHP ${{ matrix.php }} WP ${{ matrix.wp }} |
16 | 18 | runs-on: ubuntu-latest |
17 | | - outputs: |
18 | | - has_changed: ${{ steps.files-changed.outputs.RSA_PHP_FILES_CHANGED }} |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + php: [ '8.4', '8.3', '8.2', '8.1', '8.0', '7.4' ] |
| 23 | + wp: [ latest, trunk ] |
| 24 | + env: |
| 25 | + WP_ENV_PHP_VERSION: ${{ matrix.php }} |
| 26 | + WP_ENV_CORE: ${{ matrix.wp == 'trunk' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wp ) }} |
19 | 27 |
|
20 | 28 | steps: |
21 | | - - name: Checkout |
22 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
23 | | - with: |
24 | | - fetch-depth: 0 |
25 | | - |
26 | | - - name: Get updated PHP files |
27 | | - id: changed-files |
28 | | - uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1 |
29 | | - with: |
30 | | - files: | |
31 | | - **/*.php |
32 | | - composer.json |
33 | | - composer.lock |
34 | | - phpunit.xml |
35 | | -
|
36 | | - - id: files-changed |
| 29 | + - name: Configure environment variables |
37 | 30 | run: | |
38 | | - if [[ ( "${{ steps.changed-files.outputs.any_changed }}" == 'true' && "${{ github.event_name }}" == "pull_request" ) || "${{ github.event_name }}" == "push" ]]; then |
39 | | - echo "RSA_PHP_FILES_CHANGED=yes" >> $GITHUB_OUTPUT |
40 | | - fi |
| 31 | + echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" |
| 32 | + echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" |
41 | 33 |
|
42 | | - phpunit: |
43 | | - runs-on: ubuntu-latest |
44 | | - needs: check-diffs |
45 | | - if: needs.check-diffs.outputs.has_changed == 'yes' |
46 | | - |
47 | | - steps: |
48 | | - - name: Checkout |
49 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 34 | + - name: Checkout repository |
| 35 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 36 | + with: |
| 37 | + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} |
| 38 | + persist-credentials: false |
50 | 39 |
|
51 | | - - uses: getong/mariadb-action@d6d2ec41fd5588f369be4c9398ce77ee725ca9ea # v1.11 |
| 40 | + ## |
| 41 | + # This allows Composer dependencies to be installed using a single step. |
| 42 | + # |
| 43 | + # Since the tests are currently run within the Docker containers where the PHP version varies, |
| 44 | + # the same PHP version needs to be configured for the action runner machine so that the correct |
| 45 | + # dependency versions are installed and cached. |
| 46 | + ## |
| 47 | + - name: Set up PHP |
| 48 | + uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4 |
| 49 | + with: |
| 50 | + php-version: '${{ matrix.php }}' |
| 51 | + coverage: none |
52 | 52 |
|
53 | | - - name: Set PHP version |
54 | | - uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0 |
55 | | - with: |
56 | | - php-version: '7.4' |
57 | | - coverage: none |
58 | | - tools: composer:v2 |
| 53 | + - name: Install Composer dependencies |
| 54 | + uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1 |
59 | 55 |
|
60 | | - - name: Install dependencies |
61 | | - run: composer install |
| 56 | + - name: Setup Node |
| 57 | + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 |
| 58 | + with: |
| 59 | + cache: 'npm' |
| 60 | + node-version-file: '.nvmrc' |
62 | 61 |
|
63 | | - - name: install node v16 |
64 | | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 |
65 | | - with: |
66 | | - node-version-file: '.nvmrc' |
| 62 | + - name: Install NPM dependencies |
| 63 | + run: npm ci && npm run build |
67 | 64 |
|
68 | | - - name: Install dependencies |
69 | | - run: npm i && npm run build |
| 65 | + - name: Start the Docker testing environment |
| 66 | + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 |
| 67 | + with: |
| 68 | + timeout_minutes: 10 |
| 69 | + max_attempts: 3 |
| 70 | + command: | |
| 71 | + npm run env:start |
70 | 72 |
|
71 | | - - name: Setup WP Tests |
72 | | - run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 |
| 73 | + - name: Log versions |
| 74 | + run: | |
| 75 | + npm run env -- run cli php -- -v |
| 76 | + npm run env -- run cli wp core version |
73 | 77 |
|
74 | | - - name: PHPUnit |
75 | | - run: './vendor/bin/phpunit' |
| 78 | + - name: Run PHPUnit tests |
| 79 | + id: phpunit |
| 80 | + run: | |
| 81 | + npm run test:php |
0 commit comments