Skip to content

Commit

Permalink
GH Actions: tweak the way the PHPCS versions are set
Browse files Browse the repository at this point in the history
As things were, whenever the minimum PHPCS version would be changed, the branch protection settings for both the `master` and the `develop` branch would need to be updated and all "required builds" referencing the old PHPCS version would need to be removed, while new "required builds" would need to be added referencing the new minimum PHPCS version.

This was a fiddly process and time-consuming.

The change proposed in this commit takes advantage of the Composer `--prefer-lowest` setting to archive the same without a hard-coded PHPCS version in the build name, which means that once the branch protection settings have been updated for this PR, they shouldn't need updating anymore for future PHPCS version bumps.
  • Loading branch information
jrfnl committed Mar 24, 2023
1 parent 6e78de9 commit f21d06f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/basic-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
strategy:
matrix:
php: [ 'latest' ]
phpcs_version: [ '3.7.1', 'dev-master' ]
phpcs_version: [ 'lowest', 'dev-master' ]

name: "Ruleset test: PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}"

Expand All @@ -114,7 +114,8 @@ jobs:
ini-values: error_reporting = E_ALL & ~E_DEPRECATED
coverage: none

- name: Set PHPCS version
- name: "Set PHPCS version (master)"
if: ${{ matrix.phpcs_version == 'dev-master' }}
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: Install Composer dependencies
Expand All @@ -124,6 +125,10 @@ jobs:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Set PHPCS version (lowest)"
if: ${{ matrix.phpcs_version == 'lowest' }}
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction

- name: Test the WordPress-Core ruleset
run: $(pwd)/vendor/bin/phpcs -ps ./Tests/RulesetCheck/class-ruleset-test.inc --standard=WordPress-Core

Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
php: [ '5.4', 'latest' ]
phpcs_version: [ '3.7.1', 'dev-master' ]
phpcs_version: [ 'lowest', 'dev-master' ]

name: QTest - PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}

Expand All @@ -50,7 +50,8 @@ jobs:
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none

- name: Set PHPCS version
- name: "Set PHPCS version (master)"
if: ${{ matrix.phpcs_version == 'dev-master' }}
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: Install Composer dependencies (PHP < 8.0 )
Expand All @@ -67,6 +68,10 @@ jobs:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Set PHPCS version (lowest)"
if: ${{ matrix.phpcs_version == 'lowest' }}
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction

- name: Lint PHP files against parse errors
if: ${{ matrix.phpcs_version == 'dev-master' }}
run: composer lint -- --checkstyle
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
php: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
phpcs_version: [ '3.7.1', 'dev-master' ]
phpcs_version: [ 'lowest', 'dev-master' ]
extensions: [ '' ]

include:
Expand Down Expand Up @@ -61,7 +61,8 @@ jobs:
coverage: none
tools: cs2pr

- name: Set PHPCS version
- name: "Set PHPCS version (master)"
if: ${{ matrix.phpcs_version == 'dev-master' }}
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction

- name: Install Composer dependencies (PHP < 8.0 )
Expand All @@ -78,6 +79,10 @@ jobs:
composer-options: --ignore-platform-req=php+
custom-cache-suffix: $(date -u "+%Y-%m")

- name: "Set PHPCS version (lowest)"
if: ${{ matrix.phpcs_version == 'lowest' }}
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction

- name: Lint PHP files against parse errors
if: ${{ matrix.phpcs_version == 'dev-master' }}
run: composer lint -- --checkstyle | cs2pr
Expand Down

0 comments on commit f21d06f

Please sign in to comment.