@@ -25,11 +25,11 @@ jobs:
2525
2626 strategy :
2727 matrix :
28- php : ['5.4', '7.0', '7.4', '8.0', '8.4', '8.5 ']
28+ php : ['5.4', '7.0', '7.4', '8.0', '8.4', 'nightly ']
2929
3030 name : " Lint: PHP ${{ matrix.php }}"
3131
32- continue-on-error : ${{ matrix.php == '8.5 ' }}
32+ continue-on-error : ${{ matrix.php == 'nightly ' }}
3333
3434 steps :
3535 - name : Checkout code
4747 uses : " ramsey/composer-install@v3"
4848 with :
4949 # For the PHP "nightly", we need to install with ignore platform reqs as not all dependencies may allow it yet.
50- composer-options : ${{ matrix.php == '8.5 ' && '--ignore-platform-req=php+' || '' }}
50+ composer-options : ${{ matrix.php == 'nightly ' && '--ignore-platform-req=php+' || '' }}
5151 # Bust the cache at least once a month - output format: YYYY-MM.
5252 custom-cache-suffix : $(date -u "+%Y-%m")
5353
6868 #
6969 # The matrix is set up so as not to duplicate the builds which are run for code coverage.
7070 php : ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.5']
71- phpcs_version : ['lowest', 'dev-master']
72-
73- name : " Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
71+ phpcs_version : ['lowest', 'stable', '4.x-dev']
72+ phpcsutils_version : ['stable']
73+
74+ exclude :
75+ - php : ' 5.5'
76+ phpcs_version : ' 4.x-dev'
77+ - php : ' 5.6'
78+ phpcs_version : ' 4.x-dev'
79+ - php : ' 7.0'
80+ phpcs_version : ' 4.x-dev'
81+ - php : ' 7.1'
82+ phpcs_version : ' 4.x-dev'
83+
84+ include :
85+ # Add some builds with variations of the dependency versions.
86+ # Note: the PHPCS low/stable + Utils stable combi is already run via the above matrix.
87+ # And the PHPCS low + Utils low combi is run in the code coverage builds.
88+ # So these are the only combis missing.
89+ - php : ' 5.4'
90+ phpcs_version : ' stable'
91+ phpcsutils_version : ' lowest'
92+ - php : ' 8.4'
93+ phpcs_version : ' stable'
94+ phpcsutils_version : ' lowest'
95+
96+ # Test against dev versions of all dependencies with select PHP versions for early detection of issues.
97+ - php : ' 5.4'
98+ phpcs_version : ' dev-master'
99+ phpcsutils_version : ' dev-develop'
100+ - php : ' 7.2'
101+ phpcs_version : ' dev-master'
102+ phpcsutils_version : ' dev-develop'
103+ - php : ' 7.4'
104+ phpcs_version : ' 4.x-dev'
105+ phpcsutils_version : ' dev-develop'
106+ - php : ' 8.2'
107+ phpcs_version : ' 4.x-dev'
108+ phpcsutils_version : ' dev-develop'
109+
110+ name : " Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - Utils ${{ matrix.phpcsutils_version }}"
74111
75112 continue-on-error : ${{ matrix.php == '8.5' }}
76113
@@ -82,12 +119,14 @@ jobs:
82119 # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
83120 - name : Setup ini config
84121 id : set_ini
122+ # yamllint disable rule:line-length
85123 run : |
86- if [[ "${{ matrix.phpcs_version }}" != " dev-master " ]]; then
124+ if [[ "${{ contains( matrix.phpcs_version, 'dev') }}" == "false" && "${{ contains( matrix.phpcsutils_version, ' dev') }}" == "false " ]]; then
87125 echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT"
88126 else
89127 echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
90128 fi
129+ # yamllint enable rule:line-length
91130
92131 - name : Install PHP
93132 uses : shivammathur/setup-php@v2
@@ -96,12 +135,19 @@ jobs:
96135 ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
97136 coverage : none
98137
99- - name : " Composer: set PHPCS version for tests (master)"
100- if : ${{ matrix.phpcs_version != 'lowest' }}
138+ # Remove PHPCSDevCS as it would (for now) prevent the tests from being able to run against PHPCS 4.x.
139+ - name : ' Composer: remove PHPCSDevCS'
140+ run : composer remove --dev phpcsstandards/phpcsdevcs --no-update --no-interaction
141+
142+ - name : " Composer: set PHPCS version for tests (dev/specific version)"
143+ if : ${{ matrix.phpcs_version != 'lowest' && matrix.phpcs_version != 'stable' }}
101144 run : composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
102145
103- - name : " Composer: use lock file when necessary"
104- if : ${{ matrix.phpcs_version == 'lowest' }}
146+ - name : " Composer: set PHPCSUtils version for tests (dev/specific version)"
147+ if : ${{ matrix.phpcsutils_version != 'lowest' && matrix.phpcsutils_version != 'stable' }}
148+ run : composer require phpcsstandards/phpcsutils:"${{ matrix.phpcsutils_version }}" --no-update --no-scripts --no-interaction
149+
150+ - name : " Composer: use lock file"
105151 run : composer config --unset lock
106152
107153 # Install dependencies and handle caching in one go.
@@ -114,19 +160,34 @@ jobs:
114160 # Bust the cache at least once a month - output format: YYYY-MM.
115161 custom-cache-suffix : $(date -u "+%Y-%m")
116162
117- - name : " Composer: set PHPCS/PHPCSUtils version for tests (lowest)"
163+ - name : " Composer: set PHPCS version for tests (lowest)"
118164 if : ${{ matrix.phpcs_version == 'lowest' }}
119- run : >
120- composer update --prefer-lowest --no-scripts --no-interaction
121- squizlabs/php_codesniffer
122- phpcsstandards/phpcsutils
165+ run : composer update squizlabs/php_codesniffer --prefer-lowest --no-scripts --no-interaction
166+
167+ - name : " Composer: set PHPCSUtils version for tests (lowest)"
168+ if : ${{ matrix.phpcsutils_version == 'lowest' }}
169+ run : composer update phpcsstandards/phpcsutils --prefer-lowest --no-scripts --no-interaction
170+
171+ - name : Composer info
172+ run : composer info
173+
174+ - name : Grab PHPCS version
175+ id : phpcs_version
176+ # yamllint disable-line rule:line-length
177+ run : echo "VERSION=$(vendor/bin/phpcs --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
178+
179+ - name : Run the unit tests (PHPCS 3.x)
180+ if : ${{ startsWith( steps.phpcs_version.outputs.VERSION, '3.' ) }}
181+ run : composer test-phpcs3
182+
183+ - name : Run the unit tests (PHPCS 4.x)
184+ if : ${{ startsWith( steps.phpcs_version.outputs.VERSION, '4.' ) }}
185+ run : composer test-phpcs4
123186
124- - name : Run the unit tests
125- run : composer test
126187
127188 # ### CODE COVERAGE STAGE ####
128189 # N.B.: Coverage is only checked on the lowest and highest stable PHP versions
129- # and a low/high of each major for PHPCS.
190+ # and a low/high for PHPCS and PHPCSUtils .
130191 # These builds are left out off the "test" stage so as not to duplicate test runs.
131192 coverage :
132193 # No use running the coverage builds if there are failing test builds.
@@ -139,9 +200,18 @@ jobs:
139200 strategy :
140201 matrix :
141202 php : ['5.4', '8.4']
142- phpcs_version : ['lowest', 'dev-master ']
203+ dependencies : ['lowest', 'stable', ' dev']
143204
144- name : " Coverage: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
205+ exclude :
206+ - php : ' 5.4'
207+ dependencies : ' dev'
208+
209+ include :
210+ # Replace the "low PHP" dev build for PHPCS 4.x.
211+ - php : ' 7.2'
212+ dependencies : ' dev'
213+
214+ name : " Coverage: PHP ${{ matrix.php }} - PHPCS ${{ matrix.dependencies }}"
145215
146216 steps :
147217 - name : Checkout code
@@ -151,12 +221,14 @@ jobs:
151221 # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
152222 - name : Setup ini config
153223 id : set_ini
224+ # yamllint disable rule:line-length
154225 run : |
155- if [ "${{ matrix.phpcs_version }}" != "dev-master " ]; then
226+ if [ "${{ matrix.dependencies == 'dev' }}" == "false " ]; then
156227 echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT"
157228 else
158229 echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
159230 fi
231+ # yamllint enable rule:line-length
160232
161233 - name : Install PHP
162234 uses : shivammathur/setup-php@v2
@@ -165,12 +237,19 @@ jobs:
165237 ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
166238 coverage : xdebug
167239
168- - name : " Composer: set PHPCS version for tests (master)"
169- if : ${{ matrix.phpcs_version != 'lowest' }}
170- run : composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
240+ # Remove PHPCSDevCS as it would (for now) prevent the tests from being able to run against PHPCS 4.x.
241+ - name : ' Composer: remove PHPCSDevCS'
242+ run : composer remove --dev phpcsstandards/phpcsdevcs --no-update --no-interaction
243+
244+ - name : " Composer: set PHPCS version for tests (dev)"
245+ if : ${{ matrix.dependencies == 'dev' }}
246+ run : >
247+ composer require --no-scripts --no-interaction
248+ squizlabs/php_codesniffer:"4.x-dev"
249+ phpcsstandards/phpcsutils:"dev-develop"
171250
172251 - name : " Composer: use lock file when necessary"
173- if : ${{ matrix.phpcs_version == 'lowest' }}
252+ if : ${{ matrix.dependencies == 'lowest' }}
174253 run : composer config --unset lock
175254
176255 # Install dependencies and handle caching in one go.
@@ -182,22 +261,32 @@ jobs:
182261 custom-cache-suffix : $(date -u "+%Y-%m")
183262
184263 - name : " Composer: set PHPCS/PHPCSUtils version for tests (lowest)"
185- if : ${{ matrix.phpcs_version == 'lowest' }}
264+ if : ${{ matrix.dependencies == 'lowest' }}
186265 run : >
187266 composer update --prefer-lowest --no-scripts --no-interaction
188267 squizlabs/php_codesniffer
189268 phpcsstandards/phpcsutils
190269
191- - name : Run the unit tests with code coverage
192- run : composer coverage
270+ - name : Grab PHPCS version
271+ id : phpcs_version
272+ # yamllint disable-line rule:line-length
273+ run : echo "VERSION=$(vendor/bin/phpcs --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
274+
275+ - name : Run the unit tests with code coverage (PHPCS 3.x)
276+ if : ${{ startsWith( steps.phpcs_version.outputs.VERSION, '3.' ) }}
277+ run : composer coverage-phpcs3
278+
279+ - name : Run the unit tests with code coverage (PHPCS 4.x)
280+ if : ${{ startsWith( steps.phpcs_version.outputs.VERSION, '4.' ) }}
281+ run : composer coverage-phpcs4
193282
194283 - name : Upload coverage results to Coveralls
195284 if : ${{ success() }}
196285 uses : coverallsapp/github-action@v2
197286 with :
198287 format : clover
199288 file : build/logs/clover.xml
200- flag-name : php-${{ matrix.php }}-phpcs-${{ matrix.phpcs_version }}
289+ flag-name : php-${{ matrix.php }}-phpcs-${{ matrix.dependencies }}
201290 parallel : true
202291
203292 coveralls-finish :
0 commit comments