Skip to content

Commit 92a8c82

Browse files
authored
Merge pull request #787 from Automattic/3.0/feature/ghactions-improve-matrix
2 parents 238ac94 + 944874d commit 92a8c82

File tree

2 files changed

+77
-46
lines changed

2 files changed

+77
-46
lines changed

.github/workflows/quicktest.yml

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,30 @@ jobs:
2727
matrix:
2828
include:
2929
- php: '5.4'
30-
phpcs_version: 'dev-master'
31-
wpcs_version: '3.0.*'
30+
dependencies: 'stable'
3231
- php: '5.4'
33-
phpcs_version: '3.7.2'
34-
wpcs_version: '3.0.*'
32+
dependencies: 'lowest'
3533

3634
- php: 'latest'
37-
phpcs_version: 'dev-master'
38-
wpcs_version: '3.0.*'
35+
dependencies: 'stable'
3936
- php: 'latest'
40-
phpcs_version: '3.7.2'
41-
wpcs_version: '3.0.*'
37+
dependencies: 'lowest'
4238

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

4541
steps:
4642
- name: Checkout code
4743
uses: actions/checkout@v3
4844

49-
# On stable PHPCS versions, allow for PHP deprecation notices.
50-
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
51-
- name: Setup ini config
52-
id: set_ini
53-
run: |
54-
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
55-
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
56-
else
57-
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
58-
fi
59-
6045
- name: Set up PHP
6146
uses: shivammathur/setup-php@v2
6247
with:
6348
php-version: ${{ matrix.php }}
64-
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
49+
# With stable PHPCS dependencies, allow for PHP deprecation notices.
50+
# Unit tests shouldn't fail on those for stable releases where those issues won't get fixed anymore.
51+
ini-values: error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On
6552
coverage: none
6653

67-
- name: 'Composer: set PHPCS version for tests'
68-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
69-
70-
- name: 'Composer: set WPCS version for tests'
71-
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction
72-
7354
# Install dependencies and handle caching in one go.
7455
# @link https://github.com/marketplace/actions/install-composer-dependencies
7556
- name: Install Composer dependencies - normal
@@ -88,11 +69,31 @@ jobs:
8869
composer-options: --ignore-platform-req=php+
8970
custom-cache-suffix: $(date -u "+%Y-%m")
9071

72+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
73+
if: ${{ matrix.php == '5.4' && matrix.dependencies == 'lowest' }}
74+
run: >
75+
composer update --prefer-lowest --no-scripts --no-interaction
76+
squizlabs/php_codesniffer
77+
phpcsstandards/phpcsutils
78+
phpcsstandards/phpcsextra
79+
sirbrillig/phpcs-variable-analysis
80+
wp-coding-standards/wpcs
81+
82+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
83+
if: ${{ matrix.php == 'latest' && matrix.dependencies == 'lowest' }}
84+
run: >
85+
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
86+
squizlabs/php_codesniffer
87+
phpcsstandards/phpcsutils
88+
phpcsstandards/phpcsextra
89+
sirbrillig/phpcs-variable-analysis
90+
wp-coding-standards/wpcs
91+
9192
- name: Display PHPCS installed standards
9293
run: ./vendor/bin/phpcs -i
9394

9495
- name: Lint against parse errors
95-
if: matrix.phpcs_version == 'dev-master'
96+
if: matrix.dependencies == 'stable'
9697
run: ./bin/php-lint
9798

9899
- name: Run the unit tests

.github/workflows/test.yml

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,41 +62,47 @@ jobs:
6262
strategy:
6363
# Keys:
6464
# - php: The PHP versions to test against.
65-
# - phpcs_version: The PHPCS versions to test against.
65+
# - dependencies: The PHPCS dependencies versions to test against.
6666
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
6767
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
6868
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors, and we require a higher minimum version.
6969
# - 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.
70-
# - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions
71-
# would be supported. As, at this time, only the latest stable release of WPCS is supported,
72-
# no additional versions are included in the array.
7370
matrix:
7471
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
75-
phpcs_version: ['3.7.2', 'dev-master']
76-
wpcs_version: ['3.0.*']
72+
dependencies: ['lowest', 'stable']
7773

