diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index dc0e0006..389a1146 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: checkcs: name: 'Basic CS and QA checks' @@ -40,12 +46,12 @@ jobs: - name: 'Composer: adjust dependencies' # Using PHPCS `master` as an early detection system for bugs upstream. - run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" + run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" - name: 'Validate XML against schema and check code style' run: ./bin/xml-lint diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index b0b332ad..835e69a8 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: #### QUICK TEST STAGE #### # This is a much quicker test which only runs the unit tests and linting against the low/high @@ -31,26 +37,28 @@ jobs: phpcs_version: 'dev-master' wpcs_version: '2.3.*' - php: 'latest' - # PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0. - phpcs_version: '3.5.7' + # PHPCS 3.6.1 is the lowest version of PHPCS which supports PHP 8.1. + phpcs_version: '3.6.1' wpcs_version: '2.3.*' name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}" - steps: - name: Checkout code uses: actions/checkout@v2 # On stable PHPCS versions, allow for PHP deprecation notices. # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. + # Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+. - name: Setup ini config id: set_ini run: | if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' + elif [[ "${{ matrix.php }}" == "latest" ]]; then + echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' else - echo '::set-output name=PHP_INI::error_reporting=E_ALL' + echo '::set-output name=PHP_INI::error_reporting=-1' fi - name: Install PHP @@ -62,20 +70,20 @@ jobs: - name: 'Composer: set PHPCS and WPCS versions for tests' run: | - composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" - composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" + composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-interaction + composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - normal if: ${{ startsWith( matrix.php, '8' ) == false && matrix.php != 'latest' }} - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" # PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform # requirements to get PHPUnit 7.x to install on nightly. - name: Install Composer dependencies - with ignore platform if: ${{ startsWith( matrix.php, '8' ) || matrix.php == 'latest' }} - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" with: composer-options: --ignore-platform-reqs @@ -83,8 +91,13 @@ jobs: if: matrix.phpcs_version == 'dev-master' run: ./bin/php-lint - - name: Run the unit tests + - name: Run the unit tests - PHP 5.4 - 8.0 + if: matrix.php != 'latest' run: ./bin/unit-tests + - name: Run the unit tests - PHP > 8.1 + if: matrix.php == 'latest' + run: vendor/bin/phpunit --filter WordPressVIPMinimum ./vendor/squizlabs/php_codesniffer/tests/AllTests.php --no-coverage --no-configuration --bootstrap=./tests/bootstrap.php --dont-report-useless-tests + - name: Run the ruleset tests run: ./bin/ruleset-tests diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3353e971..2d1add55 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: #### PHP LINT STAGE #### # Linting against high/low PHP versions should catch everything. @@ -21,15 +27,10 @@ jobs: strategy: matrix: - php: ['5.4', 'latest'] - experimental: [false] - - include: - - php: '8.1' - experimental: true + php: ['5.4', 'latest', '8.2'] name: "Lint: PHP ${{ matrix.php }}" - continue-on-error: ${{ matrix.experimental }} + continue-on-error: ${{ matrix.php == '8.2' }} steps: - name: Checkout code @@ -43,7 +44,7 @@ jobs: tools: cs2pr - name: Install Composer dependencies - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" - name: Lint against parse errors run: ./bin/php-lint --checkstyle | cs2pr @@ -83,8 +84,19 @@ jobs: wpcs_version: '2.3.*' experimental: false + # Complete the matrix by adding PHP 8.1, but only test against compatible PHPCS versions. + - php: '8.1' + phpcs_version: 'dev-master' + wpcs_version: '2.3.*' + experimental: false + - php: '8.1' + # PHPCS 3.6.1 is the lowest version of PHPCS which supports PHP 8.1. + phpcs_version: '3.6.1' + wpcs_version: '2.3.*' + experimental: false + # Experimental builds. These are allowed to fail. - #- php: '8.1' + #- php: '8.2' # phpcs_version: 'dev-master' # wpcs_version: '2.3.*' # experimental: true @@ -99,13 +111,16 @@ jobs: # On stable PHPCS versions, allow for PHP deprecation notices. # Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore. + # Note: the "elif" condition is temporary and should be removed once VIPCS updates to WPCS 3.0+. - name: Setup ini config id: set_ini run: | if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' + elif [[ "${{ matrix.php }}" == "8.1" ]]; then + echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED' else - echo '::set-output name=PHP_INI::error_reporting=E_ALL' + echo '::set-output name=PHP_INI::error_reporting=-1' fi - name: Install PHP @@ -117,25 +132,30 @@ jobs: - name: 'Composer: set PHPCS and WPCS versions for tests' run: | - composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" - composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" + composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-interaction + composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - normal if: ${{ startsWith( matrix.php, '8' ) == false }} - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" # PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform # requirements to get PHPUnit 7.x to install on nightly. - name: Install Composer dependencies - with ignore platform if: ${{ startsWith( matrix.php, '8' ) }} - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v2" with: composer-options: --ignore-platform-reqs - - name: Run the unit tests + - name: Run the unit tests - PHP 5.4 - 8.0 + if: matrix.php < '8.1' run: ./bin/unit-tests + - name: Run the unit tests - PHP > 8.1 + if: matrix.php >= '8.1' + run: vendor/bin/phpunit --filter WordPressVIPMinimum ./vendor/squizlabs/php_codesniffer/tests/AllTests.php --no-coverage --no-configuration --bootstrap=./tests/bootstrap.php --dont-report-useless-tests + - name: Run the ruleset tests run: ./bin/ruleset-tests diff --git a/composer.json b/composer.json index 5a7ee54b..8cedf46c 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,11 @@ "phpcsstandards/phpcsdevtools": "^1.0", "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, "scripts": { "install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run", "ruleset": "bin/ruleset-tests",