Skip to content

Commit 5113377

Browse files
committed
Test on PHP 8.2
* Hugely simplify the workflow (no Docker) * Run against PHP 8.2 * Exclude the import tests which require the importer plugin for now.
1 parent 4ae6eb6 commit 5113377

File tree

3 files changed

+66
-194
lines changed

3 files changed

+66
-194
lines changed

.github/workflows/phpunit-tests.yml

Lines changed: 64 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ name: PHPUnit Tests
22

33
on:
44
push:
5-
branches:
6-
- trunk
7-
- '3.[7-9]'
8-
- '[4-9].[0-9]'
9-
tags:
10-
- '[0-9]+.[0-9]'
11-
- '[0-9]+.[0-9].[0-9]+'
5+
# branches:
6+
# - trunk
7+
# - '3.[7-9]'
8+
# - '[4-9].[0-9]'
9+
# tags:
10+
# - '[0-9]+.[0-9]'
11+
# - '[0-9]+.[0-9].[0-9]+'
1212
pull_request:
1313
branches:
1414
- trunk
@@ -57,221 +57,91 @@ jobs:
5757
# - Reconnect the directory to the Git repository.
5858
# - Submit the test results to the WordPress.org host test results.
5959
test-php:
60-
name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.split_slow && ' slow tests' || '' }}${{ matrix.memcached && ' with memcached' || '' }} on ${{ matrix.os }}
60+
name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ${{ matrix.os }}
6161
runs-on: ${{ matrix.os }}
6262
timeout-minutes: 20
63-
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
63+
# if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
6464
strategy:
6565
fail-fast: false
6666
matrix:
67-
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
67+
php: [ '8.1', '8.2' ]
6868
os: [ ubuntu-latest ]
69-
memcached: [ false ]
70-
split_slow: [ false ]
7169
multisite: [ false, true ]
70+
7271
include:
73-
# Additional "slow" jobs for PHP 5.6.
74-
- php: '5.6'
75-
os: ubuntu-latest
76-
memcached: false
77-
multisite: false
78-
split_slow: true
79-
- php: '5.6'
80-
os: ubuntu-latest
81-
memcached: false
82-
multisite: true
83-
split_slow: true
84-
# Include jobs for PHP 7.4 with memcached.
8572
- php: '7.4'
8673
os: ubuntu-latest
87-
memcached: true
8874
multisite: false
89-
- php: '7.4'
75+
- php: '5.6'
9076
os: ubuntu-latest
91-
memcached: true
9277
multisite: true
93-
# Report the results of the PHP 7.4 without memcached job.
94-
- php: '7.4'
95-
os: ubuntu-latest
96-
memcached: false
97-
multisite: false
98-
report: true
9978

10079
env:
101-
LOCAL_PHP: ${{ matrix.php }}-fpm
102-
LOCAL_PHP_MEMCACHED: ${{ matrix.memcached }}
10380
PHPUNIT_CONFIG: ${{ matrix.multisite && 'tests/phpunit/multisite.xml' || 'phpunit.xml.dist' }}
10481

105-
steps:
106-
- name: Configure environment variables
107-
run: |
108-
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
109-
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
82+
services:
83+
mysql:
84+
image: mysql:5.7
85+
env:
86+
MYSQL_ALLOW_EMPTY_PASSWORD: false
87+
MYSQL_DATABASE: wordpress_test
88+
ports:
89+
- 3306:3306
90+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
11091

92+
steps:
11193
- name: Checkout repository
11294
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
11395

