-
Notifications
You must be signed in to change notification settings - Fork 13
387 lines (342 loc) · 14.1 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Test
on:
# Run on all pushes and on all pull requests.
push:
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
#### TEST STAGE ####
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
phpunit: ['auto']
coverage: [true]
experimental: [false]
# Mind: code coverage can not be run on PHPUnit 11.2.0 - 11.3.2.
#
# Since PHPUnit 10.0, PHPUnit native deprecations would affect the exit code.
# This has been handled via various work-arounds to avoid the PHPUnit
# deprecation notices, up to the point where it couldn't be handled anymore *.
#
# PHPUnit 11.3.3 changes the default behaviour. PHPUnit deprecation notices will
# now no longer affect the exit code.
#
# * PHPUnit 11.2.0 deprecated the use of `#[CoversClass]` for tests covering traits
# in favour of a new `#[CoversTrait]` attributes.
# No work-around was available to avoid this deprecation notice other than to
# not run code coverage.
# @link https://github.com/sebastianbergmann/phpunit/issues/5937
include:
# Test against a version on the low-end of the PHPUnit versions supported for each PHP version.
# Using the Composer `--prefer-lowest` option is, unfortunately, not viable, as
# it would result PHP 7.0 - 7.4 all using PHPUnit 6.4.4, which is not the intention.
# It also would run into trouble with PHP 8.5.12 being used on PHP 8.0+, while the
# 8.5.12 release still contained a bug which makes it incompatible with PHP 8.1+,
# even though it officially allows for it.
#
# Note: PHPUnit 10 is not supported for the PHPUnit Polyfills 3.x branch, so there are
# no builds against PHPUnit 10!
- php: '7.0'
phpunit: '6.4.4'
coverage: true
experimental: false
- php: '7.1'
phpunit: '~6.4.4'
coverage: true
experimental: false
- php: '7.2'
# - PHPUnit 7.0 seems to have an issue with something related to TestListeners, so using PHPUnit 7.1 instead for "low".
phpunit: '~7.1.0'
coverage: true
experimental: false
- php: '7.3'
phpunit: '7.2.7'
coverage: true
experimental: false
- php: '7.4'
phpunit: '8.1.6'
coverage: true
experimental: false
- php: '7.4'
# Specifically set at 9.6.10 to test functioning on 9.x before the 9.6.11 assertObject*() backports came in.
phpunit: '9.6.10'
coverage: true
experimental: false
- php: '8.0'
phpunit: '8.5.16'
# PHPUnit 8.x does not support code coverage on PHP 8.x.
coverage: false
experimental: false
- php: '8.0'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.1'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.2'
phpunit: '9.3.0'
coverage: true
experimental: false
- php: '8.2'
phpunit: '~11.1.0' # See note above about PHPUnit 11.2.
coverage: true
experimental: false
- php: '8.3'
phpunit: '11.0.0'
coverage: true
experimental: false
# Experimental builds.
- php: 'nightly'
phpunit: '^9.6'
coverage: false
experimental: true
- php: 'nightly'
phpunit: 'auto' # PHPUnit 11.x.
coverage: false
experimental: true
- php: 'latest'
phpunit: 'dev-main' # PHPUnit 11.x/12.x.
coverage: false
experimental: true
name: "Tests: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
continue-on-error: ${{ matrix.experimental }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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: ${{ matrix.coverage == true && 'xdebug' || 'none' }}
# YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package.
- name: 'Composer: remove YoastCS'
run: composer remove --dev yoast/yoastcs --no-update --no-interaction
- name: 'Composer: set PHPUnit version for tests'
if: ${{ matrix.phpunit != 'auto' }}
run: composer require --no-update phpunit/phpunit:"${{ matrix.phpunit }}" --no-interaction
# 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: matrix.php != 'nightly'
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Install Composer dependencies - ignore PHP restrictions
if: matrix.php == 'nightly'
uses: "ramsey/composer-install@v3"
with:
composer-options: --ignore-platform-req=php+
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
- name: Determine PHPUnit config
id: phpunit_config
run: |
if [ "${{ matrix.phpunit == 'dev-main' }}" == "true" ]; then
echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT
else
echo 'FILE=phpunit.xml.dist' >> $GITHUB_OUTPUT
fi
- name: "Run the unit tests"
# Don't fail the build on a test run failure against a future PHPUnit version.
continue-on-error: ${{ matrix.phpunit == 'dev-main' }}
run: >
vendor/bin/phpunit -c ${{ steps.phpunit_config.outputs.FILE }}
${{ ! matrix.coverage && '--no-coverage' || '' }}
- name: Upload coverage results to Coveralls
if: ${{ success() && matrix.coverage == true }}
uses: coverallsapp/github-action@v2
with:
file: build/logs/clover.xml
format: clover
flag-name: php-${{ matrix.php }}-phpunit-${{ matrix.phpunit }}
parallel: true
test-phar:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Test against the high/low supported PHP-PHPUnit combinations.
#
# Code coverage is only run against the high/high PHP-PHPUnit combinations
# and very select other combinations.
# This should be sufficient to record the coverage for the PHAR specific code.
# PHPUnit 6 is only supported for PHPUnit 6.4.4-latest on the officially supported PHP versions.
- php: '7.0'
phpunit: '6.4'
- php: '7.0'
phpunit: '6'
- php: '7.2'
phpunit: '6.4'
- php: '7.2'
phpunit: '6'
coverage: true
# PHPUnit 7 is fully supported for the officially supported PHP versions.
# Caveats:
# - PHPUnit 7.0 seems to have an issue with something related to TestListeners, so using PHPUnit 7.1 instead for "low".
# - PHPUnit 7 supports PHP 7.3 as of PHPUnit 7.3.0 (for our purposes).
- php: '7.1'
phpunit: '7.1'
- php: '7.1'
phpunit: '7'
- php: '7.3'
phpunit: '7.3'
- php: '7.3'
phpunit: '7'
coverage: true
# PHPUnit 8 is fully supported for the officially supported PHP versions.
# Caveats:
# - PHPUnit 8 supports PHP 8.0 as of PHPUnit 8.5.12 (for our purposes).
# - PHPUnit 8 supports PHP 8.1 as of PHPUnit 8.5.19 (for our purposes).
# - PHPUnit 8 supports PHP 8.2 as of PHPUnit 8.5.19 (for our purposes).
# - PHPUnit 8 supports PHP 8.3 as of PHPUnit 8.5.19 (for our purposes).
# - PHPUnit 8 does not support running code coverage on PHP 8.0 or higher.
- php: '7.2'
phpunit: '8.0'
coverage: true
- php: '7.2'
phpunit: '8'
- php: '7.4'
phpunit: '8'
coverage: true
- php: '8.0'
phpunit: '8.5.12'
- php: '8.3'
phpunit: '8.5.19'
- php: '8.3'
phpunit: '8'
# PHPUnit 9 is fully supported for the officially supported PHP versions.
# Caveats:
# - PHPUnit 9 supports PHP 8.0 as of PHPUnit 9.3.0 (for our purposes).
# - PHPUnit 9 supports PHP 8.1 as of PHPUnit 9.5.8 (for our purposes).
# - PHPUnit 9 supports PHP 8.2 as of PHPUnit 9.5.8 (for our purposes).
# - PHPUnit 9 supports PHP 8.3 as of PHPUnit 9.5.8 (for our purposes).
- php: '7.3'
phpunit: '9.0'
coverage: true
- php: '7.3'
phpunit: '9'
- php: '8.0'
phpunit: '9.3.0'
- php: '8.0'
phpunit: '9'
- php: '8.1'
phpunit: '9.5.8'
- php: '8.1'
phpunit: '9'
- php: '8.2'
phpunit: '9.5.8'
- php: '8.2'
phpunit: '9'
- php: '8.3'
phpunit: '9.5.8'
- php: '8.3'
phpunit: '9'
coverage: true
# PHPUnit 10 is NOT supported in PHPUnit Polyfills 3.x.
# PHPUnit 11 is fully supported for the officially supported PHP versions.
#
# Mind: code coverage can not be run on PHPUnit 11.2.0 - 11.3.2.
# For a full explanation, see above (in the strategy for the other test job).
- php: '8.2'
phpunit: '11.0'
coverage: true
- php: '8.2'
phpunit: '11'
- php: '8.3'
phpunit: '11.0'
- php: '8.3'
phpunit: '11'
coverage: true
# Experimental builds.
- php: 'nightly'
phpunit: '9'
- php: 'nightly'
phpunit: '11'
name: "PHAR test: PHP ${{ matrix.php }} - PHPUnit: ${{matrix.phpunit}}"
continue-on-error: ${{ matrix.php == 'nightly' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
tools: phpunit:${{ matrix.phpunit }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
env:
fail-fast: true
# YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package.
- name: 'Composer: remove YoastCS'
run: composer remove --dev yoast/yoastcs --no-update --no-interaction
# Remove PHPUnit from the Composer install as we want to be sure the PHAR file is used.
- name: 'Composer: remove PHPUnit'
run: composer remove phpunit/phpunit --no-update --no-interaction
# 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: matrix.php != 'nightly'
uses: "ramsey/composer-install@v3"
with:
composer-options: "--no-dev"
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Install Composer dependencies - ignore PHP restrictions
if: matrix.php == 'nightly'
uses: "ramsey/composer-install@v3"
with:
composer-options: "--no-dev --ignore-platform-req=php+"
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT
- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
- name: Determine PHPUnit config
id: phpunit_config
run: |
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit10.xml.dist' >> $GITHUB_OUTPUT
else
echo 'FILE=phpunit.xml.dist' >> $GITHUB_OUTPUT
fi
- name: "Run the unit tests"
run: >
phpunit -c ${{ steps.phpunit_config.outputs.FILE }}
${{ ! matrix.coverage && '--no-coverage' || '' }}
- name: Upload coverage results to Coveralls
if: ${{ success() && matrix.coverage }}
uses: coverallsapp/github-action@v2
with:
file: build/logs/clover.xml
format: clover
flag-name: php-${{ matrix.php }}-phpunit-phar-${{ matrix.phpunit }}
parallel: true
coveralls-finish:
needs: [test, test-phar]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true