Skip to content

Commit 3c5364c

Browse files
committed
Initial attempt at context aware upgrade testing.
1 parent b00c4ac commit 3c5364c

1 file changed

Lines changed: 187 additions & 8 deletions

File tree

.github/workflows/upgrade-testing.yml

Lines changed: 187 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@ on:
99
- trunk
1010
# Always test the workflow after it's updated.
1111
paths:
12+
- '.version-support-*.json'
1213
- '.github/workflows/upgrade-testing.yml'
1314
- '.github/workflows/reusable-upgrade-testing.yml'
15+
- '.github/workflows/reusable-support-json-reader-v1.yml'
1416
pull_request:
1517
# This workflow is only meant to run from trunk. Pull requests changing this file with different BASE branches should be ignored.
1618
branches:
1719
- trunk
1820
# Always test the workflow when changes are suggested.
1921
paths:
22+
- '.version-support-*.json'
2023
- '.github/workflows/upgrade-testing.yml'
2124
- '.github/workflows/reusable-upgrade-testing.yml'
25+
- '.github/workflows/reusable-support-json-reader-v1.yml'
2226
workflow_dispatch:
2327
inputs:
2428
new-version:
25-
description: 'The version to test installing. Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".'
29+
description: 'The version to test upgrading to. Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".'
2630
type: string
2731
default: 'latest'
2832

@@ -37,6 +41,10 @@ concurrency:
3741
# Any needed permissions should be configured at the job level.
3842
permissions: {}
3943

44+
env:
45+
CURRENTLY_SUPPORTED_BRANCH: '6.9'
46+
OLDEST_SECURITY_BRANCH: '4.7'
47+
4048
# Because the number of jobs spawned can quickly balloon out of control, the following methodology is applied when
4149
# building out the matrix below:
4250
#
@@ -57,11 +65,111 @@ permissions: {}
5765
# - 5.6.x Docker containers are available and work, but 5.6 only accounts for ~2.3% of installs as of 12/6/2024.defaults:
5866
# - 5.7.x accounts for ~20% of installs, so this is used below instead.
5967
jobs:
68+
# Determines whether an older branch is being tested.
69+
#
70+
# When an older version is specified, a reduced matrix tailored to that branch is run.
71+
determine-workflow-type:
72+
name: Determine workflow type
73+
runs-on: 'ubuntu-24.04'
74+
timeout-minutes: 5
75+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
76+
outputs:
77+
testing-old-branch: ${{ steps.old-branch-check.outputs.testing-old-branch }}
78+
steps:
79+
- name: Determine if an older branch is being tested
80+
id: old-branch-check
81+
env:
82+
NEW_VERSION: ${{ inputs.new-version }}
83+
CURRENTLY_SUPPORTED_BRANCH: ${{ env.CURRENTLY_SUPPORTED_BRANCH }}
84+
run: |
85+
case "$NEW_VERSION" in
86+
"" | "latest" | "nightly" | "$CURRENTLY_SUPPORTED_BRANCH" | "$CURRENTLY_SUPPORTED_BRANCH".*)
87+
echo "testing-old-branch=false" >> "$GITHUB_OUTPUT"
88+
;;
89+
*)
90+
echo "testing-old-branch=true" >> "$GITHUB_OUTPUT"
91+
;;
92+
esac
93+
94+
# Determines the PHP and database versions to test based on the WordPress version when testing old branches.
95+
build-test-matrix:
96+
name: Build Test Matrix
97+
uses: ./.github/workflows/reusable-support-json-reader-v1.yml
98+
permissions:
99+
contents: read
100+
secrets: inherit
101+
needs: [ determine-workflow-type ]
102+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch == 'true' }}
103+
with:
104+
wp-version: ${{ inputs.new-version }}
105+
106+
# Determines the list of WordPress versions to upgrade from when testing an older branch.
107+
#
108+
# Generates a JSON array of all branches from OLDEST_SECURITY_BRANCH up to, but not
109+
# including, the target branch. For example, when the target is 5.0, this produces
110+
# ["4.7", "4.8", "4.9"]. WordPress branches are versioned as X.Y, where Y increments
111+
# from 0 to 9 before X increments and Y resets to 0.
112+
#
113+
# Only runs when testing an older branch.
114+
determine-from-versions:
115+
name: Determine FROM WordPress versions
116+
runs-on: 'ubuntu-24.04'
117+
timeout-minutes: 5
118+
needs: [ determine-workflow-type, build-test-matrix ]
119+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
120+
outputs:
121+
from-versions: ${{ steps.from-versions.outputs.from-versions }}
122+
123+
steps:
124+
- name: Determine the FROM WordPress versions
125+
id: from-versions
126+
env:
127+
OLDEST_SECURITY_BRANCH: ${{ env.OLDEST_SECURITY_BRANCH }}
128+
MAJOR_WP_VERSION: ${{ needs.build-test-matrix.outputs.major-wp-version }}
129+
run: |
130+
OLDEST_MAJOR=$(echo "$OLDEST_SECURITY_BRANCH" | cut -d'.' -f1)
131+
OLDEST_MINOR=$(echo "$OLDEST_SECURITY_BRANCH" | cut -d'.' -f2)
132+
133+
# Converts the target branch key (e.g. "5-0") to X.Y format.
134+
TARGET=$(echo "$MAJOR_WP_VERSION" | tr '-' '.')
135+
TARGET_MAJOR=$(echo "$TARGET" | cut -d'.' -f1)
136+
TARGET_MINOR=$(echo "$TARGET" | cut -d'.' -f2)
137+
138+
# Build a JSON array of all branches from OLDEST_SECURITY_BRANCH up to, but not
139+
# including, the target branch. Y increments 0–9, then X increments and Y resets to 0.
140+
VERSIONS=""
141+
CURRENT_MAJOR=$OLDEST_MAJOR
142+
CURRENT_MINOR=$OLDEST_MINOR
143+
144+
while true; do
145+
if [ "$CURRENT_MAJOR" -gt "$TARGET_MAJOR" ] || \
146+
{ [ "$CURRENT_MAJOR" -eq "$TARGET_MAJOR" ] && [ "$CURRENT_MINOR" -ge "$TARGET_MINOR" ]; }; then
147+
break
148+
fi
149+
150+
if [ -n "$VERSIONS" ]; then
151+
VERSIONS="${VERSIONS},"
152+
fi
153+
VERSIONS="${VERSIONS}\"${CURRENT_MAJOR}.${CURRENT_MINOR}\""
154+
155+
if [ "$CURRENT_MINOR" -eq 9 ]; then
156+
CURRENT_MAJOR=$((CURRENT_MAJOR + 1))
157+
CURRENT_MINOR=0
158+
else
159+
CURRENT_MINOR=$((CURRENT_MINOR + 1))
160+
fi
161+
done
162+
163+
echo "from-versions=[${VERSIONS}]" >> "$GITHUB_OUTPUT"
164+
60165
# Tests the full list of PHP/MySQL combinations for the two most recent versions of WordPress.
166+
#
167+
# Only runs when testing the currently supported branch or latest/nightly.
61168
upgrade-tests-recent-releases:
62169
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
63170
uses: ./.github/workflows/reusable-upgrade-testing.yml
64-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
171+
needs: [ determine-workflow-type ]
172+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch != 'true' }}
65173
permissions:
66174
contents: read
67175
strategy:
@@ -83,10 +191,13 @@ jobs:
83191
multisite: ${{ matrix.multisite }}
84192

