Skip to content

Commit 24a2eac

Browse files
committed
Build/Test Tools: Add a workflow that tests the process of upgrading WordPress to a build of the current branch.
This complements the existing workflow which tests upgrading to an already released version. Props johnbillion, peterwilsoncc, mukesh27, desrosj, audrasjb, joemcgill. See #62221 git-svn-id: https://develop.svn.wordpress.org/trunk@59815 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ac2eeb9 commit 24a2eac

File tree

3 files changed

+222
-1
lines changed

3 files changed

+222
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
##
2+
# A reusable workflow that builds and packages WordPress. The resulting package can be used to test upgrading and installing.
3+
##
4+
name: Build and package WordPress
5+
6+
on:
7+
workflow_call:
8+
9+
# Disable permissions for all available scopes by default.
10+
# Any needed permissions should be configured at the job level.
11+
permissions: {}
12+
13+
jobs:
14+
# Builds and packages WordPress.
15+
#
16+
# Performs the following steps:
17+
# - Checks out the repository.
18+
# - Sets up Node.js.
19+
# - Runs the build script.
20+
# - Prepares the directory structure for the ZIP.
21+
# - Creates a ZIP of the built files.
22+
# - Uploads the ZIP as a GitHub Actions artifact.
23+
build:
24+
name: WordPress
25+
permissions:
26+
contents: read
27+
runs-on: ubuntu-24.04
28+
timeout-minutes: 20
29+
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
with:
34+
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
35+
persist-credentials: false
36+
37+
- name: Set up Node.js
38+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
39+
with:
40+
node-version-file: '.nvmrc'
41+
cache: npm
42+
43+
- name: Install npm Dependencies
44+
run: npm ci
45+
46+
- name: Build WordPress
47+
run: npm run build
48+
49+
- name: Prepare the directory structure for the ZIP
50+
run: mv build wordpress
51+
52+
- name: Create ZIP of built files
53+
run: zip -q -r develop.zip wordpress/.
54+
55+
- name: Upload ZIP as a GitHub Actions artifact
56+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
57+
with:
58+
name: wordpress-develop
59+
path: develop.zip
60+
if-no-files-found: error

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
required: true
1515
type: 'string'
1616
new-version:
17-
description: 'The version of WordPress to update to.'
17+
description: 'The version of WordPress to update to. Use "latest" to update to the latest version, "develop" to update to the current branch, or provide a specific version number to update to.'
1818
type: 'string'
1919
default: 'latest'
2020
php:
@@ -49,8 +49,13 @@ jobs:
4949
# - Downloads the specified version of WordPress.
5050
# - Creates a `wp-config.php` file.
5151
# - Installs WordPress.
52+
# - Checks the version of WordPress before the upgrade.
5253
# - Updates to the latest minor version.
54+
# - Updates the database after the minor update.
55+
# - Checks the version of WordPress after the minor update.
5356
# - Updates to the version of WordPress being tested.
57+
# - Updates the database.
58+
# - Checks the version of WordPress after the upgrade.
5459
upgrade-tests:
5560
name: ${{ inputs.wp }} to ${{ inputs.new-version }} / PHP ${{ inputs.php }} with ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}
5661
permissions: {}
@@ -96,11 +101,38 @@ jobs:
96101
--url=http://localhost/ --title="Upgrade Test" --admin_user=admin \
97102
--admin_password=password [email protected] --skip-email
98103
104+
- name: Pre-upgrade version check
105+
run: wp core version
106+
99107
- name: Update to the latest minor version
100108
run: wp core update --minor
101109

