Skip to content

Commit d836928

Browse files
committed
Build/Test Tools: Spawn fewer jobs in GitHub Actions on forks.
The GitHub Actions workflows currently limit when jobs run for forks by short-circuiting any that are triggered by `push` events when not running within the `wordpress-develop` repository. Because the large majority of forks are not created under organizations, they will be subject to the individual account limit of 20 concurrent jobs (40 for pro accounts) at any given time instead of the 500 concurrent job limit that applies to the WordPress organization. This means that a single pull request back to a fork can take several hours to complete the workflow jobs that are spawned. This revises the conditional statements to further limit the number of jobs that spawn within a fork while still allowing the full test matrices for forks within the `WordPress` organization and pull requests back to `wordpress-develop`. These adjustments result in a maximum of 53 jobs when all workflows configured to run within forks are triggered. Of these, ~66% will run in less than 3 minutes, and ~55% will run in less than 1 minute. Props jorbin, johnbillion. Fixes #63752. git-svn-id: https://develop.svn.wordpress.org/trunk@60534 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 3479f1f commit d836928

7 files changed

+125
-33
lines changed

.github/workflows/install-testing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
permissions:
4848
contents: read
4949
secrets: inherit
50-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
50+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
5151
with:
5252
wp-version: ${{ inputs.wp-version }}
5353

@@ -63,7 +63,7 @@ jobs:
6363
permissions:
6464
contents: read
6565
runs-on: ${{ matrix.os }}
66-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
66+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
6767
timeout-minutes: 10
6868
needs: [ build-test-matrix ]
6969
strategy:

.github/workflows/local-docker-environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
permissions:
7474
contents: read
7575
secrets: inherit
76-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
76+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
7777
with:
7878
wp-version: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}
7979

.github/workflows/phpunit-tests.yml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
permissions:
6464
contents: read
6565
secrets: inherit
66-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
66+
if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
6767
strategy:
6868
fail-fast: false
6969
matrix:
@@ -140,7 +140,7 @@ jobs:
140140
permissions:
141141
contents: read
142142
secrets: inherit
143-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
143+
if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
144144
strategy:
145145
fail-fast: false
146146
matrix:
@@ -192,7 +192,7 @@ jobs:
192192
permissions:
193193
contents: read
194194
secrets: inherit
195-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
195+
if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
196196
strategy:
197197
fail-fast: false
198198
matrix:
@@ -232,7 +232,7 @@ jobs:
232232
permissions:
233233
contents: read
234234
secrets: inherit
235-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
235+
if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
236236
strategy:
237237
fail-fast: false
238238
matrix:
@@ -246,13 +246,71 @@ jobs:
246246
db-version: ${{ matrix.db-version }}
247247
phpunit-test-groups: ${{ matrix.phpunit-test-groups }}
248248

