Switch to PHPCSStandards/PHP_CodeSniffer #89
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
# Run on pushes to `master` and on all pull requests. | |
push: | |
branches: | |
- master | |
pull_request: | |
# Also run this workflow on day 15 of every month as the repo isn't that active. | |
schedule: | |
- cron: '0 0 15 * *' | |
# Allow manually triggering the workflow. | |
workflow_dispatch: | |
jobs: | |
xmllint: | |
name: 'Check XML' | |
runs-on: ubuntu-latest | |
env: | |
XMLLINT_INDENT: ' ' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 'latest' | |
coverage: none | |
# Install dependencies to make sure the PHPCS XSD file is available. | |
- name: Install dependencies | |
run: composer install --no-dev --no-interaction --no-progress | |
- name: Setup xmllint | |
run: | | |
sudo apt-get update | |
sudo apt-get install --no-install-recommends -y libxml2-utils | |
# Show violations inline in the file diff. | |
# @link https://github.com/marketplace/actions/xmllint-problem-matcher | |
- name: Enable showing XML issues inline | |
uses: korelstar/xmllint-problem-matcher@v1 | |
# Validate the xml file. | |
# @link http://xmlsoft.org/xmllint.html | |
- name: Validate against schema | |
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml | |
# Check the code-style consistency of the xml file. | |
- name: Check code style | |
run: | | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP54/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP54/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP55/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP55/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP70/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP70/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP71/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP71/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP73/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP73/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP74/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP74/ruleset.xml") | |
diff -B ./PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml <(xmllint --format "./PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml") | |
test: | |
needs: xmllint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php: ['5.4', 'latest'] | |
phpcompat: ['stable'] | |
experimental: [false] | |
include: | |
- php: '7.4' | |
phpcompat: 'dev-develop as 9.99.99' | |
experimental: true | |
name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}" | |
continue-on-error: ${{ matrix.experimental }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: error_reporting=E_ALL, display_errors=On | |
coverage: none | |
- name: Conditionally require specific versions of the polyfills | |
if: ${{ matrix.php == '5.4' }} | |
run: | | |
# Remove the PHP 8 polyfill on PHP < 7 as the minimum requirement is PHP 7.1 and the autoloading | |
# of the polyfill bootstrap file via Composer would generate a parse error, blocking the DealerDirect plugin | |
# from setting the installed_paths for PHPCS. | |
composer remove --dev symfony/polyfill-php80 --no-update --no-scripts --no-interaction | |
composer require --no-update symfony/polyfill-php72:"1.19" symfony/polyfill-php73:"1.19" symfony/polyfill-php74:"1.19" --no-interaction | |
- name: Conditionally update PHPCompatibility to develop version | |
if: ${{ matrix.phpcompat != 'stable' }} | |
run: | | |
composer config minimum-stability dev | |
composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" --no-interaction | |
- name: Install dependencies | |
run: composer install --no-interaction --no-progress | |
# Validate the composer.json file. | |
# @link https://getcomposer.org/doc/03-cli.md#validate | |
- name: Validate Composer installation | |
run: composer validate --no-check-all --strict | |
# Make sure that known polyfills don't trigger any errors. | |
- name: Test the rulesets | |
run: | | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP54Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP54 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP55Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP55 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP56Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP70Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP70 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP71Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP71 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP72Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP73Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP74Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 5.3- | |
- name: Test the PHP 8.0 ruleset | |
# The PHP 8.0 polyfill has a minimum PHP requirement of PHP 7.1. | |
if: ${{ matrix.php != '5.4' }} | |
run: | | |
vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP80Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP80 --runtime-set testVersion 7.1- | |
# Check that the rulesets don't throw unnecessary errors for the compat libraries themselves. | |
# Note: the polyfills for PHP 5.4 - 7.1 have been decoupled from the monorepo at version 1.19. | |
# and are no longer updated. | |
- name: Test running against the polyfills - polyfills 5.4-7.1 | |
run: | | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php54/ --standard=PHPCompatibilitySymfonyPolyfillPHP54 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php55/ --standard=PHPCompatibilitySymfonyPolyfillPHP55 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php56/ ./vendor/symfony/polyfill-util/ --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3- --ignore=*/polyfill-util/TestListener* | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php70/ --standard=PHPCompatibilitySymfonyPolyfillPHP70 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php71/ --standard=PHPCompatibilitySymfonyPolyfillPHP71 --runtime-set testVersion 5.3- | |
# The polyfills for PHP 7.2 and higher are compatible with PHP 5.3+ at version 1.19. | |
- name: Test running against the polyfills - polyfills 7.2- | |
if: ${{ matrix.php == '5.4' }} | |
run: | | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 5.3- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 5.3- | |
# The polyfills for PHP 7.2 and higher are compatible with PHP 7.1+ at version 1.20 and above. | |
- name: Test running against the polyfills - polyfills 7.2- | |
if: ${{ matrix.php != '5.4' }} | |
run: | | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 7.1- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 7.1- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 7.1- | |
vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php80/ --standard=PHPCompatibilitySymfonyPolyfillPHP80 --runtime-set testVersion 7.1- | |