114-
- name: Install NodeJS
115-
uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3.4.1
116-
with:
117-
node-version-file: '.nvmrc'
118-
cache: npm
119-
120-
- name: Install Dependencies
121-
run: npm ci
122-
123-
# This date is used to ensure that the Composer cache is refreshed at least once every week.
124-
# http://man7.org/linux/man-pages/man1/date.1.html
125-
- name: "Get last Monday's date"
126-
id: get-date
127-
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
128-
129-
- name: Get Composer cache directory
130-
id: composer-cache
131-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
132-
133-
- name: Cache Composer dependencies
134-
uses: actions/cache@fd5de65bc895cf536527842281bea11763fefd77 # v3.0.8
135-
env:
136-
cache-name: cache-composer-dependencies
96+
- name: Install PHP
97+
uses: shivammathur/setup-php@v2
13798
with:
138-
path: ${{ steps.composer-cache.outputs.dir }}
139-
key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }}
140-
141-
- name: Install Composer dependencies
142-
run: |
143-
docker-compose run --rm php composer --version
144-
145-
# Install using `composer update` as there is no `composer.lock` file.
146-
if [ ${{ env.LOCAL_PHP }} == '8.2-fpm' ]; then
147-
docker-compose run --rm php composer update --ignore-platform-req=php+
148-
else
149-
docker-compose run --rm php composer update
150-
fi
151-
152-
- name: Docker debug information
153-
run: |
154-
docker -v
155-
docker-compose -v
156-
157-
- name: Start Docker environment
158-
run: |
159-
npm run env:start
160-
161-
- name: General debug information
162-
run: |
163-
npm --version
164-
node --version
165-
curl --version
166-
git --version
167-
svn --version
168-
169-
- name: Log running Docker containers
170-
run: docker ps -a
171-
172-
- name: WordPress Docker container debug information
173-
run: |
174-
docker-compose run --rm mysql mysql --version
175-
docker-compose run --rm php php --version
176-
docker-compose run --rm php php -m
177-
docker-compose run --rm php php -i
178-
docker-compose run --rm php locale -a
179-
180-
- name: Install WordPress
181-
run: npm run env:install
182-
183-
- name: Run slow PHPUnit tests
184-
if: ${{ matrix.split_slow }}
185-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ${{ env.SLOW_TESTS }}
186-
187-
- name: Run PHPUnit tests for single site excluding slow tests
188-
if: ${{ matrix.php < '7.0' && ! matrix.split_slow && ! matrix.multisite }}
189-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-required
190-
191-
- name: Run PHPUnit tests for Multisite excluding slow tests
192-
if: ${{ matrix.php < '7.0' && ! matrix.split_slow && matrix.multisite }}
193-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --exclude-group ${{ env.SLOW_TESTS }},ajax,ms-files,ms-excluded,oembed-headers
194-
195-
- name: Run PHPUnit tests
196-
if: ${{ matrix.php >= '7.0' }}
197-
continue-on-error: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
198-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}
199-
200-
- name: Run AJAX tests
201-
if: ${{ ! matrix.split_slow }}
99+
php-version: ${{ matrix.php }}
100+
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
101+
coverage: none
102+
tools: phpunit-polyfills
103+
104+
- name: Ensure correct PHPUnit version is available
105+
if: ${{ matrix.php == '8.2' }}
106+
run: composer global update yoast/phpunit-polyfills --with-all-dependencies --ignore-platform-reqs
107+
108+
- run: cp wp-tests-config-sample.php wp-tests-config.php
109+
- run: sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
110+
- run: sed -i "s/yourusernamehere/root/" wp-tests-config.php
111+
- run: sed -i "s/yourpasswordhere//" wp-tests-config.php
112+
- run: sed -i "s/localhost/127.0.0.1:3306/" wp-tests-config.php
113+
114+
- name: Show PHPUnit version
115+
run: phpunit --version
116+
117+
- name: Run PHPUnit tests - single site
118+
continue-on-error: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
119+
if: ${{ matrix.multisite == false }}
120+
run: phpunit
121+
122+
- name: Run PHPUnit tests - multi site
123+
continue-on-error: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
124+
if: ${{ matrix.multisite == true }}
125+
run: phpunit -c tests/phpunit/multisite.xml
126+
127+
- name: Run AJAX tests - single site
128+
continue-on-error: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
129+
if: ${{ matrix.multisite == false }}
130+
run: phpunit --group ajax
131+
132+
- name: Run AJAX tests - multi site
202133
continue-on-error: ${{ matrix.php == '8.2' }}
203-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax
134+
if: ${{ matrix.multisite == true }}
135+
run: phpunit -c tests/phpunit/multisite.xml --group ajax
204136