249+
#
250+
# Runs unit tests for forks.
251+
#
252+
# Because the majority of forks will belong to personal GitHub accounts (which are limited to just 20 concurrent jobs
253+
# at any given time), forks only run a small subset of test combinations. This allows contributors to open pull
254+
# requests back to their own forks for testing purposes without having to wait hours for workflow to complete.
255+
#
256+
limited-matrix-for-forks:
257+
name: PHP ${{ matrix.php }}
258+
uses: ./.github/workflows/reusable-phpunit-tests-v3.yml
259+
permissions:
260+
contents: read
261+
secrets: inherit
262+
if: ${{ ! startsWith( github.repository, 'WordPress/' ) && github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
263+
strategy:
264+
fail-fast: false
265+
matrix:
266+
php: [ '7.2', '8.4' ]
267+
db-version: [ '8.4', '11.8' ]
268+
db-type: [ 'mysql', 'mariadb' ]
269+
multisite: [ false ]
270+
271+
include:
272+
# Include one multisite job for each database type.
273+
- php: '8.4'
274+
db-version: '8.4'
275+
db-type: 'mysql'
276+
multisite: true
277+
- php: '8.4'
278+
db-version: '11.8'
279+
db-type: 'mariadb'
280+
multisite: true
281+
# Test with memcached.
282+
- php: '8.4'
283+
db-version: '8.4'
284+
db-type: 'mysql'
285+
multisite: true
286+
memcached: true
287+
# Run specific test groups once.
288+
- php: '8.4'
289+
db-version: '8.4'
290+
db-type: 'mysql'
291+
phpunit-test-groups: 'html-api-html5lib-tests'
292+
293+
exclude:
294+
# Exclude PHP versions that are not supported by the database versions.
295+
- db-type: 'mysql'
296+
db-version: '11.8'
297+
- db-type: 'mariadb'
298+
db-version: '8.4'
299+
300+
with:
301+
php: ${{ matrix.php }}
302+
db-version: ${{ matrix.db-version }}
303+
db-type: ${{ matrix.db-type }}
304+
memcached: ${{ matrix.memcached || false }}
305+
phpunit-test-groups: ${{ matrix.phpunit-test-groups || '' }}
306+
249307
slack-notifications:
250308
name: Slack Notifications
251309
uses: ./.github/workflows/slack-notifications.yml
252310
permissions:
253311
actions: read
254312
contents: read
255-
needs: [ test-with-mysql, test-with-mariadb, test-innovation-releases, specific-test-groups ]
313+
needs: [ test-with-mysql, test-with-mariadb, test-innovation-releases, specific-test-groups, limited-matrix-for-forks ]
256314
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
257315
with:
258316
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}

.github/workflows/test-and-zip-default-themes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189
contents: read
190190
needs: [ check-for-empty-files, test-build-scripts ]
191191
timeout-minutes: 10
192-
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
192+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
193193
strategy:
194194
fail-fast: false
195195
matrix:

.github/workflows/test-build-processes.yml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ concurrency:
4545
permissions: {}
4646

4747
jobs:
48-
# Tests the WordPress Core build process on multiple operating systems.
48+
# Tests the WordPress Core build process.
4949
test-core-build-process:
5050
name: Core running from ${{ matrix.directory }}
5151
uses: ./.github/workflows/reusable-test-core-build-process.yml
@@ -55,30 +55,31 @@ jobs:
5555
strategy:
5656
fail-fast: false
5757
matrix:
58-
os: [ ubuntu-24.04, windows-2022 ]
58+
os: [ 'ubuntu-24.04' ]
5959
directory: [ 'src', 'build' ]
6060
include:
6161
# Only prepare artifacts for Playground once.
62-
- os: ubuntu-24.04
62+
- os: 'ubuntu-24.04'
6363
directory: 'build'
6464
save-build: true
6565
prepare-playground: ${{ github.event_name == 'pull_request' && true || '' }}
66-
6766
with:
6867
os: ${{ matrix.os }}
6968
directory: ${{ matrix.directory }}
7069
save-build: ${{ matrix.save-build && matrix.save-build || false }}
7170
prepare-playground: ${{ matrix.prepare-playground && matrix.prepare-playground || false }}
7271

73-
# Tests the WordPress Core build process on MacOS.
72+
# Tests the WordPress Core build process on additional operating systems.
7473
#
75-
# This is separate from the job above in order to use stricter conditions when determining when to run.
76-
# This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
74+
# This is separate from the job above in order to use stricter conditions when determining when to test additional
75+
# operating systems. This avoids unintentionally consuming excessive minutes. Windows-based jobs consume minutes at a
76+
# 2x rate, and MacOS-based jobs at a 10x rate.
77+
# See https://docs.github.com/en/billing/concepts/product-billing/github-actions#per-minute-rates.
7778
#
7879
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
7980
# currently no way to determine the OS being used on a given job.
8081
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
81-
test-core-build-process-macos:
82+
test-core-build-process-additional-os:
8283
name: Core running from ${{ matrix.directory }}
8384
uses: ./.github/workflows/reusable-test-core-build-process.yml
8485
permissions:
@@ -87,37 +88,39 @@ jobs:
8788
strategy:
8889
fail-fast: false
8990
matrix:
90-
os: [ macos-14 ]
91+
os: [ 'macos-14', 'windows-2022' ]
9192
directory: [ 'src', 'build' ]
9293
with:
9394
os: ${{ matrix.os }}
9495
directory: ${{ matrix.directory }}
9596

96-
# Tests the Gutenberg plugin build process on multiple operating systems when run within a wordpress-develop checkout.
97+
# Tests the Gutenberg plugin build process within a wordpress-develop checkout.
9798
test-gutenberg-build-process:
9899
name: Gutenberg running from ${{ matrix.directory }}
99100
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
100101
permissions:
101102
contents: read
102-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
103+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
103104
strategy:
104105
fail-fast: false
105106
matrix:
106-
os: [ ubuntu-24.04, windows-2022 ]
107+
os: [ 'ubuntu-24.04' ]
107108
directory: [ 'src', 'build' ]
108109
with:
109110
os: ${{ matrix.os }}
110111
directory: ${{ matrix.directory }}
111112

112-
# Tests the Gutenberg plugin build process on MacOS when run within a wordpress-develop checkout.
113+
# Tests the Gutenberg plugin build process on additional operating systems.
113114
#
114-
# This is separate from the job above in order to use stricter conditions when determining when to run.
115-
# This avoids unintentionally consuming excessive minutes, as MacOS jobs consume minutes at a 10x rate.
115+
# This is separate from the job above in order to use stricter conditions when determining when to test additional
116+
# operating systems. This avoids unintentionally consuming excessive minutes. Windows-based jobs consume minutes at a
117+
# 2x rate, and MacOS-based jobs at a 10x rate.
118+
# See https://docs.github.com/en/billing/concepts/product-billing/github-actions#per-minute-rates.
116119
#
117120
# The `matrix` and `runner` contexts are not available for use within `if` expressions. So there is
118121
# currently no way to determine the OS being used on a given job.
119122
# See https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability.
120-
test-gutenberg-build-process-macos:
123+
test-gutenberg-build-process-additional-os:
121124
name: Gutenberg running from ${{ matrix.directory }}
122125
uses: ./.github/workflows/reusable-test-gutenberg-build-process.yml
123126
permissions:
@@ -126,7 +129,7 @@ jobs:
126129
strategy:
127130
fail-fast: false
128131
matrix:
129-
os: [ macos-14 ]
132+
os: [ 'macos-14', 'windows-2022' ]
130133
directory: [ 'src', 'build' ]
131134
with:
132135
os: ${{ matrix.os }}
@@ -138,7 +141,7 @@ jobs:
138141
permissions:
139142
actions: read
140143
contents: read
141-
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
144+
needs: [ test-core-build-process, test-core-build-process-additional-os, test-gutenberg-build-process, test-gutenberg-build-process-additional-os ]
142145
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
143146
with:
144147
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}

