Skip to content

Commit a4d57d0

Browse files
committed
GH Actions: split test jobs
With PHPCS 4.x around the corner, the matrix for the PHP/PHPCS combis will become more complex, making all inline conditions more complex too. Splitting the test jobs into two separate jobs, one where only the PHP version changes, one where both the PHP version + the PHPCS version changes, will allow for making the adjustments needed for PHPCS 4.x and still keep the jobs stable, readable and maintainable.
1 parent f18ade5 commit a4d57d0

File tree

2 files changed

+173
-91
lines changed

2 files changed

+173
-91
lines changed

.github/workflows/quicktest.yml

Lines changed: 73 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,15 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
#### QUICK TEST STAGE ####
19-
# This is a much quicker test which only runs the unit tests and linting against the low/high
20-
# supported PHP/PHPCS combinations.
21-
quicktest:
18+
# Run CI checks/tests which have no dependency on the PHPCS version used.
19+
quicktest-php:
2220
runs-on: ubuntu-latest
2321

2422
strategy:
2523
matrix:
2624
php: ['5.4', 'latest']
27-
phpcs_version: ['dev-master']
2825

29-
include:
30-
- php: '7.2'
31-
phpcs_version: '3.1.0'
32-
- php: '5.4'
33-
phpcs_version: '3.1.0'
34-
35-
name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
26+
name: "QTest + Lint: PHP ${{ matrix.php }}"
3627

3728
steps:
3829
- name: Checkout code
@@ -48,6 +39,76 @@ jobs:
4839
- name: Install xmllint
4940
run: sudo apt-get install --no-install-recommends -y libxml2-utils
5041

42+
- name: Install PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php }}
46+
ini-values: error_reporting=-1, display_errors=On
47+
coverage: none
48+
49+
# Install dependencies and handle caching in one go.
50+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
51+
- name: Install Composer dependencies
52+
uses: "ramsey/composer-install@v3"
53+
with:
54+
# Bust the cache at least once a month - output format: YYYY-MM.
55+
custom-cache-suffix: $(date -u "+%Y-%m")
56+
57+
- name: Lint against parse errors (PHP 7.2+)
58+
if: ${{ matrix.php >= '7.2' }}
59+
run: composer lint
60+
61+
- name: Lint against parse errors (PHP < 7.2)
62+
if: ${{ matrix.php < '7.2' }}
63+
run: composer lintlt72
64+
65+
# Check that any sniffs available are feature complete.
66+
# This acts as an integration test for the feature completeness script,
67+
# which is why it is run against various PHP versions.
68+
- name: Check for feature completeness
69+
run: composer check-complete
70+
71+
- name: Grab PHPUnit version
72+
id: phpunit_version
73+
# yamllint disable rule:line-length
74+
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
75+
# yamllint enable rule:line-length
76+
77+
- name: Determine PHPUnit composer script to use
78+
id: phpunit_script
79+
run: |
80+
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
81+
echo 'SUFFIX=' >> "$GITHUB_OUTPUT"
82+
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
83+
echo 'SUFFIX=' >> "$GITHUB_OUTPUT"
84+
else
85+
echo 'SUFFIX=-lte9' >> "$GITHUB_OUTPUT"
86+
fi
87+
88+
- name: Run the unit tests for the DevTools
89+
run: composer test-tools${{ steps.phpunit_script.outputs.SUFFIX }}
90+
91+
# Run CI checks/tests which have a dependency on the PHPCS version used.
92+
quicktest-phpcs:
93+
runs-on: ubuntu-latest
94+
95+
strategy:
96+
matrix:
97+
php: ['5.4', 'latest']
98+
phpcs_version: ['dev-master']
99+
100+
include:
101+
- php: '7.2'
102+
phpcs_version: '3.1.0'
103+
- php: '5.4'
104+
phpcs_version: '3.1.0'
105+
106+
name: "QTest: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
107+
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v4
111+
51112
# On stable PHPCS versions, allow for PHP deprecation notices.
52113
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
53114
- name: Setup ini config
@@ -81,21 +142,6 @@ jobs:
81142
# Bust the cache at least once a month - output format: YYYY-MM.
82143
custom-cache-suffix: $(date -u "+%Y-%m")
83144

