11name : Test
22
33on :
4- # Run on pushes to `master` and on all pull requests.
4+ # Run on pushes to `master`/`4.0` and on all pull requests.
55 # Prevent the build from running when there are only irrelevant changes.
66 push :
77 branches :
88 - master
9+ - 4.0
910 tags :
1011 - ' **'
1112 paths-ignore :
4445 group : ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index }}-${{ github.ref }}
4546 cancel-in-progress : true
4647
47- runs-on : ubuntu-latest
48+ runs-on : ${{ matrix.os }}
4849 needs : build
4950
5051 strategy :
6061 # Installing on Windows with PHP 5.4 runs into all sorts of problems (which are not ours).
6162 - php : ' 5.4'
6263 os : ' windows-latest'
64+ # By default, the memory limit should be disabled with setup_php, but we're still running
65+ # into memory limit issues when the full test suite is run on PHP 5.6 in Windows.
66+ # As support for PHP < 7.2 will be dropped in PHPCS 4.0 anyhow, let's just skip the build.
67+ - php : ' 5.6'
68+ os : ' windows-latest'
6369
6470 include :
6571 # Skip test runs on builds which are also run in the coverage job.
@@ -73,16 +79,33 @@ jobs:
7379 - php : ' 8.4'
7480 skip_tests : true
7581
82+ # The default libxml library on Ubuntu images is a little out of date.
83+ # To safeguard support for the latest libxml we need to update the library on the fly.
84+ # This only needs to be tested with one PHP version for each libxml minor to verify support.
85+ # Testing against multiple PHP versions would not yield a difference in results.
86+ - php : ' 8.0'
87+ os : ' ubuntu-latest'
88+ libxml_minor : ' 2.11'
89+ - php : ' 8.3'
90+ os : ' ubuntu-latest'
91+ libxml_minor : ' 2.13'
92+
7693 # Extra builds running only the unit tests with different PHP ini settings.
7794 - php : ' 5.5'
7895 os : ' ubuntu-latest'
7996 custom_ini : true
8097 - php : ' 7.0'
8198 os : ' ubuntu-latest'
8299 custom_ini : true
100+ - php : ' 8.0'
101+ os : ' ubuntu-latest'
102+ custom_ini : true
103+ - php : ' 8.2'
104+ os : ' ubuntu-latest'
105+ custom_ini : true
83106
84107 # yamllint disable-line rule:line-length
85- name : " PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
108+ name : " PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}${{ matrix.libxml_minor && format( ' with libxml {0}', matrix.libxml_minor ) || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
86109
87110 continue-on-error : ${{ matrix.php == '8.5' }}
88111
@@ -93,6 +116,70 @@ jobs:
93116 - name : Checkout code
94117 uses : actions/checkout@v4
95118
119+ - name : " libxml2: find the latest relevant tag"
120+ if : ${{ matrix.libxml_minor }}
121+ id : libxml_version
122+ uses : oprypin/find-latest-tag@v1
123+ with :
124+ repository : GNOME/libxml2
125+ releases-only : false # The libxml2 repository doesn't use GitHub's "release" feature.
126+ prefix : ' v${{ matrix.libxml_minor }}.' # Limit the result to the minor we're interested in.
127+ sort-tags : true # Find the "greatest" version for that minor based on semver.
128+
129+ # To put it simply: we need to remove the 'v' prefix from the version number.
130+ - name : " libxml2: parse the version to a patch version"
131+ if : ${{ matrix.libxml_minor }}
132+ id : libxml_patch_version
133+ shell : bash
134+ env :
135+ TAG : ${{ steps.libxml_version.outputs.tag }}
136+ run : echo "PATCH=$( echo "$TAG" | cut -b 2- )" >> "$GITHUB_OUTPUT"
137+
138+ - name : " libxml2: restore cache"
139+ if : ${{ matrix.libxml_minor }}
140+ id : libxml_cache_restore
141+ uses : actions/cache/restore@v4
142+ with :
143+ path : " libxml2-${{ steps.libxml_patch_version.outputs.PATCH }}"
144+ key : " ${{ matrix.os }}-libxml-${{ matrix.libxml_minor }}-${{ steps.libxml_patch_version.outputs.PATCH }}"
145+
146+ # Updating the lists can fail intermittently, typically after Microsoft has released a new package.
147+ # This should not be blocking for this job, so ignore any errors from this step.
148+ # Ref: https://github.com/dotnet/core/issues/4167
149+ - name : " libxml2: Update the available packages list"
150+ if : ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }}
151+ continue-on-error : true
152+ run : sudo apt-get update
153+
154+ - name : " libxml2: Download and build package (linux only)"
155+ if : ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }}
156+ env :
157+ PATCH : ${{ steps.libxml_patch_version.outputs.PATCH }}
158+ run : |
159+ sudo apt-get install -y wget build-essential
160+ wget "https://download.gnome.org/sources/libxml2/${{ matrix.libxml_minor }}/libxml2-$PATCH.tar.xz"
161+ tar -xf "libxml2-$PATCH.tar.xz"
162+ cd "libxml2-$PATCH"
163+ ./configure --prefix=/usr/local
164+ make
165+
166+ - name : " libxml2: save cache"
167+ if : ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }}
168+ id : libxml_cache_save
169+ uses : actions/cache/save@v4
170+ with :
171+ path : " libxml2-${{ steps.libxml_patch_version.outputs.PATCH }}"
172+ key : ${{ steps.libxml_cache_restore.outputs.cache-primary-key }}
173+
174+ - name : " libxml2: Install package (linux only)"
175+ if : ${{ matrix.libxml_minor }}
176+ env :
177+ PATCH : ${{ steps.libxml_patch_version.outputs.PATCH }}
178+ run : |
179+ cd "libxml2-$PATCH"
180+ sudo make install
181+ sudo ldconfig
182+
96183 - name : Setup ini config
97184 id : set_ini
98185 shell : bash
@@ -101,7 +188,7 @@ jobs:
101188 # Also turn on error_reporting to ensure all notices are shown.
102189 if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then
103190 echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> "$GITHUB_OUTPUT"
104- elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0 ' ]]; then
191+ elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" != '5.5 ' ]]; then
105192 echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
106193 else
107194 echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
@@ -113,7 +200,9 @@ jobs:
113200 php-version : ${{ matrix.php }}
114201 ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
115202 coverage : none
116- tools : cs2pr
203+
204+ - name : " DEBUG: show libxml loaded version (php)"
205+ run : php -r 'echo "libxml loaded version = ", LIBXML_LOADED_VERSION, PHP_EOL;'
117206
118207 # This action also handles the caching of the dependencies.
119208 - name : Set up node
@@ -135,37 +224,35 @@ jobs:
135224 - name : Install Composer dependencies
136225 uses : " ramsey/composer-install@v3"
137226 with :
138- composer-options : ${{ matrix.php == '8.5' && '--ignore-platform-req=php' || '' }}
227+ composer-options : ${{ matrix.php == '8.5' && '--ignore-platform-req=php+ ' || '' }}
139228 custom-cache-suffix : $(date -u "+%Y-%m")
140229
141- # Note: The code style check is run multiple times against every PHP version
142- # as it also acts as an integration test.
143230 - name : ' PHPCS: set the path to PHP'
144231 run : php "bin/phpcs" --config-set php_path php
145232
146233 - name : ' PHPUnit: run the full test suite without code coverage'
147234 if : ${{ matrix.skip_tests != true }}
148235 run : php "vendor/bin/phpunit" tests/AllTests.php --no-coverage
149236
237+ # Do one test run against the complete test suite in CBF mode to ensure all tests can run in CBF mode.
238+ - name : ' PHPUnit: run the full test suite without code coverage in CBF mode (PHP 8.3 only)'
239+ if : ${{ matrix.php == '8.3' }}
240+ run : php "vendor/bin/phpunit" tests/AllTests.php --exclude-group nothing --no-coverage
241+ env :
242+ PHP_CODESNIFFER_CBF : ' 1'
243+
150244 - name : ' PHPUnit: run select tests in CBF mode'
151- if : ${{ matrix.skip_tests != true }}
245+ if : ${{ matrix.skip_tests != true && matrix.php != '8.3' }}
152246 run : php "vendor/bin/phpunit" tests/AllTests.php --group CBF --exclude-group nothing --no-coverage
153247 env :
154248 PHP_CODESNIFFER_CBF : ' 1'
155249
250+ # Note: The code style check is run multiple times against every PHP version
251+ # as it also acts as an integration test.
156252 - name : ' PHPCS: check code style without cache, no parallel'
157- if : ${{ matrix.custom_ini == false && matrix.php != '7.4' }}
253+ if : ${{ matrix.custom_ini == false }}
158254 run : php "bin/phpcs" --no-cache --parallel=1
159255
160- - name : ' PHPCS: check code style to show results in PR'
161- if : ${{ matrix.custom_ini == false && matrix.php == '7.4' }}
162- id : phpcs
163- run : php "bin/phpcs" --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
164-
165- - name : Show PHPCS results in PR
166- if : ${{ always() && steps.phpcs.outcome == 'failure' && matrix.php == '7.4' }}
167- run : cs2pr ./phpcs-report.xml
168-
169256 - name : Download the PHPCS phar
170257 if : ${{ matrix.custom_ini == false }}
171258 uses : actions/download-artifact@v4
@@ -216,14 +303,12 @@ jobs:
216303 uses : actions/checkout@v4
217304
218305 - name : Setup ini config
219- if : ${{ matrix.os != 'windows-latest' }}
306+ if : ${{ matrix.custom_ini == true && matrix. os != 'windows-latest' }}
220307 id : set_ini
221308 shell : bash
222309 run : |
223310 # Set the "short_open_tag" ini to make sure specific conditions are tested.
224- if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.2' ]]; then
225- echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
226- fi
311+ echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
227312
228313 - name : Install PHP
229314 uses : shivammathur/setup-php@v2
@@ -275,37 +360,26 @@ jobs:
275360 if : ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
276361 run : php "vendor/bin/phpunit" --coverage-cache ./build/phpunit-cache --warm-coverage-cache
277362
278- - name : " Run the unit tests with code coverage (PHPUnit < 9.3)"
279- if : ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
280- run : php "vendor/bin/phpunit" tests/AllTests.php
281-
282- - name : " Run the unit tests with code coverage (PHPUnit 9.3+)"
283- if : ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
284- run : php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache
285-
286- - name : " Run select tests in CBF mode with code coverage (PHPUnit < 9.3)"
287- if : ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
363+ - name : " Run the unit tests with code coverage"
364+ if : ${{ matrix.os != 'windows-latest' }}
288365 run : >
289366 php "vendor/bin/phpunit" tests/AllTests.php
290- --group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml
291- env :
292- PHP_CODESNIFFER_CBF : ' 1'
367+ ${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}
293368
294- - name : " Run select tests in CBF mode with code coverage (PHPUnit 9.3+) "
295- if : ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
369+ - name : " Run select tests in CBF mode with code coverage"
370+ if : ${{ matrix.os != 'windows-latest' }}
296371 run : >
297- php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache
372+ php "vendor/bin/phpunit" tests/AllTests.php
373+ ${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}
298374 --group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml
299375 env :
300376 PHP_CODESNIFFER_CBF : ' 1'
301377
302- - name : " Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit < 9.3)"
303- if : ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
304- run : php "vendor/bin/phpunit" tests/AllTests.php --group Windows
305-
306- - name : " Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit 9.3+)"
307- if : ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
308- run : php "vendor/bin/phpunit" tests/AllTests.php --group Windows --coverage-cache ./build/phpunit-cache
378+ - name : " Run the unit tests which may have different outcomes on Windows with code coverage"
379+ if : ${{ matrix.os == 'windows-latest' }}
380+ run : >
381+ php "vendor/bin/phpunit" tests/AllTests.php --group Windows
382+ ${{ steps.phpunit_version.outputs.VERSION >= '9.3' && '--coverage-cache ./build/phpunit-cache' || '' }}
309383
310384 - name : " Upload coverage results to Coveralls (normal run)"
311385 if : ${{ success() }}
0 commit comments