7874
include:
75+
# Test against dev versions of all dependencies with select PHP versions for early detection of issues.
76+
- php: '5.4'
77+
dependencies: 'dev'
78+
- php: '7.0'
79+
dependencies: 'dev'
80+
- php: '7.4'
81+
dependencies: 'dev'
82+
- php: '8.2'
83+
dependencies: 'dev'
84+
85+
# Test against upcoming PHP version.
7986
- php: '8.3'
80-
phpcs_version: 'dev-master'
81-
wpcs_version: '3.0.*'
87+
dependencies: 'dev'
8288

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

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

8793
steps:
8894
- name: Checkout code
8995
uses: actions/checkout@v3
9096

91-
# On stable PHPCS versions, allow for PHP deprecation notices.
97+
# With stable PHPCS dependencies, allow for PHP deprecation notices.
9298
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
9399
- name: Setup ini config
94100
id: set_ini
95101
run: |
96-
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
97-
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED' >> $GITHUB_OUTPUT
102+
if [[ "${{ matrix.dependencies }}" != "dev" ]]; then
103+
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' >> $GITHUB_OUTPUT
98104
else
99-
echo 'PHP_INI=error_reporting=-1' >> $GITHUB_OUTPUT
105+
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> $GITHUB_OUTPUT
100106
fi
101107
102108
- name: Install PHP
@@ -106,11 +112,15 @@ jobs:
106112
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
107113
coverage: none
108114

109-
- name: 'Composer: set PHPCS version for tests'
110-
run: composer require squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-update --no-scripts --no-interaction
111-
112-
- name: 'Composer: set WPCS version for tests'
113-
run: composer require wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-update --no-scripts --no-interaction
115+
- name: "Composer: set PHPCS dependencies for tests (dev)"
116+
if: ${{ matrix.dependencies == 'dev' }}
117+
run: >
118+
composer require --no-update --no-scripts --no-interaction
119+
squizlabs/php_codesniffer:"dev-master"
120+
phpcsstandards/phpcsutils:"dev-develop"
121+
phpcsstandards/phpcsextra:"dev-develop"
122+
sirbrillig/phpcs-variable-analysis:"2.x"
123+
wp-coding-standards/wpcs:"dev-develop"
114124
115125
# Install dependencies and handle caching in one go.
116126
# @link https://github.com/marketplace/actions/install-composer-dependencies
@@ -130,6 +140,26 @@ jobs:
130140
composer-options: --ignore-platform-req=php+
131141
custom-cache-suffix: $(date -u "+%Y-%m")
132142

143+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest)"
144+
if: ${{ ! startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
145+
run: >
146+
composer update --prefer-lowest --no-scripts --no-interaction
147+
squizlabs/php_codesniffer
148+
phpcsstandards/phpcsutils
149+
phpcsstandards/phpcsextra
150+
sirbrillig/phpcs-variable-analysis
151+
wp-coding-standards/wpcs
152+
153+
- name: "Composer: downgrade PHPCS dependencies for tests (lowest) - with ignore platform"
154+
if: ${{ startsWith( matrix.php, '8' ) && matrix.dependencies == 'lowest' }}
155+
run: >
156+
composer update --prefer-lowest --no-scripts --no-interaction --ignore-platform-req=php+
157+
squizlabs/php_codesniffer
158+
phpcsstandards/phpcsutils
159+
phpcsstandards/phpcsextra
160+
sirbrillig/phpcs-variable-analysis
161+
wp-coding-standards/wpcs
162+
133163
- name: Run the unit tests
134164
run: ./bin/unit-tests
135165

0 commit comments

Comments
 (0)