|
73 | 73 | if: ${{ matrix.php >= '7.2' }}
|
74 | 74 | run: composer lint -- --checkstyle | cs2pr
|
75 | 75 |
|
76 |
| - - name: Lint against parse errors (PHP < 7.2) |
77 |
| - if: ${{ matrix.php < '7.2' }} |
78 |
| - run: composer lintlt72 -- --checkstyle | cs2pr |
| 76 | + - name: Lint against parse errors (PHP < 7.2 && PHP >= 7.0) |
| 77 | + if: ${{ matrix.php < '7.2' && matrix.php >= '7.0' }} |
| 78 | + run: composer lintlt72 |
| 79 | + |
| 80 | + - name: Lint against parse errors (PHP < 7.0) |
| 81 | + if: ${{ matrix.php < '7.0' }} |
| 82 | + run: composer lintlt70 |
79 | 83 |
|
80 | 84 | # Check that any sniffs available are feature complete.
|
81 | 85 | # This also acts as an integration test for the feature completeness script,
|
@@ -230,3 +234,192 @@ jobs:
|
230 | 234 |
|
231 | 235 | - name: Run the unit tests for the PHPCSDebug sniff
|
232 | 236 | run: composer test-sniff${{ steps.phpunit_script.outputs.SUFFIX }}
|
| 237 | + |
| 238 | + # Run CI checks/tests for the DocCodeExamples script as it requires PHP >= 7.0. |
| 239 | + test-doc-code-examples: |
| 240 | + runs-on: ${{ matrix.os }} |
| 241 | + |
| 242 | + strategy: |
| 243 | + matrix: |
| 244 | + os: ['ubuntu-latest', 'windows-latest'] |
| 245 | + # IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version. |
| 246 | + # - PHPCS will run without errors on PHP 7.0 - 7.2 on any version. |
| 247 | + # - PHP 7.3 needs PHPCS 3.3.1+ to run without errors. |
| 248 | + # - PHP 7.4 needs PHPCS 3.5.0+ to run without errors. |
| 249 | + # - PHP 8.0 needs PHPCS 3.5.7+ to run without errors. |
| 250 | + # - PHP 8.1 needs PHPCS 3.6.1+ to run without errors. |
| 251 | + # - PHP 8.2 needs PHPCS 3.6.1+ to run without errors. |
| 252 | + # - PHP 8.3 needs PHPCS 3.8.0+ to run without errors (though the errors don't affect this package). |
| 253 | + # - PHP 8.4 needs PHPCS 3.8.0+ to run without errors (officially 3.11.0, but 3.8.0 will work fine). |
| 254 | + php: ['7.0', '7.1', '7.2'] |
| 255 | + phpcs_version: ['3.1.0', 'dev-master'] |
| 256 | + |
| 257 | + include: |
| 258 | + # Complete the matrix, while preventing issues with PHPCS versions incompatible with certain PHP versions. |
| 259 | + - os: 'ubuntu-latest' |
| 260 | + php: '7.3' |
| 261 | + phpcs_version: 'dev-master' |
| 262 | + - os: 'windows-latest' |
| 263 | + php: '7.3' |
| 264 | + phpcs_version: 'dev-master' |
| 265 | + - os: 'ubuntu-latest' |
| 266 | + php: '7.3' |
| 267 | + phpcs_version: '3.3.1' |
| 268 | + - os: 'windows-latest' |
| 269 | + php: '7.3' |
| 270 | + phpcs_version: '3.3.1' |
| 271 | + |
| 272 | + - os: 'ubuntu-latest' |
| 273 | + php: '7.4' |
| 274 | + phpcs_version: 'dev-master' |
| 275 | + - os: 'windows-latest' |
| 276 | + php: '7.4' |
| 277 | + phpcs_version: 'dev-master' |
| 278 | + - os: 'ubuntu-latest' |
| 279 | + php: '7.4' |
| 280 | + phpcs_version: '3.5.0' |
| 281 | + - os: 'windows-latest' |
| 282 | + php: '7.4' |
| 283 | + phpcs_version: '3.5.0' |
| 284 | + |
| 285 | + - os: 'ubuntu-latest' |
| 286 | + php: '8.0' |
| 287 | + phpcs_version: 'dev-master' |
| 288 | + - os: 'windows-latest' |
| 289 | + php: '8.0' |
| 290 | + phpcs_version: 'dev-master' |
| 291 | + - os: 'ubuntu-latest' |
| 292 | + php: '8.0' |
| 293 | + phpcs_version: '3.5.7' |
| 294 | + - os: 'windows-latest' |
| 295 | + php: '8.0' |
| 296 | + phpcs_version: '3.5.7' |
| 297 | + |
| 298 | + - os: 'ubuntu-latest' |
| 299 | + php: '8.1' |
| 300 | + phpcs_version: 'dev-master' |
| 301 | + - os: 'windows-latest' |
| 302 | + php: '8.1' |
| 303 | + phpcs_version: 'dev-master' |
| 304 | + - os: 'ubuntu-latest' |
| 305 | + php: '8.1' |
| 306 | + phpcs_version: '3.6.1' |
| 307 | + - os: 'windows-latest' |
| 308 | + php: '8.1' |
| 309 | + phpcs_version: '3.6.1' |
| 310 | + |
| 311 | + - os: 'ubuntu-latest' |
| 312 | + php: '8.2' |
| 313 | + phpcs_version: 'dev-master' |
| 314 | + - os: 'windows-latest' |
| 315 | + php: '8.2' |
| 316 | + phpcs_version: 'dev-master' |
| 317 | + - os: 'ubuntu-latest' |
| 318 | + php: '8.2' |
| 319 | + phpcs_version: '3.6.1' |
| 320 | + - os: 'windows-latest' |
| 321 | + php: '8.2' |
| 322 | + phpcs_version: '3.6.1' |
| 323 | + |
| 324 | + - os: 'ubuntu-latest' |
| 325 | + php: '8.3' |
| 326 | + phpcs_version: 'dev-master' |
| 327 | + - os: 'windows-latest' |
| 328 | + php: '8.3' |
| 329 | + phpcs_version: 'dev-master' |
| 330 | + - os: 'ubuntu-latest' |
| 331 | + php: '8.3' |
| 332 | + phpcs_version: '3.8.0' |
| 333 | + - os: 'windows-latest' |
| 334 | + php: '8.3' |
| 335 | + phpcs_version: '3.8.0' |
| 336 | + |
| 337 | + - os: 'ubuntu-latest' |
| 338 | + php: '8.4' |
| 339 | + phpcs_version: 'dev-master' |
| 340 | + - os: 'windows-latest' |
| 341 | + php: '8.4' |
| 342 | + phpcs_version: 'dev-master' |
| 343 | + - os: 'ubuntu-latest' |
| 344 | + php: '8.4' |
| 345 | + phpcs_version: '3.8.0' |
| 346 | + - os: 'windows-latest' |
| 347 | + php: '8.4' |
| 348 | + phpcs_version: '3.8.0' |
| 349 | + |
| 350 | + # Experimental builds. These are allowed to fail. |
| 351 | + - os: 'ubuntu-latest' |
| 352 | + php: '7.4' |
| 353 | + phpcs_version: '4.0.x-dev' |
| 354 | + |
| 355 | + - os: 'ubuntu-latest' |
| 356 | + php: '8.5' # Nightly. |
| 357 | + phpcs_version: 'dev-master' |
| 358 | + |
| 359 | + name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} (${{ matrix.os == 'windows-latest' && 'Win' || 'Linux' }})" |
| 360 | + |
| 361 | + continue-on-error: ${{ matrix.php == '8.5' || matrix.phpcs_version == '4.0.x-dev' }} |
| 362 | + |
| 363 | + steps: |
| 364 | + - name: Prepare git to leave line endings alone |
| 365 | + run: git config --global core.autocrlf input |
| 366 | + |
| 367 | + - name: Checkout code |
| 368 | + uses: actions/checkout@v4 |
| 369 | + |
| 370 | + - name: Setup ini config |
| 371 | + id: set_ini |
| 372 | + shell: bash |
| 373 | + run: | |
| 374 | + # On stable PHPCS versions, allow for PHP deprecation notices. |
| 375 | + # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. |
| 376 | + if [[ "${{ matrix.phpcs_version }}" != "dev-master" && "${{ matrix.phpcs_version }}" != "4.0.x-dev" ]]; then |
| 377 | + echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> "$GITHUB_OUTPUT" |
| 378 | + else |
| 379 | + echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT" |
| 380 | + fi |
| 381 | +
|
| 382 | + - name: Install PHP |
| 383 | + uses: shivammathur/setup-php@v2 |
| 384 | + with: |
| 385 | + php-version: ${{ matrix.php }} |
| 386 | + ini-values: ${{ steps.set_ini.outputs.PHP_INI }} |
| 387 | + coverage: none |
| 388 | + |
| 389 | + - name: 'Composer: adjust dependencies' |
| 390 | + run: | |
| 391 | + # Set the PHPCS version to be used in the tests. |
| 392 | + composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-scripts --no-interaction |
| 393 | + # Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs. |
| 394 | + composer remove --no-update --dev phpcsstandards/phpcsdevcs --no-scripts --no-interaction |
| 395 | +
|
| 396 | + # Install dependencies and handle caching in one go. |
| 397 | + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer |
| 398 | + - name: Install Composer dependencies |
| 399 | + uses: "ramsey/composer-install@v3" |
| 400 | + with: |
| 401 | + composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }} |
| 402 | + # Bust the cache at least once a month - output format: YYYY-MM. |
| 403 | + custom-cache-suffix: $(date -u "+%Y-%m") |
| 404 | + |
| 405 | + - name: Grab PHPUnit version |
| 406 | + id: phpunit_version |
| 407 | + shell: bash |
| 408 | + # yamllint disable rule:line-length |
| 409 | + run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT" |
| 410 | + # yamllint enable rule:line-length |
| 411 | + |
| 412 | + - name: Determine PHPUnit composer script to use |
| 413 | + id: phpunit_script |
| 414 | + shell: bash |
| 415 | + run: | |
| 416 | + if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then |
| 417 | + echo 'SUFFIX=' >> "$GITHUB_OUTPUT" |
| 418 | + elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then |
| 419 | + echo 'SUFFIX=' >> "$GITHUB_OUTPUT" |
| 420 | + else |
| 421 | + echo 'SUFFIX=-lte9' >> "$GITHUB_OUTPUT" |
| 422 | + fi |
| 423 | +
|
| 424 | + - name: Run the unit tests for the DocCodeExamples script |
| 425 | + run: composer test-doc-code-examples${{ steps.phpunit_script.outputs.SUFFIX }} |
0 commit comments