7474 custom_ini : [false]
7575
7676 include :
77- # Builds running the basic tests with different PHP ini settings.
77+ # Skip test runs on builds which are also run for in the coverage job.
78+ # Note: the tests on PHP 7.2 will still be run as the coverage build is uses custom_ini for that version.
79+ - php : ' 5.4'
80+ skip_tests : true
81+ - php : ' 8.3'
82+ skip_tests : true
83+
84+ # Extra builds running only the unit tests with different PHP ini settings.
7885 - php : ' 5.5'
7986 custom_ini : true
8087 - php : ' 7.0'
@@ -137,8 +144,9 @@ jobs:
137144 - name : ' PHPCS: set the path to PHP'
138145 run : php bin/phpcs --config-set php_path php
139146
140- - name : ' PHPUnit: run the tests'
141- run : vendor/bin/phpunit tests/AllTests.php
147+ - name : ' PHPUnit: run the tests without code coverage'
148+ if : ${{ matrix.skip_tests != true }}
149+ run : vendor/bin/phpunit tests/AllTests.php --no-coverage
142150
143151 - name : ' PHPCS: check code style without cache, no parallel'
144152 if : ${{ matrix.custom_ini == false && matrix.php != '7.4' }}
@@ -163,3 +171,92 @@ jobs:
163171 - name : ' PHPCS: check code style using the Phar file'
164172 if : ${{ matrix.custom_ini == false }}
165173 run : php phpcs.phar
174+
175+ coverage :
176+ runs-on : ubuntu-latest
177+
178+ strategy :
179+ matrix :
180+ include :
181+ - php : ' 5.4'
182+ custom_ini : false
183+ - php : ' 7.2'
184+ custom_ini : true
185+ - php : ' 8.3'
186+ custom_ini : false
187+
188+ name : " Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}"
189+
190+ steps :
191+ - name : Checkout code
192+ uses : actions/checkout@v4
193+
194+ - name : Setup ini config
195+ id : set_ini
196+ run : |
197+ # 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.
199+ if [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '5.' ) }}" == true ]]; then
200+ echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> $GITHUB_OUTPUT
201+ elif [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '7.' ) }}" == true ]]; then
202+ echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> $GITHUB_OUTPUT
203+ else
204+ echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
205+ fi
206+
207+ - name : Install PHP
208+ uses : shivammathur/setup-php@v2
209+ with :
210+ php-version : ${{ matrix.php }}
211+ ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
212+ coverage : xdebug
213+
214+ # This action also handles the caching of the dependencies.
215+ - name : Set up node
216+ if : ${{ matrix.custom_ini == false }}
217+ uses : actions/setup-node@v4
218+ with :
219+ node-version : ' 20'
220+
221+ - name : Install external tools used in tests
222+ if : ${{ matrix.custom_ini == false }}
223+ run : >
224+ npm install -g --fund false
225+ csslint
226+ eslint
227+ jshint
228+
229+ # Install dependencies and handle caching in one go.
230+ # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
231+ - name : Install Composer dependencies
232+ uses : " ramsey/composer-install@v2"
233+ with :
234+ # Bust the cache at least once a month - output format: YYYY-MM.
235+ custom-cache-suffix : $(date -u "+%Y-%m")
236+
237+ - name : ' PHPCS: set the path to PHP'
238+ run : php bin/phpcs --config-set php_path php
239+
240+ - name : ' PHPUnit: run the tests with code coverage'
241+ run : vendor/bin/phpunit tests/AllTests.php
242+
243+ - name : Upload coverage results to Coveralls
244+ if : ${{ success() }}
245+ uses : coverallsapp/github-action@v2
246+ with :
247+ format : clover
248+ file : build/logs/clover.xml
249+ flag-name : php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
250+ parallel : true
251+
252+ coveralls-finish :
253+ needs : coverage
254+ if : always() && needs.coverage.result == 'success'
255+
256+ runs-on : ubuntu-latest
257+
258+ steps :
259+ - name : Coveralls Finished
260+ uses : coverallsapp/github-action@v2
261+ with :
262+ parallel-finished : true
0 commit comments