-
Notifications
You must be signed in to change notification settings - Fork 81
189 lines (171 loc) · 7.15 KB
/
test.yml
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Test
on:
# Run on all pushes for default branch and on all pull requests.
# Prevent the build from running when there are only irrelevant changes.
push:
branches:
- master
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Notes regarding supported versions in WP:
# The base matrix only contains the PHP versions which are supported on all supported WP versions.
php: ['7.2', '7.3']
wp: ['latest', '5.2']
experimental: [false]
include:
# Complement the builds run via the matrix with high/low WP builds for PHP 5.6 and PHP 7.4 up to 8.3.
# PHP 8.3 is beta-supported since WP 6.4.
- php: '8.3'
wp: 'latest'
experimental: false
- php: '8.3'
wp: '6.4'
experimental: false
# PHP 8.2 is beta-supported since WP 6.1 and Requests was updated in WP 6.2.
# That means that WP 6.2 is the earliest WP version which can be used with PHP 8.1 for this plugin.
- php: '8.2'
wp: 'latest'
experimental: false
- php: '8.2'
wp: '6.2'
experimental: false
# PHP 8.1 is beta-supported since WP 5.9 and Requests was updated in WP 6.2.
# That means that WP 6.2 is the earliest WP version which can be used with PHP 8.1 for this plugin.
- php: '8.1'
wp: 'latest'
experimental: false
- php: '8.1'
wp: '6.2'
experimental: false
# PHP 8.0 is beta-supported since WP 5.6.
- php: '8.0'
wp: 'latest'
experimental: false
- php: '8.0'
wp: '5.6'
experimental: false
# PHP 7.4 is supported since WP 5.3.
- php: '7.4'
wp: 'latest'
experimental: false
- php: '7.4'
wp: '5.4'
experimental: false
# PHP 5.6 was supported up to WP 6.2.
- php: '5.6'
wp: '6.2'
experimental: false
- php: '5.6'
wp: '5.2'
experimental: false
# PHP 7.0 was supported up to WP 6.5.
- php: '7.0'
wp: '5.2'
experimental: false
- php: '7.0'
wp: '6.5'
experimental: false
# PHP 7.1 was supported up to WP 6.5.
- php: '7.1'
wp: '5.2'
experimental: false
- php: '7.1'
wp: '6.5'
experimental: false
# Complement the builds run via the matrix with some additional builds against specific WP versions.
- php: '7.3'
wp: '6.0'
experimental: false
- php: '7.2'
wp: '5.7'
experimental: false
- php: '7.0'
wp: '5.8'
experimental: false
- php: '7.4'
wp: '6.3'
experimental: false
# Experimental builds. These are allowed to fail.
- php: '7.4'
wp: 'trunk'
experimental: true
name: "PHP ${{ matrix.php }} - WP ${{ matrix.wp }}"
continue-on-error: ${{ matrix.experimental }}
services:
mysql:
# WP 5.4 is the first WP version which largely supports MySQL 8.0.
# See: https://core.trac.wordpress.org/ticket/49344
# During the setting up of these tests, it became clear that MySQL 8.0
# in combination with PHP < 7.4 is not properly/sufficiently supported
# within WP Core.
# See: https://core.trac.wordpress.org/ticket/52496
image: mysql:${{ ( matrix.wp == 5.3 && '5.6' ) || ( (matrix.wp < 5.4 || matrix.php < 7.4) && '5.7' ) || '8.0' }}
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
- name: Set up WordPress
run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }}
# Determine the type of Composer install which is needed.
# 1. WP 5.9 or higher - all PHPUnit versions needed are supported, use the most appropriate one.
# 2. WP 5.9 or higher with PHP 8.2 (RC) - not all dependencies of PHPUnit have declared PHP 8.2 compatibility, so needs ignore platform.
# 3. WP < 5.9 with PHP < 8.0 - PHPUnit 5 - 7 supported, use the most appropriate one.
# 4. WP < 5.9 with PHP 8.0 or higher - PHPUnit 5 - 7 supported, needs ignore platform reqs to install PHPUnit 7 for PHP >= 8.0.
- name: Determine the type of Composer install to use
id: composer_toggle
run: |
if [[ "${{ matrix.wp }}" =~ ^(trunk|latest|5\.9|[6789]\.[0-9])$ ]]; then
if [[ "${{ matrix.php }}" != "8.2" ]]; then
echo 'TYPE=1' >> $GITHUB_OUTPUT
else
echo 'TYPE=2' >> $GITHUB_OUTPUT
fi
elif [[ "${{ matrix.php }}" > "7.4" ]]; then
echo 'TYPE=4' >> $GITHUB_OUTPUT
else
echo 'TYPE=3' >> $GITHUB_OUTPUT
fi
# Remove the PHPUnit requirement for WP 5.9 and higher in favour of letting the Polyfills manage it.
# The Composer command will exit with error code 2 as the package is not removed, so ignore "failure" of this step.
- name: Conditionally remove PHPUnit requirement
if: ${{ steps.composer_toggle.outputs.TYPE == '1' || steps.composer_toggle.outputs.TYPE == '2' }}
continue-on-error: true
run: composer remove --dev phpunit/phpunit --no-update --no-interaction || true
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies - normal
if: ${{ steps.composer_toggle.outputs.TYPE == '1' || steps.composer_toggle.outputs.TYPE == '3' }}
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")
# For PHP 8.0 and above on WP 5.2 - 5.8, we need to install with ignore platform reqs as not all dependencies allow it.
- name: Install Composer dependencies with ignore platform reqs
if: ${{ steps.composer_toggle.outputs.TYPE == '2' || steps.composer_toggle.outputs.TYPE == '4' }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-req=php
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")
- name: Run the unit tests - single site
run: vendor/bin/phpunit
- name: Run the unit tests - multisite
run: vendor/bin/phpunit
env:
WP_MULTISITE: 1