85193
# Tests 6.x releases where the WordPress database version changed on the oldest and newest supported versions of PHP 7 & 8.
194+
#
195+
# Only runs when testing the currently supported branch or latest/nightly.
86196
upgrade-tests-wp-6x-mysql:
87197
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
88198
uses: ./.github/workflows/reusable-upgrade-testing.yml
89-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
199+
needs: [ determine-workflow-type ]
200+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch != 'true' }}
90201
permissions:
91202
contents: read
92203
strategy:
@@ -108,10 +219,13 @@ jobs:
108219
multisite: ${{ matrix.multisite }}
109220

110221
# Tests 5.x releases where the WordPress database version changed on the only supported version of PHP 7.
222+
#
223+
# Only runs when testing the currently supported branch or latest/nightly.
111224
upgrade-tests-wp-5x-php-7x-mysql:
112225
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
113226
uses: ./.github/workflows/reusable-upgrade-testing.yml
114-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
227+
needs: [ determine-workflow-type ]
228+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch != 'true' }}
115229
permissions:
116230
contents: read
117231
strategy:
@@ -137,10 +251,13 @@ jobs:
137251
# WordPress 5.0-5.2 are excluded from PHP 8+ testing because of the following fatal errors:
138252
# - Use of __autoload().
139253
# - array/string offset with curly braces.
254+
#
255+
# Only runs when testing the currently supported branch or latest/nightly.
140256
upgrade-tests-wp-5x-php-8x-mysql:
141257
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
142258
uses: ./.github/workflows/reusable-upgrade-testing.yml
143-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
259+
needs: [ determine-workflow-type ]
260+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch != 'true' }}
144261
permissions:
145262
contents: read
146263
strategy:
@@ -167,10 +284,13 @@ jobs:
167284
# WordPress 4.7 is excluded from PHP 8+ testing because of the following fatal errors:
168285
# - Use of __autoload().
169286
# - array/string offset with curly braces.
287+
#
288+
# Only runs when testing the currently supported branch or latest/nightly.
170289
upgrade-tests-oldest-wp-mysql:
171290
name: ${{ matrix.wp }} to ${{ inputs.new-version && inputs.new-version || 'latest' }}
172291
uses: ./.github/workflows/reusable-upgrade-testing.yml
173-
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
292+
needs: [ determine-workflow-type ]
293+
if: ${{ needs.determine-workflow-type.outputs.testing-old-branch != 'true' }}
174294
permissions:
175295
contents: read
176296
strategy:
@@ -191,13 +311,72 @@ jobs:
191311
new-version: ${{ inputs.new-version && inputs.new-version || 'latest' }}
192312
multisite: ${{ matrix.multisite }}
193313

