Skip to content

Commit 64cec98

Browse files
committed
GH Actions: run tests on Windows too
For the `quicktest` and the `coverage` jobs, only select tests which are marked with `@group Windows` will be run. For the "normal " `test` job, all tests will now be run on Windows too.
1 parent 8d8de78 commit 64cec98

File tree

2 files changed

+52
-31
lines changed

2 files changed

+52
-31
lines changed

.github/workflows/quicktest.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ jobs:
2424
# These are basically the same builds as in the Test->Coverage workflow, but then without doing
2525
# the code-coverage.
2626
quicktest:
27-
runs-on: ubuntu-latest
27+
runs-on: ${{ matrix.os }}
2828

2929
strategy:
3030
matrix:
31+
os: ['ubuntu-latest', 'windows-latest']
3132
php: ['7.2', 'latest']
3233

33-
name: "QuickTest: PHP ${{ matrix.php }}"
34+
name: "QuickTest: PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
3435

3536
steps:
3637
- name: Checkout code
@@ -52,11 +53,16 @@ jobs:
5253
custom-cache-suffix: $(date -u "+%Y-%m")
5354

5455
- name: 'PHPCS: set the path to PHP'
55-
run: php bin/phpcs --config-set php_path php
56+
run: php "bin/phpcs" --config-set php_path php
5657

57-
- name: 'PHPUnit: run the tests'
58-
run: vendor/bin/phpunit tests/AllTests.php --no-coverage
58+
- name: 'PHPUnit: run the full test suite'
59+
if: ${{ matrix.os != 'windows-latest' }}
60+
run: php "vendor/bin/phpunit" --no-coverage
61+
62+
- name: 'PHPUnit: run tests which may have different outcomes on Windows'
63+
if: ${{ matrix.os == 'windows-latest' }}
64+
run: php "vendor/bin/phpunit" --group Windows --no-coverage
5965

6066
# Note: The code style check is run as an integration test.
6167
- name: 'PHPCS: check code style without cache, no parallel'
62-
run: php bin/phpcs --no-cache --parallel=1
68+
run: php "bin/phpcs" --no-cache --parallel=1

.github/workflows/test.yml

+40-25
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
# - custom_ini: Whether to run with specific custom ini settings to hit very specific
9090
# code conditions.
9191
matrix:
92+
os: ['ubuntu-latest', 'windows-latest']
9293
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
9394
custom_ini: [false]
9495

@@ -102,9 +103,11 @@ jobs:
102103

103104
# Extra builds running only the unit tests with different PHP ini settings.
104105
- php: '7.4'
106+
os: 'ubuntu-latest'
105107
custom_ini: true
106108

107-
name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}"
109+
# yamllint disable-line rule:line-length
110+
name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
108111

109112
continue-on-error: ${{ matrix.php == '8.5' }}
110113

@@ -114,6 +117,7 @@ jobs:
114117

115118
- name: Setup ini config
116119
id: set_ini
120+
shell: bash
117121
run: |
118122
# Set the "short_open_tag" ini to make sure specific conditions are tested.
119123
# Also turn on error_reporting to ensure all notices are shown.
@@ -142,20 +146,20 @@ jobs:
142146
# Note: The code style check is run multiple times against every PHP version
143147
# as it also acts as an integration test.
144148
- name: 'PHPCS: set the path to PHP'
145-
run: php bin/phpcs --config-set php_path php
149+
run: php "bin/phpcs" --config-set php_path php
146150

147-
- name: 'PHPUnit: run the tests without code coverage'
151+
- name: 'PHPUnit: run the full test suite without code coverage'
148152
if: ${{ matrix.skip_tests != true }}
149-
run: vendor/bin/phpunit --no-coverage
153+
run: php "vendor/bin/phpunit" --no-coverage
150154

151155
- name: 'PHPCS: check code style without cache, no parallel'
152156
if: ${{ matrix.custom_ini == false && matrix.php != '7.4' }}
153-
run: php bin/phpcs --no-cache --parallel=1
157+
run: php "bin/phpcs" --no-cache --parallel=1
154158

155159
- name: 'PHPCS: check code style to show results in PR'
156160
if: ${{ matrix.custom_ini == false && matrix.php == '7.4' }}
157161
id: phpcs
158-
run: php bin/phpcs --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
162+
run: php "bin/phpcs" --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
159163