.github/workflows/upgrade-develop-testing.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ jobs:
4747
build:
4848
name: Build
4949
uses: ./.github/workflows/reusable-build-package.yml
50+
if: ${{ startsWith( github.repository, 'WordPress/' ) && ( github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) ) }}
5051
permissions:
5152
contents: read
5253

5354
# Run upgrade tests for the current branch.
5455
upgrade-tests-develop:
5556
name: Upgrade from ${{ matrix.wp }}
5657
uses: ./.github/workflows/reusable-upgrade-testing.yml
57-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
58+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
5859
needs: [ build ]
5960
strategy:
6061
fail-fast: false
@@ -83,6 +84,36 @@ jobs:
8384
new-version: develop
8485
multisite: ${{ matrix.multisite }}
8586

87+
# Run a limited set of upgrade tests for the current branch on forks.
88+
upgrade-tests-develop-forks:
89+
name: Upgrade from ${{ matrix.wp }}
90+
uses: ./.github/workflows/reusable-upgrade-testing.yml
91+
if: ${{ github.repository != 'WordPress/wordpress-develop' }}
92+
needs: [ build ]
93+
strategy:
94+
fail-fast: false
95+
matrix:
96+
os: [ 'ubuntu-24.04' ]
97+
php: [ '7.2', '8.4' ]
98+
db-type: [ 'mysql' ]
99+
db-version: [ '8.4' ]
100+
# WordPress 4.9 is the oldest version that supports PHP 7.2.
101+
wp: [ '6.7', '6.8' ]
102+
multisite: [ false, true ]
103+
104+
exclude:
105+
# The PHP <= 7.3/MySQL 8.4 jobs currently fail due to mysql_native_password being disabled by default. See https://core.trac.wordpress.org/ticket/61218.
106+
- php: '7.2'
107+
db-version: '8.4'
108+
with:
109+
os: ${{ matrix.os }}
110+
php: ${{ matrix.php }}
111+
db-type: ${{ matrix.db-type }}
112+
db-version: ${{ matrix.db-version }}
113+
wp: ${{ matrix.wp }}
114+
new-version: develop
115+
multisite: ${{ matrix.multisite }}
116+
86117
slack-notifications:
87118
name: Slack Notifications
88119
uses: ./.github/workflows/slack-notifications.yml

.github/workflows/upgrade-testing.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
upgrade-tests-recent-releases:
5959
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
6060
uses: ./.github/workflows/reusable-upgrade-testing.yml
61-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
61+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
6262
strategy:
6363
fail-fast: false
6464
matrix:
@@ -93,7 +93,7 @@ jobs:
9393
upgrade-tests-wp-6x-mysql:
9494
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
9595
uses: ./.github/workflows/reusable-upgrade-testing.yml
96-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
96+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
9797
strategy:
9898
fail-fast: false
9999
matrix:
@@ -121,7 +121,7 @@ jobs:
121121
upgrade-tests-wp-5x-php-7x-mysql:
122122
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
123123
uses: ./.github/workflows/reusable-upgrade-testing.yml
124-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
124+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
125125
strategy:
126126
fail-fast: false
127127
matrix:
@@ -153,7 +153,7 @@ jobs:
153153
upgrade-tests-wp-5x-php-8x-mysql:
154154
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
155155
uses: ./.github/workflows/reusable-upgrade-testing.yml
156-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
156+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
157157
strategy:
158158
fail-fast: false
159159
matrix:
@@ -181,7 +181,7 @@ jobs:
181181
upgrade-tests-oldest-wp-mysql:
182182
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
183183
uses: ./.github/workflows/reusable-upgrade-testing.yml
184-
if: ${{ github.repository == 'WordPress/wordpress-develop' || ( github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' ) }}
184+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
185185
strategy:
186186
fail-fast: false
187187
matrix:

0 commit comments

Comments
 (0)