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