Skip to content

Commit 0ee9f30

Browse files
committed
Build/Test Tools: Run the full PHPUnit matrix by label.
Allow reviewers to trigger the weekly PHP and database matrix on eligible pull requests by adding the Full PHPUnit Matrix label. Keep full coverage on subsequent commits while the label remains. Use a separate label-triggered workflow so unrelated labels do not replace PHPUnit checks or cancel active runs. Preserve the existing path filters and document the manual request process for contributors without label access. Developed in: #13448 Props lucatume, adrianmoldovanwp. Fixes #66071. git-svn-id: https://develop.svn.wordpress.org/trunk@63585 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 43e329d commit 0ee9f30

3 files changed

Lines changed: 108 additions & 12 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: PHPUnit Tests (label)
2+
run-name: PHPUnit Tests${{ github.event.label.name == 'Full PHPUnit Matrix' && ' (full matrix)' || ' (ignored label)' }}
3+
4+
on:
5+
pull_request:
6+
types: [ labeled ]
7+
branches:
8+
- trunk
9+
- '3.[7-9]'
10+
- '[4-9].[0-9]'
11+
# Keep these paths in sync with phpunit-tests.yml.
12+
paths:
13+
- '**'
14+
# Documentation and repository metadata.
15+
- '!**.md'
16+
- '!.devcontainer/**'
17+
- '!.editorconfig'
18+
- '!.git-blame-ignore-revs'
19+
- '!.gitignore'
20+
- '!.mailmap'
21+
- '!typings/**'
22+
# Configuration for unrelated checks.
23+
- '!.eslintrc-jsdoc.js'
24+
- '!.prettierrc.js'
25+
- '!.version-support-*.json'
26+
- '!eslint.config.js'
27+
- '!jsdoc.conf.json'
28+
- '!phpcompat.xml.dist'
29+
- '!phpcs.xml.dist'
30+
- '!phpstan.neon.dist'
31+
- '!tsconfig.json'
32+
# Other test suites, tools, and workflows do not affect these tests.
33+
- '!tests/**'
34+
- '!tools/**'
35+
- '!.github/**'
36+
# Re-include documentation, tests, tools, and workflows used here.
37+
- 'SECURITY.md'
38+
- 'src/license.txt'
39+
- 'tests/phpunit/**'
40+
- 'tools/gutenberg/**'
41+
- 'tools/local-env/**'
42+
- 'tools/vendors/**'
43+
- 'tools/webpack/**'
44+
- 'phpunit.xml.dist'
45+
- '.github/workflows/phpunit-tests.yml'
46+
- '.github/workflows/phpunit-tests-full-matrix.yml'
47+
- '.github/workflows/reusable-phpunit-tests-*.yml'
48+
- '.github/workflows/reusable-prepare-gutenberg.yml'
49+
50+
# Disable permissions for all available scopes by default.
51+
permissions: {}
52+
53+
# The called workflow manages concurrency. Unrelated labels never enter it.
54+
jobs:
55+
full-matrix:
56+
if: github.event.label.name == 'Full PHPUnit Matrix'
57+
permissions:
58+
# Required by the called workflow's recovery job, which is skipped on PR events.
59+
actions: write
60+
contents: read
61+
uses: ./.github/workflows/phpunit-tests.yml
62+
secrets:
63+
CODEVITALS_PROJECT_TOKEN: ${{ secrets.CODEVITALS_PROJECT_TOKEN }}
64+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
65+
WPT_REPORT_API_KEY: ${{ secrets.WPT_REPORT_API_KEY }}

‎.github/workflows/phpunit-tests.yml‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: PHPUnit Tests
2+
run-name: PHPUnit Tests${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && ' (full matrix)' || '' }}
23

