Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH Actions: tweak the way the PHPCS/WPCS versions are set #787

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,30 @@ jobs:
matrix:
include:
- php: '5.4'
phpcs_version: 'dev-master'
wpcs_version: '3.0.*'
dependencies: 'stable'
- php: '5.4'
phpcs_version: '3.7.2'
wpcs_version: '3.0.*'
dependencies: 'lowest'

- php: 'latest'
phpcs_version: 'dev-master'
wpcs_version: '3.0.*'
dependencies: 'stable'
- php: 'latest'
phpcs_version: '3.7.2'
wpcs_version: '3.0.*'
dependencies: 'lowest'

name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
name: "QTest${{ matrix.dependencies == 'stable' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.dependencies }}"

steps:
- name: Checkout code
uses: actions/checkout@v3

# 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.
- name: Setup ini config
id: set_ini
run: |
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
else
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
fi

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
# With stable PHPCS dependencies, allow for PHP deprecation notices.
# Unit tests shouldn't fail on those for stable releases where those issues won't get fixed anymore.
ini-values: error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On
coverage: none

- name: 'Composer: set PHPCS version for tests'
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: 'Composer: set WPCS version for tests'
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
Expand All @@ -88,11 +69,31 @@ jobs:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: Display PHPCS installed standards
run: ./vendor/bin/phpcs -i

- name: Lint against parse errors
if: matrix.phpcs_version == 'dev-master'
if: matrix.dependencies == 'stable'
run: ./bin/php-lint

- name: Run the unit tests
Expand Down
66 changes: 48 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,47 @@ jobs:
strategy:
# Keys:
# - php: The PHP versions to test against.
# - phpcs_version: The PHPCS versions to test against.
# - dependencies: The PHPCS dependencies versions to test against.
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors, and we require a higher minimum version.
# - PHP 8.1 needs PHPCS 3.6.1+ to run without errors, but works best with 3.7.1+, and we require at least this minimum version.
# - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions
# would be supported. As, at this time, only the latest stable release of WPCS is supported,
# no additional versions are included in the array.
matrix:
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
phpcs_version: ['3.7.2', 'dev-master']
wpcs_version: ['3.0.*']
dependencies: ['lowest', 'stable']

include:
# Test against dev versions of all dependencies with select PHP versions for early detection of issues.
- php: '5.4'
dependencies: 'dev'
- php: '7.0'
dependencies: 'dev'
- php: '7.4'
dependencies: 'dev'
- php: '8.2'
dependencies: 'dev'

# Test against upcoming PHP version.
- php: '8.3'
phpcs_version: 'dev-master'
wpcs_version: '3.0.*'
dependencies: 'dev'

name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}"
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.dependencies }}"

continue-on-error: ${{ matrix.php == '8.3' }}

steps:
- name: Checkout code
uses: actions/checkout@v3

# On stable PHPCS versions, allow for PHP deprecation notices.
# With stable PHPCS dependencies, 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.
- name: Setup ini config
id: set_ini
run: |
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
if [[ "${{ matrix.dependencies }}" != "dev" ]]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
else
echo 'PHP_INI=error_reporting=-1' >> $GITHUB_OUTPUT
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
fi

- name: Install PHP
Expand All @@ -106,11 +112,15 @@ jobs:
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none

- name: 'Composer: set PHPCS version for tests'
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: 'Composer: set WPCS version for tests'
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction
- name: "Composer: set PHPCS dependencies for tests (dev)"
if: ${{ matrix.dependencies == 'dev' }}
run: >
composer require --no-update --no-scripts --no-interaction
squizlabs/php_codesniffer:"dev-master"
phpcsstandards/phpcsutils:"dev-develop"
phpcsstandards/phpcsextra:"dev-develop"
sirbrillig/phpcs-variable-analysis:"2.x"
wp-coding-standards/wpcs:"dev-develop"

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
Expand All @@ -130,6 +140,26 @@ jobs:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
run: >
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
squizlabs/php_codesniffer
phpcsstandards/phpcsutils
phpcsstandards/phpcsextra
sirbrillig/phpcs-variable-analysis
wp-coding-standards/wpcs

- name: Run the unit tests
run: ./bin/unit-tests

Expand Down