314+
# Tests an older WordPress branch against all PHP and database versions it supports, as
315+
# documented in the version support JSON files.
316+
#
317+
# Uses the X.Y initial release of the branch as the FROM version to test the within-branch
318+
# upgrade path. PHP and database versions unsupported by Docker are excluded, as are MySQL
319+
# innovation releases other than the most recent.
320+
#
321+
# Only runs when testing an older branch (i.e. new-version is not empty, 'latest', 'nightly',
322+
# or a version of the currently supported branch).
323+
upgrade-tests-older-branch-mysql:
324+
name: WP ${{ matrix.wp }} to ${{ inputs.new-version }} / PHP ${{ matrix.php }} / MySQL ${{ matrix.db-version }}${{ matrix.multisite && ' multisite' || '' }}
325+
uses: ./.github/workflows/reusable-upgrade-testing.yml
326+
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
327+
needs: [ build-test-matrix, determine-from-versions ]
328+
permissions:
329+
contents: read
330+
strategy:
331+
fail-fast: false
332+
matrix:
333+
os: [ 'ubuntu-24.04' ]
334+
php: ${{ fromJSON( needs.build-test-matrix.outputs.php-versions ) }}
335+
db-type: [ 'mysql' ]
336+
db-version: ${{ fromJSON( needs.build-test-matrix.outputs.mysql-versions ) }}
337+
wp: ${{ fromJSON( needs.determine-from-versions.outputs.from-versions ) }}
338+
multisite: [ false, true ]
339+
exclude:
340+
# There are no local WordPress Docker environment containers for PHP <= 5.3.
341+
- php: '5.2'
342+
- php: '5.3'
343+
# MySQL containers <= 5.5 do not exist or fail to start properly.
344+
- db-version: '5.0'
345+
- db-version: '5.1'
346+
- db-version: '5.5'
347+
# 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.
348+
- php: '7.2'
349+
db-version: '8.4'
350+
- php: '7.3'
351+
db-version: '8.4'
352+
# Only test the latest innovation release.
353+
- db-version: '9.0'
354+
- db-version: '9.1'
355+
- db-version: '9.2'
356+
- db-version: '9.3'
357+
- db-version: '9.4'
358+
- db-version: '9.5'
359+
# MySQL 9.0+ will not work on PHP 7.2 & 7.3. See https://core.trac.wordpress.org/ticket/61218.
360+
- php: '7.2'
361+
db-version: '9.6'
362+
- php: '7.3'
363+
db-version: '9.6'
364+
with:
365+
os: ${{ matrix.os }}
366+
php: ${{ matrix.php }}
367+
db-type: ${{ matrix.db-type }}
368+
db-version: ${{ matrix.db-version }}
369+
wp: ${{ matrix.wp }}
370+
new-version: ${{ inputs.new-version }}
371+
multisite: ${{ matrix.multisite }}
372+
194373
slack-notifications:
195374
name: Slack Notifications
196375
uses: ./.github/workflows/slack-notifications.yml
197376
permissions:
198377
actions: read
199378
contents: read
200-
needs: [ upgrade-tests-recent-releases, upgrade-tests-wp-6x-mysql, upgrade-tests-wp-5x-php-7x-mysql, upgrade-tests-wp-5x-php-8x-mysql, upgrade-tests-oldest-wp-mysql ]
379+
needs: [ upgrade-tests-recent-releases, upgrade-tests-wp-6x-mysql, upgrade-tests-wp-5x-php-7x-mysql, upgrade-tests-wp-5x-php-8x-mysql, upgrade-tests-oldest-wp-mysql, upgrade-tests-older-branch-mysql ]
201380
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
202381
with:
203382
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
@@ -209,7 +388,7 @@ jobs:
209388

210389
failed-workflow:
211390
name: Failed workflow tasks
212-
runs-on: ubuntu-24.04
391+
runs-on: 'ubuntu-24.04'
213392
permissions:
214393
actions: write
215394
needs: [ slack-notifications ]

0 commit comments

Comments
 (0)