34
on:
45
push:
@@ -11,6 +12,7 @@ on:
1112
- trunk
1213
- '3.[7-9]'
1314
- '[4-9].[0-9]'
15+
# Keep these paths in sync with phpunit-tests-full-matrix.yml.
1416
paths:
1517
- '**'
1618
# Documentation and repository metadata.
@@ -45,9 +47,26 @@ on:
4547
- 'tools/webpack/**'
4648
- 'phpunit.xml.dist'
4749
- '.github/workflows/phpunit-tests.yml'
50+
- '.github/workflows/phpunit-tests-full-matrix.yml'
4851
- '.github/workflows/reusable-phpunit-tests-*.yml'
4952
- '.github/workflows/reusable-prepare-gutenberg.yml'
5053
workflow_dispatch:
54+
workflow_call:
55+
secrets:
56+
CODEVITALS_PROJECT_TOKEN:
57+
required: false
58+
CODECOV_TOKEN:
59+
required: false
60+
WPT_REPORT_API_KEY:
61+
required: false
62+
SLACK_GHA_SUCCESS_WEBHOOK:
63+
required: false
64+
SLACK_GHA_CANCELLED_WEBHOOK:
65+
required: false
66+
SLACK_GHA_FIXED_WEBHOOK:
67+
required: false
68+
SLACK_GHA_FAILURE_WEBHOOK:
69+
required: false
5170
# Once weekly On Sundays at 00:00 UTC.
5271
schedule:
5372
- cron: '0 0 * * 0'
@@ -110,11 +129,11 @@ jobs:
110129
fail-fast: false
111130
matrix:
112131
os: [ ubuntu-24.04 ]
113-
# The scheduled run tests every supported PHP version. Other events test the highest and lowest of each major.
114-
php: ${{ github.event_name == 'schedule' && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
132+
# Scheduled and labeled runs test every supported PHP version. Other runs test the highest and lowest of each major.
133+
php: ${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
115134
db-type: [ 'mysql' ]
116-
# The scheduled run tests the full database matrix. Other events retain MySQL 5.7 compatibility and the widely used 8.x releases.
117-
db-version: ${{ github.event_name == 'schedule' && fromJSON('["5.7","8.0","8.4","9.7"]') || fromJSON('["5.7","8.0","8.4"]') }}
135+
# Scheduled and labeled runs test the full database matrix. Other runs retain MySQL 5.7 compatibility and the widely used 8.x releases.
136+
db-version: ${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && fromJSON('["5.7","8.0","8.4","9.7"]') || fromJSON('["5.7","8.0","8.4"]') }}
118137
tests-domain: [ 'example.org' ]
119138
multisite: [ false, true ]
120139
memcached: [ false ]
@@ -174,8 +193,8 @@ jobs:
174193
#
175194
# Creates a PHPUnit test job for each PHP/MariaDB combination.
176195
#
177-
# The scheduled run tests all LTS versions of MariaDB supported by WordPress with greater than 1% usage according to
178-
# w.org/stats. The exceptions to this rule are the most recent LTS and version 5.5.
196+
# Scheduled and labeled runs test all LTS versions of MariaDB supported by WordPress with greater than 1% usage
197+
# according to w.org/stats. The exceptions to this rule are the most recent LTS and version 5.5.
179198
#
180199
# The 5.5 release was intended as a drop-in replacement for MySQL. Because the MySQL 5.5 Docker containers do not
181200
# work, this ensures some level of MySQL 5.5 testing.
@@ -203,11 +222,11 @@ jobs:
203222
fail-fast: false
204223
matrix:
205224
os: [ ubuntu-24.04 ]
206-
# The scheduled run tests every supported PHP version. Other events test the highest and lowest of each major.
207-
php: ${{ github.event_name == 'schedule' && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
225+
# Scheduled and labeled runs test every supported PHP version. Other runs test the highest and lowest of each major.
226+
php: ${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
208227
db-type: [ 'mariadb' ]
209-
# The scheduled run tests the full database matrix. Other events retain MariaDB 5.5 compatibility, 10.6, and newer LTS releases.
210-
db-version: ${{ github.event_name == 'schedule' && fromJSON('["5.5","10.3","10.5","10.6","10.11","11.4","11.8"]') || fromJSON('["5.5","10.6","10.11","11.4","11.8"]') }}
228+
# Scheduled and labeled runs test the full database matrix. Other runs retain MariaDB 5.5 compatibility, 10.6, and newer LTS releases.
229+
db-version: ${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && fromJSON('["5.5","10.3","10.5","10.6","10.11","11.4","11.8"]') || fromJSON('["5.5","10.6","10.11","11.4","11.8"]') }}
211230
multisite: [ false, true ]
212231
memcached: [ false ]
213232

@@ -271,8 +290,8 @@ jobs:
271290
fail-fast: false
272291
matrix:
273292
os: [ ubuntu-24.04 ]
274-
# The scheduled run tests every supported PHP version. Other events test the highest and lowest of each major.
275-
php: ${{ github.event_name == 'schedule' && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
293+
# Scheduled and labeled runs test every supported PHP version. Other runs test the highest and lowest of each major.
294+
php: ${{ ( github.event_name == 'schedule' || ( github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'Full PHPUnit Matrix' ) ) ) && fromJSON('["7.4","8.0","8.1","8.2","8.3","8.4","8.5"]') || fromJSON('["7.4","8.0","8.5"]') }}
276295
db-type: [ 'mysql', 'mariadb' ]
277296
db-version: [ '12.1' ]
278297
multisite: [ false, true ]

‎tests/phpunit/README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@ PHPUnit is the official testing framework chosen by the core team to test PHP co
55
For more information, please review the relevant Core Handbook pages:
66
- [PHP: PHPUnit](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/)
77
- [Writing PHP Tests](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/)
8+
9+
## Run the full matrix on a pull request
10+
11+
Add the `Full PHPUnit Matrix` label to a pull request in `WordPress/wordpress-develop` to run the same PHP and database combinations as the weekly scheduled run. The label-triggered workflow uses the same path filters as normal PHPUnit runs.
12+
13+
If you cannot apply labels, leave a PR comment asking a reviewer with triage access to add it. Fork PRs follow GitHub's usual workflow approval requirements.
14+
15+
Adding the label starts a separate run without another code push. An existing reduced-matrix run continues alongside it; its checks and results are preserved. New commits run the full matrix while the label remains. Remove and reapply it to request another run for the current revision, or remove it to return subsequent runs to the reduced matrix.
16+
17+
Unrelated labels skip only the label-triggered workflow's `full-matrix` job and do not replace or cancel PHPUnit checks.
18+
19+
Look for `PHPUnit Tests (full matrix)` in GitHub Actions and the PHPUnit checks on the PR. Each run tests the PR's merge commit and retains its own logs and results, so check the revision before relying on an older run.

0 commit comments

Comments
 (0)