@@ -25,11 +25,11 @@ jobs:
25
25
26
26
strategy :
27
27
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 ']
29
29
30
30
name : " Lint: PHP ${{ matrix.php }}"
31
31
32
- continue-on-error : ${{ matrix.php == '8.5 ' }}
32
+ continue-on-error : ${{ matrix.php == 'nightly ' }}
33
33
34
34
steps :
35
35
- name : Checkout code
47
47
uses : " ramsey/composer-install@v3"
48
48
with :
49
49
# 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+' || '' }}
51
51
# Bust the cache at least once a month - output format: YYYY-MM.
52
52
custom-cache-suffix : $(date -u "+%Y-%m")
53
53
68
68
#
69
69
# The matrix is set up so as not to duplicate the builds which are run for code coverage.
70
70
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 }}"
74
111
75
112
continue-on-error : ${{ matrix.php == '8.5' }}
76
113
@@ -82,12 +119,14 @@ jobs:
82
119
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
83
120
- name : Setup ini config
84
121
id : set_ini
122
+ # yamllint disable rule:line-length
85
123
run : |
86
- if [[ "${{ matrix.phpcs_version }}" != " dev-master " ]]; then
124
+ if [[ "${{ contains( matrix.phpcs_version, 'dev') }}" == "false" && "${{ contains( matrix.phpcsutils_version, ' dev') }}" == "false " ]]; then
87
125
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT"
88
126
else
89
127
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
90
128
fi
129
+ # yamllint enable rule:line-length
91
130
92
131
- name : Install PHP
93
132
uses : shivammathur/setup-php@v2
@@ -96,12 +135,19 @@ jobs:
96
135
ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
97
136
coverage : none
98
137
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' }}
101
144
run : composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
102
145
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"
105
151
run : composer config --unset lock
106
152
107
153
# Install dependencies and handle caching in one go.
@@ -114,19 +160,34 @@ jobs:
114
160
# Bust the cache at least once a month - output format: YYYY-MM.
115
161
custom-cache-suffix : $(date -u "+%Y-%m")
116
162
117
- - name : " Composer: set PHPCS/PHPCSUtils version for tests (lowest)"
163
+ - name : " Composer: set PHPCS version for tests (lowest)"
118
164
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
123
186
124
- - name : Run the unit tests
125
- run : composer test
126
187
127
188
# ### CODE COVERAGE STAGE ####
128
189
# 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 .
130
191
# These builds are left out off the "test" stage so as not to duplicate test runs.
131
192
coverage :
132
193
# No use running the coverage builds if there are failing test builds.
@@ -139,9 +200,18 @@ jobs:
139
200
strategy :
140
201
matrix :
141
202
php : ['5.4', '8.4']
142
- phpcs_version : ['lowest', 'dev-master ']
203
+ dependencies : ['lowest', 'stable', ' dev']
143
204
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 }}"
145
215
146
216
steps :
147
217
- name : Checkout code
@@ -151,12 +221,14 @@ jobs:
151
221
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
152
222
- name : Setup ini config
153
223
id : set_ini
224
+ # yamllint disable rule:line-length
154
225
run : |
155
- if [ "${{ matrix.phpcs_version }}" != "dev-master " ]; then
226
+ if [ "${{ matrix.dependencies == 'dev' }}" == "false " ]; then
156
227
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT"
157
228
else
158
229
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
159
230
fi
231
+ # yamllint enable rule:line-length
160
232
161
233
- name : Install PHP
162
234
uses : shivammathur/setup-php@v2
@@ -165,12 +237,19 @@ jobs:
165
237
ini-values : ${{ steps.set_ini.outputs.PHP_INI }}
166
238
coverage : xdebug
167
239
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"
171
250
172
251
- name : " Composer: use lock file when necessary"
173
- if : ${{ matrix.phpcs_version == 'lowest' }}
252
+ if : ${{ matrix.dependencies == 'lowest' }}
174
253
run : composer config --unset lock
175
254
176
255
# Install dependencies and handle caching in one go.
@@ -182,22 +261,32 @@ jobs:
182
261
custom-cache-suffix : $(date -u "+%Y-%m")
183
262
184
263
- name : " Composer: set PHPCS/PHPCSUtils version for tests (lowest)"
185
- if : ${{ matrix.phpcs_version == 'lowest' }}
264
+ if : ${{ matrix.dependencies == 'lowest' }}
186
265
run : >
187
266
composer update --prefer-lowest --no-scripts --no-interaction
188
267
squizlabs/php_codesniffer
189
268
phpcsstandards/phpcsutils
190
269
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
193
282
194
283
- name : Upload coverage results to Coveralls
195
284
if : ${{ success() }}
196
285
uses : coverallsapp/github-action@v2
197
286
with :
198
287
format : clover
199
288
file : build/logs/clover.xml
200
- flag-name : php-${{ matrix.php }}-phpcs-${{ matrix.phpcs_version }}
289
+ flag-name : php-${{ matrix.php }}-phpcs-${{ matrix.dependencies }}
201
290
parallel : true
202
291
203
292
coveralls-finish :
0 commit comments