160164
- name: Show PHPCS results in PR
161165
if: ${{ always() && steps.phpcs.outcome == 'failure' && matrix.php == '7.4' }}
@@ -173,40 +177,42 @@ jobs:
173177
run: php phpcs.phar
174178

175179
coverage:
176-
runs-on: ubuntu-latest
180+
runs-on: ${{ matrix.os }}
177181

178182
strategy:
179183
matrix:
184+
os: ['ubuntu-latest', 'windows-latest']
185+
php: ['7.2', '8.4']
186+
custom_ini: [false]
187+
180188
include:
181-
- php: '7.2'
182-
custom_ini: false
189+
# Also run one coverage build with custom ini settings.
183190
- php: '8.1'
191+
os: 'ubuntu-latest'
184192
custom_ini: true
185-
- php: '8.4'
186-
custom_ini: false
187193

188-
name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}"
194+
# yamllint disable-line rule:line-length
195+
name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
189196

190197
steps:
191198
- name: Checkout code
192199
uses: actions/checkout@v4
193200

194201
- name: Setup ini config
202+
if: ${{ matrix.os != 'windows-latest' }}
195203
id: set_ini
204+
shell: bash
196205
run: |
197206
# Set the "short_open_tag" ini to make sure specific conditions are tested.
198-
# Also turn on error_reporting to ensure all notices are shown.
199207
if [[ ${{ matrix.custom_ini }} == true ]]; then
200-
echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
201-
else
202-
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
208+
echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
203209
fi
204210
205211
- name: Install PHP
206212
uses: shivammathur/setup-php@v2
207213
with:
208214
php-version: ${{ matrix.php }}
209-
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
215+
ini-values: error_reporting=-1, display_errors=On${{ steps.set_ini.outputs.PHP_INI }}
210216
coverage: xdebug
211217

212218
# Install dependencies and handle caching in one go.
@@ -219,38 +225,47 @@ jobs:
219225

220226
- name: Grab PHPUnit version
221227
id: phpunit_version
228+
shell: bash
222229
# yamllint disable-line rule:line-length
223-
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
230+
run: echo "VERSION=$(php "vendor/bin/phpunit" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
224231

225232
- name: "DEBUG: Show grabbed version"
226233
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
227234

228235
- name: 'PHPCS: set the path to PHP'
229-
run: php bin/phpcs --config-set php_path php
236+
run: php "bin/phpcs" --config-set php_path php
230237

231238
# PHPUnit 9.3 started using PHP-Parser for code coverage, which can cause issues due to Parser
232239
# also polyfilling PHP tokens.
233240
# As of PHPUnit 9.3.4, a cache warming option is available.
234241
# Using that option prevents issues with PHP-Parser backfilling PHP tokens during our test runs.
235242
- name: "Warm the PHPUnit cache (PHPUnit 9.3+)"
236243
if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
237-
run: vendor/bin/phpunit --coverage-cache ./build/phpunit-cache --warm-coverage-cache
244+
run: php "vendor/bin/phpunit" --coverage-cache ./build/phpunit-cache --warm-coverage-cache
238245

239246
- name: "Run the unit tests with code coverage (PHPUnit < 9.3)"
240-
if: ${{ steps.phpunit_version.outputs.VERSION < '9.3' }}
241-
run: vendor/bin/phpunit
247+
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
248+
run: php "vendor/bin/phpunit"
242249

243250
- name: "Run the unit tests with code coverage (PHPUnit 9.3+)"
244-
if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
245-
run: vendor/bin/phpunit --coverage-cache ./build/phpunit-cache
251+
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
252+
run: php "vendor/bin/phpunit" --coverage-cache ./build/phpunit-cache
253+
254+
- name: "Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit < 9.3)"
255+
if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
256+
run: php "vendor/bin/phpunit" --group Windows
257+
258+
- name: "Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit 9.3+)"
259+
if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
260+
run: php "vendor/bin/phpunit" --group Windows --coverage-cache ./build/phpunit-cache
246261

247262
- name: Upload coverage results to Coveralls
248263
if: ${{ success() }}
249264
uses: coverallsapp/github-action@v2
250265
with:
251266
format: clover
252267
file: build/logs/clover.xml
253-
flag-name: php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
268+
flag-name: os-${{ matrix.os }}-php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
254269
parallel: true
255270

256271
coveralls-finish:

0 commit comments

Comments
 (0)