110+
- name: Update the database after the minor update
111+
run: wp core update-db ${{ inputs.multisite && '--network' || '' }}
112+
113+
- name: Post-upgrade version check after the minor update
114+
run: wp core version
115+
116+
- name: Download build artifact for the current branch
117+
if: ${{ inputs.new-version == 'develop' }}
118+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
119+
with:
120+
name: wordpress-develop
121+
122+
- name: Upgrade to WordPress at current branch
123+
if: ${{ inputs.new-version == 'develop' }}
124+
run: |
125+
wp core update develop.zip
126+
102127
- name: Upgrade to WordPress ${{ inputs.new-version }}
128+
if: ${{ inputs.new-version != 'develop' }}
103129
run: |
104130
wp core update ${{ 'latest' != inputs.new-version && '--version="${WP_VERSION}"' || '' }}
105131
env:
106132
WP_VERSION: ${{ inputs.new-version }}
133+
134+
- name: Update the database
135+
run: wp core update-db ${{ inputs.multisite && '--network' || '' }}
136+
137+
- name: Post-upgrade version check
138+
run: wp core version
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Confirms that updating WordPress using WP-CLI works successfully.
2+
#
3+
# This workflow tests upgrading from a previous version to the current wordpress-develop checkout, not to a version available on WordPress.org.
4+
name: Upgrade Develop Version Tests
5+
6+
on:
7+
push:
8+
branches:
9+
- trunk
10+
- '6.[8-9]'
11+
- '[7-9].[0-9]'
12+
tags:
13+
- '[0-9]+.[0-9]'
14+
- '[0-9]+.[0-9].[0-9]+'
15+
paths:
16+
# Any change to a source PHP file should run checks.
17+
- 'src/**.php'
18+
# Confirm any changes to relevant workflow files.
19+
- '.github/workflows/upgrade-develop-testing.yml'
20+
- '.github/workflows/reusable-upgrade-testing.yml'
21+
pull_request:
22+
branches:
23+
- trunk
24+
- '6.[8-9]'
25+
- '[7-9].[0-9]'
26+
paths:
27+
# Any change to a source PHP file should run checks.
28+
- 'src/**.php'
29+
# Confirm any changes to relevant workflow files.
30+
- '.github/workflows/upgrade-develop-testing.yml'
31+
- '.github/workflows/reusable-upgrade-testing.yml'
32+
workflow_dispatch:
33+
34+
# Cancels all previous workflow runs for pull requests that have not completed.
35+
concurrency:
36+
# The concurrency group contains the workflow name and the branch name for pull requests
37+
# or the commit hash for any other events.
38+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
39+
cancel-in-progress: true
40+
41+
# Disable permissions for all available scopes by default.
42+
# Any needed permissions should be configured at the job level.
43+
permissions: {}
44+
45+
jobs:
46+
# Build WordPress from the current branch ready for the upgrade tests.
47+
build:
48+
name: Build
49+
uses: ./.github/workflows/reusable-build-package.yml
50+
permissions:
51+
contents: read
52+
53+
# Run upgrade tests for the current branch.
54+
upgrade-tests-develop:
55+
name: Upgrade from ${{ matrix.wp }}
56+
uses: ./.github/workflows/reusable-upgrade-testing.yml
57+
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
58+
needs: [ build ]
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
os: [ 'ubuntu-24.04' ]
63+
php: [ '7.2', '8.4' ]
64+
db-type: [ 'mysql' ]
65+
db-version: [ '5.7', '8.4' ]
66+
wp: [ '6.5', '6.6', '6.7' ]
67+
multisite: [ false, true ]
68+
69+
exclude:
70+
# 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.
71+
- php: '7.2'
72+
db-version: '8.4'
73+
with:
74+
os: ${{ matrix.os }}
75+
php: ${{ matrix.php }}
76+
db-type: ${{ matrix.db-type }}
77+
db-version: ${{ matrix.db-version }}
78+
wp: ${{ matrix.wp }}
79+
new-version: develop
80+
multisite: ${{ matrix.multisite }}
81+
82+
slack-notifications:
83+
name: Slack Notifications
84+
uses: ./.github/workflows/slack-notifications.yml
85+
permissions:
86+
actions: read
87+
contents: read
88+
needs: [ upgrade-tests-develop ]
89+
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
90+
with:
91+
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
92+
secrets:
93+
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
94+
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
95+
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
96+
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}
97+
98+
failed-workflow:
99+
name: Failed workflow tasks
100+
runs-on: ubuntu-24.04
101+
permissions:
102+
actions: write
103+
needs: [ slack-notifications ]
104+
if: |
105+
always() &&
106+
github.repository == 'WordPress/wordpress-develop' &&
107+
github.event_name != 'pull_request' &&
108+
github.run_attempt < 2 &&
109+
(
110+
contains( needs.*.result, 'cancelled' ) ||
111+
contains( needs.*.result, 'failure' )
112+
)
113+
114+
steps:
115+
- name: Dispatch workflow run
116+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
117+
with:
118+
retries: 2
119+
retry-exempt-status-codes: 418
120+
script: |
121+
github.rest.actions.createWorkflowDispatch({
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
workflow_id: 'failed-workflow.yml',
125+
ref: 'trunk',
126+
inputs: {
127+
run_id: `${context.runId}`,
128+
}
129+
});

0 commit comments

Comments
 (0)