84-
- name: Lint against parse errors (PHP 7.2+)
85-
if: ${{ matrix.phpcs_version == 'dev-master' && matrix.php >= '7.2' }}
86-
run: composer lint
87-
88-
- name: Lint against parse errors (PHP < 7.2)
89-
if: ${{ matrix.phpcs_version == 'dev-master' && matrix.php < '7.2' }}
90-
run: composer lintlt72
91-
92-
# Check that any sniffs available are feature complete.
93-
# This also acts as an integration test for the feature completeness script,
94-
# which is why it is run against various PHP versions and not in the "Sniff" stage.
95-
- name: Check for feature completeness
96-
if: ${{ matrix.phpcs_version == 'dev-master' }}
97-
run: composer check-complete
98-
99145
- name: Grab PHPUnit version
100146
id: phpunit_version
101147
# yamllint disable rule:line-length
@@ -115,7 +161,3 @@ jobs:
115161
116162
- name: Run the unit tests for the PHPCSDebug sniff
117163
run: composer test-sniff${{ steps.phpunit_script.outputs.SUFFIX }}
118-
119-
- name: Run the unit tests for the DevTools
120-
if: ${{ matrix.phpcs_version == 'dev-master' }}
121-
run: composer test-tools${{ steps.phpunit_script.outputs.SUFFIX }}

.github/workflows/test.yml

Lines changed: 100 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,85 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
#### TEST STAGE ####
20-
test:
19+
# Run CI checks/tests which have no dependency on the PHPCS version used.
20+
test-php:
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
matrix:
25+
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', '8.4', '8.5']
26+
27+
name: "Test + Lint: PHP ${{ matrix.php }}"
28+
29+
continue-on-error: ${{ matrix.php == '8.5' }}
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
36+
# This should not be blocking for this job, so ignore any errors from this step.
37+
# Ref: https://github.com/dotnet/core/issues/4167
38+
- name: Update the available packages list
39+
continue-on-error: true
40+
run: sudo apt-get update
41+
42+
- name: Install xmllint
43+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
44+
45+
- name: Install PHP
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
php-version: ${{ matrix.php }}
49+
ini-values: error_reporting=-1, display_errors=On
50+
coverage: none
51+
tools: cs2pr
52+
53+
# Install dependencies and handle caching in one go.
54+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
55+
- name: Install Composer dependencies
56+
uses: "ramsey/composer-install@v3"
57+
with:
58+
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
59+
# Bust the cache at least once a month - output format: YYYY-MM.
60+
custom-cache-suffix: $(date -u "+%Y-%m")
61+
62+
- name: Lint against parse errors (PHP 7.2+)
63+
if: ${{ matrix.php >= '7.2' }}
64+
run: composer lint -- --checkstyle | cs2pr
65+
66+
- name: Lint against parse errors (PHP < 7.2)
67+
if: ${{ matrix.php < '7.2' }}
68+
run: composer lintlt72 -- --checkstyle | cs2pr
69+
70+
# Check that any sniffs available are feature complete.
71+
# This also acts as an integration test for the feature completeness script,
72+
# which is why it is run against various PHP versions and not in the "Sniff" stage.
73+
- name: Check for feature completeness
74+
run: composer check-complete
75+
76+
- name: Grab PHPUnit version
77+
id: phpunit_version
78+
# yamllint disable rule:line-length
79+
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
80+
# yamllint enable rule:line-length
81+
82+
- name: Determine PHPUnit composer script to use
83+
id: phpunit_script
84+
run: |
85+
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
86+
echo 'SUFFIX=' >> "$GITHUB_OUTPUT"
87+
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
88+
echo 'SUFFIX=' >> "$GITHUB_OUTPUT"
89+
else
90+
echo 'SUFFIX=-lte9' >> "$GITHUB_OUTPUT"
91+
fi
92+
93+
- name: Run the unit tests for the DevTools
94+
run: composer test-tools${{ steps.phpunit_script.outputs.SUFFIX }}
95+
96+
# Run CI checks/tests which have a dependency on the PHPCS version used.
97+
test-phpcs:
2198
runs-on: ubuntu-latest
2299

23100
strategy:
@@ -38,40 +115,40 @@ jobs:
38115

39116
include:
40117
# Complete the matrix, while preventing issues with PHPCS versions incompatible with certain PHP versions.
41-
- php: '8.4'
118+
- php: '7.3'
42119
phpcs_version: 'dev-master'
43-
- php: '8.4'
44-
phpcs_version: '3.8.0'
120+
- php: '7.3'
121+
phpcs_version: '3.3.1'
45122

46-
- php: '8.3'
123+
- php: '7.4'
47124
phpcs_version: 'dev-master'
48-
- php: '8.3'
49-
phpcs_version: '3.8.0'
125+
- php: '7.4'
126+
phpcs_version: '3.5.0'
50127

