Skip to content

Commit e900d13

Browse files
authored
Merge pull request #2417 from WordPress/feature/ghactions-improve-workflows
2 parents 5f0c8a7 + 01c27cb commit e900d13

3 files changed

Lines changed: 93 additions & 52 deletions

File tree

.github/workflows/basic-qa.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ concurrency:
1212
group: ${{ github.workflow }}-${{ github.ref }}
1313
cancel-in-progress: true
1414

15+
env:
16+
PHPCS_DEV: 'dev-master'
17+
UTILS_DEV: 'dev-develop'
18+
EXTRA_DEV: 'dev-develop'
19+
1520
jobs:
1621
# Check code style of sniffs, rulesets and XML documentation.
1722
# Check that all sniffs are feature complete.
@@ -37,9 +42,13 @@ jobs:
3742
- name: Validate the composer.json file
3843
run: composer validate --no-check-all --strict
3944

40-
# Using PHPCS `master` as an early detection system for bugs upstream.
41-
- name: Set PHPCS version
42-
run: composer require squizlabs/php_codesniffer:"dev-master" --no-update --no-scripts --no-interaction
45+
# Using dev versions of the dependencies as an early detection system for bugs upstream.
46+
- name: "Composer: set PHPCS dependencies (dev)"
47+
run: >
48+
composer require --no-update --no-scripts --no-interaction
49+
squizlabs/php_codesniffer:"${{ env.PHPCS_DEV }}"
50+
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
51+
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
4352
4453
- name: Install Composer dependencies
4554
uses: ramsey/composer-install@v2
@@ -93,15 +102,15 @@ jobs:
93102

94103
# Makes sure the rulesets don't throw unexpected errors or warnings.
95104
# This workflow needs to be run against a high PHP version to prevent triggering the syntax error check.
96-
# It also needs to be run against all PHPCS versions WPCS is tested against.
105+
# It also needs to be run against all dependency versions WPCS is tested against.
97106
ruleset-tests:
98107
runs-on: ubuntu-latest
99108
strategy:
100109
matrix:
101110
php: [ 'latest' ]
102-
phpcs_version: [ 'lowest', 'dev-master' ]
111+
dependencies: [ 'lowest', 'stable', 'dev' ]
103112

104-
name: "Ruleset test: PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}"
113+
name: "Ruleset test: PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}"
105114

106115
steps:
107116
- name: Checkout repository
@@ -115,9 +124,13 @@ jobs:
115124
ini-values: error_reporting = E_ALL & ~E_DEPRECATED
116125
coverage: none
117126

118-
- name: "Set PHPCS version (master)"
119-
if: ${{ matrix.phpcs_version != 'lowest' }}
120-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
127+
- name: "Composer: set PHPCS dependencies for tests (dev)"
128+
if: ${{ matrix.dependencies == 'dev' }}
129+
run: >
130+
composer require --no-update --no-scripts --no-interaction
131+
squizlabs/php_codesniffer:"${{ env.PHPCS_DEV }}"
132+
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
133+
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
121134
122135
- name: Install Composer dependencies
123136
uses: ramsey/composer-install@v2
@@ -126,8 +139,13 @@ jobs:
126139
# Bust the cache at least once a month - output format: YYYY-MM.
127140
custom-cache-suffix: $(date -u "+%Y-%m")
128141

129-
- name: "Set PHPCS version (lowest)"
130-
run: composer update squizlabs/php_codesniffer --prefer-lowest --no-scripts --no-interaction
142+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
143+
if: ${{ matrix.dependencies == 'lowest' }}
144+
run: >
145+
composer update --prefer-lowest --no-scripts --no-interaction
146+
squizlabs/php_codesniffer
147+
phpcsstandards/phpcsutils
148+
phpcsstandards/phpcsextra
131149
132150
- name: Test the WordPress-Core ruleset
133151
run: $(pwd)/vendor/bin/phpcs -ps ./Tests/RulesetCheck/class-ruleset-test.inc --standard=WordPress-Core
@@ -150,8 +168,9 @@ jobs:
150168
# Test for fixer conflicts by running the auto-fixers of the complete WPCS over the test case files.
151169
# This is not an exhaustive test, but should give an early indication for typical fixer conflicts.
152170
# If only fixable errors are found, the exit code will be 1, which can be interpreted as success.
171+
# This check is only run against "dev" as conflicts can not be fixed for already released versions.
153172
- name: Test for fixer conflicts (fixes expected)
154-
if: ${{ matrix.phpcs_version == 'dev-master' }}
173+
if: ${{ matrix.dependencies == 'dev' }}
155174
id: phpcbf
156175
continue-on-error: true
157176
run: |

