|
1 | 1 | name: PHP Unit Tests |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - # Only run if PHP-related files changed. |
6 | | - paths: |
7 | | - - '**.php' |
8 | | - - 'phpunit.xml.dist' |
9 | | - - 'phpunit-multisite.xml.dist' |
10 | | - - 'composer.json' |
11 | | - - 'composer.lock' |
12 | | - - 'tests/**' |
13 | | - branches: |
14 | | - - master |
15 | | - - release/* |
16 | | - pull_request: |
17 | | - # Only run if PHP-related files changed. |
18 | | - paths: |
19 | | - - '**.php' |
20 | | - - 'phpunit.xml.dist' |
21 | | - - 'phpunit-multisite.xml.dist' |
22 | | - - 'composer.json' |
23 | | - - 'composer.lock' |
24 | | - - 'tests/**' |
25 | | - - '.github/workflows/tests-unit-php.yml' |
| 4 | + push: |
| 5 | + # Only run if PHP-related files changed. |
| 6 | + paths: |
| 7 | + - '**.php' |
| 8 | + - 'phpunit.xml.dist' |
| 9 | + - 'phpunit-multisite.xml.dist' |
| 10 | + - 'composer.json' |
| 11 | + - 'composer.lock' |
| 12 | + - 'tests/**' |
| 13 | + branches: |
| 14 | + - master |
| 15 | + - release/* |
| 16 | + pull_request: |
| 17 | + # Only run if PHP-related files changed. |
| 18 | + paths: |
| 19 | + - '**.php' |
| 20 | + - 'phpunit.xml.dist' |
| 21 | + - 'phpunit-multisite.xml.dist' |
| 22 | + - 'composer.json' |
| 23 | + - 'composer.lock' |
| 24 | + - 'tests/**' |
| 25 | + - '.github/workflows/tests-unit-php.yml' |
26 | 26 |
|
27 | 27 | jobs: |
28 | | - unit-php: |
29 | | - name: 'PHP ${{ matrix.php }} - WP ${{ matrix.wp }}' |
30 | | - runs-on: ubuntu-latest |
31 | | - timeout-minutes: 60 |
32 | | - services: |
33 | | - mysql: |
34 | | - image: mariadb:latest |
35 | | - env: |
36 | | - MYSQL_ALLOW_EMPTY_PASSWORD: true |
37 | | - MYSQL_ROOT_PASSWORD: |
38 | | - MYSQL_DATABASE: wordpress_test |
39 | | - ports: |
40 | | - - 3306 |
41 | | - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
42 | | - continue-on-error: ${{ matrix.experimental == true }} |
43 | | - strategy: |
44 | | - matrix: |
45 | | - php: ['7.0', '7.2', '7.4', '8.0', '8.1', '8.2'] |
46 | | - wp: ['latest'] |
47 | | - include: |
48 | | - - php: '7.4' |
49 | | - wp: 'trunk' |
50 | | - experimental: true |
| 28 | + unit-php: |
| 29 | + name: 'PHP ${{ matrix.php }} - WP ${{ matrix.wp }}' |
| 30 | + runs-on: ubuntu-latest |
| 31 | + timeout-minutes: 60 |
| 32 | + services: |
| 33 | + mysql: |
| 34 | + image: mariadb:latest |
| 35 | + env: |
| 36 | + MYSQL_ALLOW_EMPTY_PASSWORD: true |
| 37 | + MYSQL_ROOT_PASSWORD: |
| 38 | + MYSQL_DATABASE: wordpress_test |
| 39 | + ports: |
| 40 | + - 3306 |
| 41 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 42 | + continue-on-error: ${{ matrix.experimental == true }} |
| 43 | + strategy: |
| 44 | + matrix: |
| 45 | + php: ['7.0', '7.2', '7.4', '8.0'] |
| 46 | + wp: ['latest'] |
| 47 | + include: |
| 48 | + - php: '7.4' |
| 49 | + wp: 'trunk' |
| 50 | + experimental: true |
51 | 51 |
|
52 | | - steps: |
53 | | - - name: Checkout |
54 | | - uses: actions/checkout@v2 |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v2 |
55 | 55 |
|
56 | | - - name: Get Composer cache directory |
57 | | - id: composer-cache |
58 | | - run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 56 | + - name: Get Composer cache directory |
| 57 | + id: composer-cache |
| 58 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
59 | 59 |
|
60 | | - - name: Setup Composer cache |
61 | | - |
62 | | - with: |
63 | | - path: ${{ steps.composer-cache.outputs.dir }} |
64 | | - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
65 | | - restore-keys: | |
66 | | - ${{ runner.os }}-composer- |
67 | | - ${{ runner.os }}- |
| 60 | + - name: Setup Composer cache |
| 61 | + |
| 62 | + with: |
| 63 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 64 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-composer- |
| 67 | + ${{ runner.os }}- |
68 | 68 |
|
69 | | - # PHP-Scoper only works on PHP 7.2+ and we need to prefix our dependencies to accurately test them. |
70 | | - # So we temporarily switch PHP versions, do a full install and then remove the package. |
71 | | - # Then switch back to the PHP version we want to test and delete the vendor directory. |
| 69 | + - name: Setup PHP 8.0 |
| 70 | + uses: shivammathur/setup-php@d30ad8b1843ace22e6698ab99bbafaa747b6bd0d |
| 71 | + with: |
| 72 | + php-version: '8.0' |
| 73 | + tools: composer |
72 | 74 |
|
73 | | - - name: Setup PHP 7.4 |
74 | | - uses: shivammathur/setup-php@v2 |
75 | | - with: |
76 | | - php-version: 7.4 |
77 | | - tools: composer |
| 75 | + - name: Install prefixed dependencies |
| 76 | + run: | |
| 77 | + composer install --prefer-dist --no-suggest --no-progress --no-interaction |
| 78 | + rm -rf vendor/* |
78 | 79 |
|
79 | | - - name: Install prefixed dependencies |
80 | | - run: | |
81 | | - composer install --prefer-dist --no-suggest --no-progress --no-interaction |
82 | | - rm -rf vendor/* |
| 80 | + - name: Setup PHP |
| 81 | + uses: shivammathur/setup-php@v2 |
| 82 | + with: |
| 83 | + php-version: ${{ matrix.php }} |
| 84 | + extensions: mysql |
| 85 | + tools: composer, cs2pr |
83 | 86 |
|
84 | | - - name: Setup PHP |
85 | | - uses: shivammathur/setup-php@v2 |
86 | | - with: |
87 | | - php-version: ${{ matrix.php }} |
88 | | - extensions: mysql |
89 | | - tools: composer, cs2pr |
| 87 | + - name: Install dependencies |
| 88 | + run: | |
| 89 | + composer install --prefer-dist --no-suggest --no-progress --no-interaction --no-scripts |
| 90 | + composer dump-autoload --no-interaction |
90 | 91 |
|
91 | | - - name: Install dependencies |
92 | | - run: | |
93 | | - composer install --prefer-dist --no-suggest --no-progress --no-interaction --no-scripts |
94 | | - composer dump-autoload --no-interaction |
| 92 | + - name: Shutdown default MySQL service |
| 93 | + run: sudo service mysql stop |
95 | 94 |
|
96 | | - - name: Shutdown default MySQL service |
97 | | - run: sudo service mysql stop |
| 95 | + - name: Verify MariaDB connection |
| 96 | + run: | |
| 97 | + while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do |
| 98 | + sleep 1 |
| 99 | + done |
98 | 100 |
|
99 | | - - name: Verify MariaDB connection |
100 | | - run: | |
101 | | - while ! mysqladmin ping -h"127.0.0.1" -P"${{ job.services.mysql.ports[3306] }}" --silent; do |
102 | | - sleep 1 |
103 | | - done |
| 101 | + - name: Set up tests |
| 102 | + run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true |
104 | 103 |
|
105 | | - - name: Set up tests |
106 | | - run: bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1:${{ job.services.mysql.ports['3306'] }} ${{ matrix.wp }} true |
107 | | - |
108 | | - - name: Run tests |
109 | | - run: | |
110 | | - npm run test:php |
111 | | - npm run test:php:multisite |
| 104 | + - name: Run tests |
| 105 | + run: | |
| 106 | + npm run test:php |
| 107 | + npm run test:php:multisite |
0 commit comments