51-
- php: '8.2'
128+
- php: '8.0'
52129
phpcs_version: 'dev-master'
53-
- php: '8.2'
54-
phpcs_version: '3.6.1'
130+
- php: '8.0'
131+
phpcs_version: '3.5.7'
55132

56133
- php: '8.1'
57134
phpcs_version: 'dev-master'
58135
- php: '8.1'
59136
phpcs_version: '3.6.1'
60137

61-
- php: '8.0'
138+
- php: '8.2'
62139
phpcs_version: 'dev-master'
63-
- php: '8.0'
64-
phpcs_version: '3.5.7'
140+
- php: '8.2'
141+
phpcs_version: '3.6.1'
65142

66-
- php: '7.4'
143+
- php: '8.3'
67144
phpcs_version: 'dev-master'
68-
- php: '7.4'
69-
phpcs_version: '3.5.0'
145+
- php: '8.3'
146+
phpcs_version: '3.8.0'
70147

71-
- php: '7.3'
148+
- php: '8.4'
72149
phpcs_version: 'dev-master'
73-
- php: '7.3'
74-
phpcs_version: '3.3.1'
150+
- php: '8.4'
151+
phpcs_version: '3.8.0'
75152

76153
# Experimental builds. These are allowed to fail.
77154
- php: '7.4'
@@ -80,24 +157,14 @@ jobs:
80157
- php: '8.5' # Nightly.
81158
phpcs_version: 'dev-master'
82159

83-
name: "Test${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
160+
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
84161

85162
continue-on-error: ${{ matrix.php == '8.5' || matrix.phpcs_version == '4.0.x-dev' }}
86163

87164
steps:
88165
- name: Checkout code
89166
uses: actions/checkout@v4
90167

91-
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
92-
# This should not be blocking for this job, so ignore any errors from this step.
93-
# Ref: https://github.com/dotnet/core/issues/4167
94-
- name: Update the available packages list
95-
continue-on-error: true
96-
run: sudo apt-get update
97-
98-
- name: Install xmllint
99-
run: sudo apt-get install --no-install-recommends -y libxml2-utils
100-
101168
- name: Setup ini config
102169
id: set_ini
103170
run: |
@@ -126,36 +193,13 @@ jobs:
126193
127194
# Install dependencies and handle caching in one go.
128195
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
129-
- name: Install Composer dependencies - normal
130-
if: ${{ matrix.php < 8.5 }}
196+
- name: Install Composer dependencies
131197
uses: "ramsey/composer-install@v3"
132198
with:
199+
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php+' || '' }}
133200
# Bust the cache at least once a month - output format: YYYY-MM.
134201
custom-cache-suffix: $(date -u "+%Y-%m")
135202

136-
# For PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow installation.
137-
- name: Install Composer dependencies - with ignore platform
138-
if: ${{ matrix.php >= 8.5 }}
139-
uses: "ramsey/composer-install@v3"
140-
with:
141-
composer-options: --ignore-platform-reqs
142-
custom-cache-suffix: $(date -u "+%Y-%m")
143-
144-
- name: Lint against parse errors (PHP 7.2+)
145-
if: ${{ matrix.phpcs_version == 'dev-master' && matrix.php >= '7.2' }}
146-
run: composer lint -- --checkstyle | cs2pr
147-
148-
- name: Lint against parse errors (PHP < 7.2)
149-
if: ${{ matrix.phpcs_version == 'dev-master' && matrix.php < '7.2' }}
150-
run: composer lintlt72 -- --checkstyle | cs2pr
151-
152-
# Check that any sniffs available are feature complete.
153-
# This also acts as an integration test for the feature completeness script,
154-
# which is why it is run against various PHP versions and not in the "Sniff" stage.
155-
- name: Check for feature completeness
156-
if: matrix.phpcs_version == 'dev-master'
157-
run: composer check-complete
158-
159203
- name: Grab PHPUnit version
160204
id: phpunit_version
161205
# yamllint disable rule:line-length
@@ -175,7 +219,3 @@ jobs:
175219
176220
- name: Run the unit tests for the PHPCSDebug sniff
177221
run: composer test-sniff${{ steps.phpunit_script.outputs.SUFFIX }}
178-
179-
- name: Run the unit tests for the DevTools
180-
if: ${{ matrix.phpcs_version == 'dev-master' }}
181-
run: composer test-tools${{ steps.phpunit_script.outputs.SUFFIX }}

0 commit comments

Comments
 (0)