.github/workflows/quicktest.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,39 @@ jobs:
2424
strategy:
2525
matrix:
2626
php: [ '5.4', 'latest' ]
27-
phpcs_version: [ 'lowest', 'dev-master' ]
27+
dependencies: [ 'lowest', 'stable' ]
2828

29-
name: QTest - PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}
29+
name: QTest - PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}
3030

3131
steps:
3232
- name: Checkout repository
3333
uses: actions/checkout@v4
3434

35-
# On stable PHPCS versions, allow for PHP deprecation notices.
36-
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
37-
- name: Setup ini config
38-
id: set_ini
39-
run: |
40-
if [ "${{ matrix.phpcs_version }}" != "dev-master" ]; then
41-
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
42-
else
43-
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
44-
fi
45-
4635
- name: Set up PHP
4736
uses: shivammathur/setup-php@v2
4837
with:
4938
php-version: ${{ matrix.php }}
50-
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
39+
# With stable PHPCS dependencies, allow for PHP deprecation notices.
40+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
41+
ini-values: error_reporting=-1, display_errors=On
5142
coverage: ${{ github.ref_name == 'develop' && 'xdebug' || 'none' }}
5243

53-
- name: "Set PHPCS version (master)"
54-
if: ${{ matrix.phpcs_version != 'lowest' }}
55-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
56-
5744
- name: Install Composer dependencies
5845
uses: ramsey/composer-install@v2
5946
with:
6047
# Bust the cache at least once a month - output format: YYYY-MM.
6148
custom-cache-suffix: $(date -u "+%Y-%m")
6249

63-
- name: "Set PHPCS version (lowest)"
64-
if: ${{ matrix.phpcs_version == 'lowest' }}
65-
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction
50+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
51+
if: ${{ matrix.dependencies == 'lowest' }}
52+
run: >
53+
composer update --prefer-lowest --no-scripts --no-interaction
54+
squizlabs/php_codesniffer
55+
phpcsstandards/phpcsutils
56+
phpcsstandards/phpcsextra
6657
6758
- name: Lint PHP files against parse errors
68-
if: ${{ matrix.phpcs_version == 'dev-master' }}
59+
if: ${{ matrix.dependencies == 'stable' }}
6960
run: composer lint -- --checkstyle
7061

7162
- name: Run the unit tests without code coverage

.github/workflows/unit-tests.yml

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,83 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
env:
18+
PHPCS_DEV: 'dev-master'
19+
UTILS_DEV: 'dev-develop'
20+
EXTRA_DEV: 'dev-develop'
21+
1722
jobs:
1823
# Runs the test suite against all supported branches and combinations.
19-
# Linting is performed on all jobs run against PHPCS `dev-master`.
24+
# Linting is performed on all jobs run with dependencies `stable`.
2025
test:
2126
runs-on: ubuntu-latest
2227
strategy:
2328
matrix:
2429
php: [ '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.4' ]
25-
phpcs_version: [ 'lowest', 'dev-master' ]
30+
dependencies: [ 'lowest', 'stable' ]
2631
extensions: [ '' ]
2732
coverage: [false]
2833

2934
include:
3035
- php: '7.4'
31-
phpcs_version: 'dev-master'
36+
dependencies: 'stable'
3237
extensions: ':mbstring' # = Disable Mbstring.
3338
coverage: true # Make sure coverage is recorded for this too.
3439

