Skip to content

Commit

Permalink
Merge pull request #705 from Automattic/feature/ci-various-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored Dec 24, 2021
2 parents 8808483 + d24fe22 commit e34dae9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 26 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
31 changes: 22 additions & 9 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -62,29 +70,34 @@ 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

- name: Lint against parse errors
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
50 changes: 35 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit e34dae9

Please sign in to comment.