205137
- name: Run ms-files tests as a multisite install
206-
if: ${{ matrix.multisite && ! matrix.split_slow }}
207138
continue-on-error: ${{ matrix.php == '8.2' }}
208-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c tests/phpunit/multisite.xml --group ms-files
139+
if: ${{ matrix.multisite }}
140+
run: phpunit -c tests/phpunit/multisite.xml --group ms-files
209141

210142
- name: Run external HTTP tests
211-
if: ${{ ! matrix.multisite && ! matrix.split_slow }}
212143
continue-on-error: ${{ matrix.php == '8.2' }}
213-
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c phpunit.xml.dist --group external-http
214-
215-
# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
216-
- name: Run (Xdebug) tests
217-
if: ${{ ! matrix.split_slow && matrix.php != '8.2' }}
218-
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__
219-
220-
- name: Ensure version-controlled files are not modified or deleted
221-
run: git diff --exit-code
222-
223-
- name: Checkout the WordPress Test Reporter
224-
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
225-
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
226-
with:
227-
repository: 'WordPress/phpunit-test-runner'
228-
path: 'test-runner'
229-
230-
- name: Submit test results to the WordPress.org host test results
231-
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.ref == 'refs/heads/trunk' && matrix.report }}
232-
env:
233-
WPT_REPORT_API_KEY: "${{ secrets.WPT_REPORT_API_KEY }}"
234-
run: docker-compose run --rm -e WPT_REPORT_API_KEY -e WPT_PREPARE_DIR=/var/www -e WPT_TEST_DIR=/var/www php php test-runner/report.php
235-
236-
slack-notifications:
237-
name: Slack Notifications
238-
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
239-
needs: [ test-php ]
240-
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
241-
with:
242-
calling_status: ${{ needs.test-php.result == 'success' && 'success' || needs.test-php.result == 'cancelled' && 'cancelled' || 'failure' }}
243-
secrets:
244-
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
245-
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
246-
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
247-
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
248-
249-
failed-workflow:
250-
name: Failed workflow tasks
251-
runs-on: ubuntu-latest
252-
needs: [ test-php, slack-notifications ]
253-
if: |
254-
always() &&
255-
github.repository == 'WordPress/wordpress-develop' &&
256-
github.event_name != 'pull_request' &&
257-
github.run_attempt < 2 &&
258-
(
259-
needs.test-php.result == 'cancelled' || needs.test-php.result == 'failure'
260-
)
261-
262-
steps:
263-
- name: Dispatch workflow run
264-
uses: actions/github-script@d4560e157075e2d93aa3022b5b51a42a880f1f93 # v6.3.0
265-
with:
144+
if: ${{ ! matrix.multisite }}
145+
run: phpunit --group external-http
266146
retries: 2
267147
retry-exempt-status-codes: 418
268-
script: |
269-
github.rest.actions.createWorkflowDispatch({
270-
owner: context.repo.owner,
271-
repo: context.repo.repo,
272-
workflow_id: 'failed-workflow.yml',
273-
ref: '${{ github.ref_name }}',
274-
inputs: {
275-
run_id: '${{ github.run_id }}'
276-
}
277-
});

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<group>ms-files</group>
2929
<group>ms-required</group>
3030
<group>external-http</group>
31+
<group>import</group>
3132
</exclude>
3233
</groups>
3334
<logging>

tests/phpunit/multisite.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<group>ms-excluded</group>
3434
<group>external-http</group>
3535
<group>oembed-headers</group>
36+
<group>import</group>
3637
</exclude>
3738
</groups>
3839
<filter>

0 commit comments

Comments
 (0)