3540
# Run code coverage builds against high/low PHP and high/low PHPCS.
3641
- php: '5.4'
37-
phpcs_version: 'dev-master'
42+
dependencies: 'stable'
3843
extensions: ''
3944
coverage: true
4045
- php: '5.4'
41-
phpcs_version: 'lowest'
46+
dependencies: 'lowest'
4247
extensions: ''
4348
coverage: true
4449
- php: '8.3'
45-
phpcs_version: 'dev-master'
50+
dependencies: 'stable'
4651
extensions: ''
4752
coverage: true
4853
- php: '8.3'
49-
phpcs_version: 'lowest'
54+
dependencies: 'lowest'
5055
extensions: ''
5156
coverage: true
5257

58+
# Test against dev versions of all dependencies with select PHP versions for early detection of issues.
59+
- php: '5.4'
60+
dependencies: 'dev'
61+
extensions: ''
62+
coverage: false
63+
- php: '7.0'
64+
dependencies: 'dev'
65+
extensions: ''
66+
coverage: false
67+
- php: '7.4'
68+
dependencies: 'dev'
69+
extensions: ''
70+
coverage: false
71+
- php: '8.3'
72+
dependencies: 'dev'
73+
extensions: ''
74+
coverage: false
75+
5376
# Add extra build to test against PHPCS 4.
5477
#- php: '7.4'
55-
# phpcs_version: '4.0.x-dev as 3.9.99'
78+
# dependencies: '4.0.x-dev as 3.9.99'
5679

57-
name: PHP ${{ matrix.php }} on PHPCS ${{ matrix.phpcs_version }}
80+
name: PHP ${{ matrix.php }} on PHPCS ${{ matrix.dependencies }}
5881

5982
continue-on-error: ${{ matrix.php == '8.4' }}
6083

6184
steps:
6285
- name: Checkout repository
6386
uses: actions/checkout@v4
6487

65-
# On stable PHPCS versions, allow for PHP deprecation notices.
88+
# With stable PHPCS dependencies, allow for PHP deprecation notices.
6689
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
6790
- name: Setup ini config
6891
id: set_ini
6992
run: |
70-
if [ "${{ matrix.phpcs_version }}" != "dev-master" ]; then
93+
if [ "${{ matrix.dependencies }}" != "dev" ]; then
7194
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
7295
else
7396
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
@@ -81,22 +104,30 @@ jobs:
81104
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
82105
tools: cs2pr
83106

84-
- name: "Set PHPCS version (master)"
85-
if: ${{ matrix.phpcs_version != 'lowest' }}
86-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
107+
- name: "Composer: set PHPCS dependencies for tests (dev)"
108+
if: ${{ matrix.dependencies == 'dev' }}
109+
run: >
110+
composer require --no-update --no-scripts --no-interaction
111+
squizlabs/php_codesniffer:"${{ env.PHPCS_DEV }}"
112+
phpcsstandards/phpcsutils:"${{ env.UTILS_DEV }}"
113+
phpcsstandards/phpcsextra:"${{ env.EXTRA_DEV }}"
87114
88115
- name: Install Composer dependencies
89116
uses: ramsey/composer-install@v2
90117
with:
91118
# Bust the cache at least once a month - output format: YYYY-MM.
92119
custom-cache-suffix: $(date -u "+%Y-%m")
93120

94-
- name: "Set PHPCS version (lowest)"
95-
if: ${{ matrix.phpcs_version == 'lowest' }}
96-
run: composer update squizlabs/php_codesniffer --prefer-lowest --ignore-platform-req=php+ --no-scripts --no-interaction
121+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
122+
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
123+
run: >
124+
composer update --prefer-lowest --no-scripts --no-interaction
125+
squizlabs/php_codesniffer
126+
phpcsstandards/phpcsutils
127+
phpcsstandards/phpcsextra
97128
98129
- name: Lint PHP files against parse errors
99-
if: ${{ matrix.phpcs_version == 'dev-master' }}
130+
if: ${{ matrix.dependencies == 'stable' }}
100131
run: composer lint -- --checkstyle | cs2pr
101132

102133
- name: Run the unit tests without code coverage

0 commit comments

Comments
 (0)