@@ -69,16 +69,31 @@ jobs:
6969 # Keys:
7070 # - custom_ini: Whether to run with specific custom ini settings to hit very specific
7171 # code conditions.
72+ # - coverage: Whether to run the tests with code coverage.
7273 matrix :
73- php : ['5.4', '5.5 ', '5.6', '7.0', '7.1', '7.2', '7. 3', '7.4', '8.0', '8.1', '8.2', '8.3 ', '8.4']
74+ php : ['5.5 ', '5.6', '7.0', '7.1', '7.3', '7.4', '8.0', '8.1', '8.2', '8.4']
7475 custom_ini : [false]
76+ coverage : [false]
7577
7678 include :
7779 # Builds running the basic tests with different PHP ini settings.
7880 - php : ' 5.5'
7981 custom_ini : true
82+ coverage : false
8083 - php : ' 7.0'
8184 custom_ini : true
85+ coverage : false
86+
87+ # Builds running the tests with code coverage.
88+ - php : ' 5.4'
89+ custom_ini : false
90+ coverage : true
91+ - php : ' 7.2'
92+ custom_ini : true
93+ coverage : true
94+ - php : ' 8.3'
95+ custom_ini : false
96+ coverage : true
8297
8398 name : " PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}"
8499
93108 run : |
94109 # Set the "short_open_tag" ini to make sure specific conditions are tested.
95110 # Also turn on error_reporting to ensure all notices are shown.
96- if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then
111+ if [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '5.' ) }}" == true ]]; then
97112 echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> $GITHUB_OUTPUT
98- elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then
113+ elif [[ ${{ matrix.custom_ini }} == true && "${{ startsWith( matrix.php, '7.' ) }}" == true ]]; then
99114 echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> $GITHUB_OUTPUT
100115 else
101116 echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
@@ -106,7 +121,7 @@ jobs:
106121 with :
107122 php-version : ${{ matrix.php }}
108123 ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
109- coverage : none
124+ coverage : ${{ matrix.coverage == true && 'xdebug' || ' none' }}
110125 tools : cs2pr
111126
112127 # This action also handles the caching of the dependencies.
@@ -144,7 +159,12 @@ jobs:
144159 - name : ' PHPCS: set the path to PHP'
145160 run : php bin/phpcs --config-set php_path php
146161
147- - name : ' PHPUnit: run the tests'
162+ - name : ' PHPUnit: run the tests without code coverage'
163+ if : ${{ matrix.coverage == false }}
164+ run : vendor/bin/phpunit tests/AllTests.php --no-coverage
165+
166+ - name : ' PHPUnit: run the tests with code coverage'
167+ if : ${{ matrix.coverage == true }}
148168 run : vendor/bin/phpunit tests/AllTests.php
149169
150170 - name : ' PHPCS: check code style without cache, no parallel'
@@ -169,3 +189,24 @@ jobs:
169189 - name : ' PHPCS: check code style using the Phar file'
170190 if : ${{ matrix.custom_ini == false }}
171191 run : php phpcs.phar
192+
193+ - name : Upload coverage results to Coveralls
194+ if : ${{ success() && matrix.coverage == true }}
195+ uses : coverallsapp/github-action@v2
196+ with :
197+ format : clover
198+ file : build/logs/clover.xml
199+ flag-name : php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
200+ parallel : true
201+
202+ coveralls-finish :
203+ needs : test
204+ if : always() && needs.test.result == 'success'
205+
206+ runs-on : ubuntu-latest
207+
208+ steps :
209+ - name : Coveralls Finished
210+ uses : coverallsapp/github-action@v2
211+ with :
212+ parallel-finished : true
0 commit comments