forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (122 loc) · 4.98 KB
/
reusable-upgrade-testing.yml
File metadata and controls
139 lines (122 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# A reusable workflow that runs WordPress upgrade testing under the conditions provided.
name: Upgrade Tests
on:
workflow_call:
inputs:
os:
description: 'Operating system to run tests on.'
required: false
type: 'string'
default: 'ubuntu-24.04'
wp:
description: 'The version of WordPress to start with.'
required: true
type: 'string'
new-version:
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.'
type: 'string'
default: 'latest'
php:
description: 'The version of PHP to use. Expected format: X.Y.'
required: true
type: 'string'
multisite:
description: 'Whether to run tests as multisite.'
required: false
type: 'boolean'
default: false
db-type:
description: 'Database type. Valid types are mysql and mariadb.'
required: false
type: 'string'
default: 'mysql'
db-version:
description: 'Database version.'
required: false
type: 'string'
default: '5.7'
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
# Runs upgrade tests on a build of WordPress.
#
# Performs the following steps:
# - Sets up PHP.
# - Downloads the specified version of WordPress.
# - Creates a `wp-config.php` file.
# - Installs WordPress.
# - Checks the version of WordPress before the upgrade.
# - Updates to the latest minor version.
# - Updates the database after the minor update.
# - Checks the version of WordPress after the minor update.
# - Updates to the version of WordPress being tested.
# - Updates the database.
# - Checks the version of WordPress after the upgrade.
upgrade-tests:
name: ${{ inputs.wp }} to ${{ inputs.new-version }} / PHP ${{ inputs.php }} with ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.multisite && ' multisite' || '' }}
permissions:
contents: read
runs-on: ${{ inputs.os }}
timeout-minutes: 20
services:
database:
image: ${{ inputs.db-type }}:${{ inputs.db-version }}
ports:
- 3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval="30s"
--health-timeout="10s"
--health-retries="5"
-e MYSQL_ROOT_PASSWORD="root"
-e MYSQL_DATABASE="test_db"
--entrypoint sh ${{ inputs.db-type }}:${{ inputs.db-version }}
-c "exec docker-entrypoint.sh mysqld${{ inputs.db-type == 'mysql' && contains( fromJSON('["7.2", "7.3"]'), inputs.php ) && ' --default-authentication-plugin=mysql_native_password' || '' }}"
steps:
- name: Set up PHP ${{ inputs.php }}
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2.32.0
with:
php-version: '${{ inputs.php }}'
coverage: none
tools: wp-cli
- name: Download WordPress ${{ inputs.wp }}
run: wp core download --version="${WP_VERSION}"
env:
WP_VERSION: ${{ inputs.wp }}
- name: Create wp-config.php file
run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost="127.0.0.1:${DB_PORT}"
env:
DB_PORT: ${{ job.services.database.ports['3306'] }}
- name: Install WordPress
run: |
wp core ${{ inputs.multisite && 'multisite-install' || 'install' }} \
--url=http://localhost/ --title="Upgrade Test" --admin_user=admin \
--admin_password=password --admin_email=me@example.org --skip-email
- name: Pre-upgrade version check
run: wp core version
- name: Update to the latest minor version
run: wp core update --minor
- name: Update the database after the minor update
run: wp core update-db ${{ inputs.multisite && '--network' || '' }}
- name: Post-upgrade version check after the minor update
run: wp core version
- name: Download build artifact for the current branch
if: ${{ inputs.new-version == 'develop' }}
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: wordpress-develop
- name: Upgrade to WordPress at current branch
if: ${{ inputs.new-version == 'develop' }}
run: |
wp core update develop.zip
- name: Upgrade to WordPress ${{ inputs.new-version }}
if: ${{ inputs.new-version != 'develop' }}
run: |
wp core update ${{ 'latest' != inputs.new-version && '--version="${WP_VERSION}"' || '' }}
env:
WP_VERSION: ${{ inputs.new-version }}
- name: Update the database
run: wp core update-db ${{ inputs.multisite && '--network' || '' }}
- name: Post-upgrade version check
run: wp core version