Skip to content

Commit 619055e

Browse files
committed
CI: Split tasks between targeted tasks that run only on the targeted (and lowest) PHP version, and others that run on all versions
1 parent 6410701 commit 619055e

File tree

3 files changed

+179
-33
lines changed

3 files changed

+179
-33
lines changed

.github/workflows/ci.yaml

Lines changed: 172 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ on:
3737
default: false
3838
required: false
3939
type: boolean
40+
supportedChecksCommand:
41+
description: The make command to invoke listing the different tasks to run across all versions, will also act as a prefix for All, Direct on OS, Lowest, Locked, and Highest task lists.
42+
default: "task-list-ci"
43+
required: false
44+
type: string
4045

4146
#defaults:
4247
# run:
@@ -84,6 +89,7 @@ jobs:
8489
- supported-versions-matrix
8590
outputs:
8691
version: ${{ steps.supported-threading-matrix.outputs.result }}
92+
primary: ${{ steps.primary.outputs.result }}
8793
steps:
8894
- id: supported-threading-matrix
8995
uses: actions/github-script@v7
@@ -102,6 +108,19 @@ jobs:
102108
return ['nts'];
103109
}
104110
return ['nts', 'zts'];
111+
- id: primary
112+
uses: actions/github-script@v7
113+
env:
114+
PHP_EXTENSIONS: ${{ needs.supported-versions-matrix.outputs.extensions }}
115+
with:
116+
script: |
117+
const phpExtensions = JSON.parse(process.env.PHP_EXTENSIONS);
118+
for(var i = 0; i <= phpExtensions.length; i++) {
119+
if (phpExtensions[i] == 'parallel') {
120+
return 'zts';
121+
}
122+
}
123+
return 'nts';
105124
supported-checks-matrix:
106125
name: Supported Checks Matrix
107126
runs-on: ${{ inputs.runsOnChaos }}
@@ -110,7 +129,11 @@ jobs:
110129
- supported-versions-matrix
111130
outputs:
112131
check: ${{ steps.supported-checks-matrix.outputs.check }}
113-
run-tests: ${{ steps.run-tests.outputs.result }}
132+
all: ${{ steps.supported-checks-matrix.outputs.all }}
133+
dos: ${{ steps.supported-checks-matrix.outputs.dos }}
134+
low: ${{ steps.supported-checks-matrix.outputs.low }}
135+
locked: ${{ steps.supported-checks-matrix.outputs.locked }}
136+
high: ${{ steps.supported-checks-matrix.outputs.high }}
114137
steps:
115138
- uses: actions/checkout@v4
116139
with:
@@ -121,19 +144,150 @@ jobs:
121144
- id: supported-checks-matrix
122145
name: Generate check
123146
run: |
124-
printf "Checks found: %s\r\n" $(make task-list-ci)
125-
printf "check=%s" $(make task-list-ci) >> $GITHUB_OUTPUT
147+
printf "Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }} || echo "[]")
148+
printf "check=%s\n" $(make ${{ inputs.supportedChecksCommand }} || echo "[]") >> $GITHUB_OUTPUT
149+
printf "All Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }}-all || echo "[]")
150+
printf "all=%s\n" $(make ${{ inputs.supportedChecksCommand }}-all || echo "[]") >> $GITHUB_OUTPUT
151+
printf "Directly on OS Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }}-dos || echo "[]")
152+
printf "dos=%s\n" $(make ${{ inputs.supportedChecksCommand }}-dos || echo "[]") >> $GITHUB_OUTPUT
153+
printf "Low Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }}-low || echo "[]")
154+
printf "low=%s\n" $(make ${{ inputs.supportedChecksCommand }}-low || echo "[]") >> $GITHUB_OUTPUT
155+
printf "Locked Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }}-locked || echo "[]")
156+
printf "locked=%s\n" $(make ${{ inputs.supportedChecksCommand }}-locked || echo "[]") >> $GITHUB_OUTPUT
157+
printf "High Checks found: %s\r\n" $(make ${{ inputs.supportedChecksCommand }}-high || echo "[]")
158+
printf "high=%s\n" $(make ${{ inputs.supportedChecksCommand }}-high || echo "[]") >> $GITHUB_OUTPUT
159+
working-directory: ${{ inputs.workingDirectory }}
160+
compile-matrix:
161+
name: Compile the matrix
162+
runs-on: ubuntu-latest
163+
needs:
164+
- supported-checks-matrix
165+
- supported-versions-matrix
166+
- supported-threading-matrix
167+
outputs:
168+
qa: ${{ steps.compile-qa-matrix.outputs.result }}
169+
directly-on-os: ${{ steps.compile-directly-on-os-matrix.outputs.result }}
170+
steps:
126171
- uses: actions/github-script@v7
127-
id: run-tests
172+
name: Compile the QA matrix
173+
id: compile-qa-matrix
128174
env:
129-
CHECKS: ${{ steps.supported-checks-matrix.outputs.check }}
175+
PHP_LOWEST: "${{ needs.supported-versions-matrix.outputs.lowest }}"
176+
PHP_VERSIONS: ${{ needs.supported-versions-matrix.outputs.version }}
177+
PHP_TO_THREAD_OR_NOT_TO_THREAD: ${{ needs.supported-threading-matrix.outputs.version }}
178+
THREAD_PRIMARY: ${{ needs.supported-threading-matrix.outputs.primary }}
179+
COMPOSER: '["lowest", "locked", "highest"]'
180+
CHECKS: ${{ needs.supported-checks-matrix.outputs.check }}
181+
CHECKS_ALL: ${{ needs.supported-checks-matrix.outputs.all }}
182+
CHECKS_LOW: ${{ needs.supported-checks-matrix.outputs.low }}
183+
CHECKS_LOCKED: ${{ needs.supported-checks-matrix.outputs.locked }}
184+
CHECKS_HIGH: ${{ needs.supported-checks-matrix.outputs.high }}
130185
with:
131186
script: |
187+
let matrix = [];
188+
const phpLowest = JSON.parse(process.env.PHP_LOWEST);
189+
const phpVersions = JSON.parse(process.env.PHP_VERSIONS);
190+
const phpToThreadOrNotToThread = JSON.parse(process.env.PHP_TO_THREAD_OR_NOT_TO_THREAD);
191+
const threadPrimary = JSON.parse(process.env.THREAD_PRIMARY);
192+
const composer = JSON.parse(process.env.COMPOSER);
132193
const checks = JSON.parse(process.env.CHECKS);
133-
console.log(checks);
134-
console.log(checks.includes("unit-testing"));
135-
console.log(checks.includes("unit-testing") ? "yes" : "no");
136-
return checks.includes("unit-testing") ? "yes" : "no";
194+
const checksAll = JSON.parse(process.env.CHECKS_ALL);
195+
const checksLow = JSON.parse(process.env.CHECKS_LOW);
196+
const checksLocked = JSON.parse(process.env.CHECKS_LOCKED);
197+
const checksHigh = JSON.parse(process.env.CHECKS_HIGH);
198+
for (const checkLow in checksLow) {
199+
matrix.push({
200+
php: phpLowest,
201+
"php-to-thread-or-not-to-thread": threadPrimary,
202+
composer: 'lowest',
203+
check: checksLow[checkLow],
204+
});
205+
}
206+
for (const checkLocked in checksLocked) {
207+
matrix.push({
208+
php: phpLowest,
209+
"php-to-thread-or-not-to-thread": threadPrimary,
210+
composer: 'locked',
211+
check: checksLocked[checkLocked],
212+
});
213+
}
214+
for (const checkHigh in checksHigh) {
215+
matrix.push({
216+
php: phpLowest,
217+
"php-to-thread-or-not-to-thread": threadPrimary,
218+
composer: 'highest',
219+
check: checksHigh[checkHigh],
220+
});
221+
}
222+
for (const ztsOrNts in phpToThreadOrNotToThread) {
223+
for (const composerAction in composer) {
224+
for (const phpVersion in phpVersions) {
225+
for (const checkAll in checksAll) {
226+
matrix.push({
227+
php: phpVersions[phpVersion],
228+
"php-to-thread-or-not-to-thread": phpToThreadOrNotToThread[ztsOrNts],
229+
composer: composer[composerAction],
230+
check: checksAll[checkAll],
231+
});
232+
}
233+
for (const check in checks) {
234+
matrix.push({
235+
php: phpVersions[phpVersion],
236+
"php-to-thread-or-not-to-thread": phpToThreadOrNotToThread[ztsOrNts],
237+
composer: composer[composerAction],
238+
check: checks[check],
239+
});
240+
}
241+
}
242+
}
243+
}
244+
console.log(JSON.stringify(matrix, null, 4));
245+
return matrix;
246+
- uses: actions/github-script@v7
247+
name: Compile the Direction on OS matrix
248+
id: compile-directly-on-os-matrix
249+
env:
250+
OS: ${{ (contains(needs.supported-versions-matrix.outputs.extensions, 'pcntl') == false || contains(needs.supported-versions-matrix.outputs.extensions, 'parallel') == false) && '["ubuntu-latest", "windows-latest", "macos-latest"]' || '["ubuntu-latest", "macos-latest"]' }}
251+
PHP_VERSIONS: ${{ needs.supported-versions-matrix.outputs.version }}
252+
THREAD_PRIMARY: ${{ needs.supported-threading-matrix.outputs.primary }}
253+
COMPOSER: '["lowest", "locked", "highest"]'
254+
CHECKS: ${{ needs.supported-checks-matrix.outputs.check }}
255+
CHECKS_DOS: ${{ needs.supported-checks-matrix.outputs.dos }}
256+
with:
257+
script: |
258+
let matrix = [];
259+
const oses = JSON.parse(process.env.OS);
260+
const phpVersions = JSON.parse(process.env.PHP_VERSIONS);
261+
const threadPrimary = JSON.parse(process.env.THREAD_PRIMARY);
262+
const composer = JSON.parse(process.env.COMPOSER);
263+
const checks = JSON.parse(process.env.CHECKS_DOS === "[]" ? '["unit-testing"]' : process.env.CHECKS);
264+
const checksDos = JSON.parse(process.env.CHECKS_DOS);
265+
for (const os in oses) {
266+
for (const composerAction in composer) {
267+
for (const phpVersion in phpVersions) {
268+
for (const checkDos in checksDos) {
269+
matrix.push({
270+
os: oses[os],
271+
php: phpVersions[phpVersion],
272+
"php-to-thread-or-not-to-thread": threadPrimary,
273+
composer: composer[composerAction],
274+
check: checksDos[checkDos],
275+
});
276+
}
277+
for (const check in checks) {
278+
matrix.push({
279+
os: oses[os],
280+
php: phpVersions[phpVersion],
281+
"php-to-thread-or-not-to-thread": threadPrimary,
282+
composer: composer[composerAction],
283+
check: checks[check],
284+
});
285+
}
286+
}
287+
}
288+
}
289+
console.log(JSON.stringify(matrix, null, 4));
290+
return matrix;
137291
can-require:
138292
name: Test we can require "${{ matrix.package-name }}" on PHP ${{ matrix.php }} (${{ matrix.php-to-thread-or-not-to-thread }})
139293
if: ${{ inputs.isProject == false }}
@@ -171,14 +325,9 @@ jobs:
171325
strategy:
172326
fail-fast: false
173327
matrix:
174-
php: ${{ fromJson(inputs.isProject == false && needs.supported-versions-matrix.outputs.version || format('["{0}"]', needs.supported-versions-matrix.outputs.lowest)) }}
175-
php-to-thread-or-not-to-thread: ${{ fromJson(needs.supported-threading-matrix.outputs.version) }}
176-
composer: ${{ fromJson(inputs.isProject == false && '["lowest", "locked", "highest"]' || '["locked"]') }}
177-
check: ${{ fromJson(needs.supported-checks-matrix.outputs.check) }}
328+
include: ${{ fromJson(needs.compile-matrix.outputs.qa) }}
178329
needs:
179-
- supported-checks-matrix
180-
- supported-versions-matrix
181-
- supported-threading-matrix
330+
- compile-matrix
182331
runs-on: ubuntu-latest
183332
container:
184333
image: ghcr.io/wyrihaximusnet/php:${{ matrix.php }}-${{ matrix.php-to-thread-or-not-to-thread }}-alpine-dev-root
@@ -206,21 +355,18 @@ jobs:
206355
env:
207356
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
208357
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
209-
tests-directly-on-os:
210-
name: Run tests on PHP ${{ matrix.php }} (${{ matrix.php-to-thread-or-not-to-thread }}) with ${{ matrix.composer }} dependency preference (${{ matrix.os }})
358+
directly-on-os:
359+
name: Run ${{ matrix.check }} on PHP ${{ matrix.php }} (${{ matrix.php-to-thread-or-not-to-thread }}) with ${{ matrix.composer }} dependency preference (${{ matrix.os }})
211360
strategy:
212361
fail-fast: false
213362
matrix:
214-
os: ${{ fromJson((contains(needs.supported-versions-matrix.outputs.extensions, 'pcntl') == false || contains(needs.supported-versions-matrix.outputs.extensions, 'parallel') == false) && '["ubuntu-latest", "windows-latest", "macos-latest"]' || '["ubuntu-latest", "macos-latest"]') }}
215-
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
216-
php-to-thread-or-not-to-thread: ${{ fromJson(needs.supported-threading-matrix.outputs.version) }}
217-
composer: [lowest, locked, highest]
363+
include: ${{ fromJson(needs.compile-matrix.outputs.directly-on-os) }}
218364
needs:
219365
- supported-checks-matrix
220366
- supported-versions-matrix
221-
- supported-threading-matrix
367+
- compile-matrix
222368
runs-on: ${{ matrix.os }}
223-
if: ${{ needs.supported-checks-matrix.outputs.run-tests == '"yes"' && inputs.isProject == false }}
369+
if: ${{ inputs.isProject == false }}
224370
env: ${{ fromJson(inputs.env) }}
225371
services: ${{ fromJson(inputs.services) }}
226372
steps:
@@ -238,15 +384,8 @@ jobs:
238384
with:
239385
dependency-versions: ${{ matrix.composer }}
240386
working-directory: ${{ inputs.workingDirectory }}
241-
- run: make unit-testing-raw || true
242-
working-directory: ${{ inputs.workingDirectory }}
243-
if: needs.supported-versions-matrix.outputs.upcoming == matrix.php
244-
env:
245-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
246-
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
247-
- run: make unit-testing-raw
387+
- run: make ${{ matrix.check }}
248388
working-directory: ${{ inputs.workingDirectory }}
249-
if: needs.supported-versions-matrix.outputs.upcoming != matrix.php
250389
env:
251390
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
252391
COVERALLS_RUN_LOCALLY: ${{ secrets.COVERALLS_RUN_LOCALLY }}
@@ -255,7 +394,7 @@ jobs:
255394
needs:
256395
- can-require
257396
- qa
258-
- tests-directly-on-os
397+
- directly-on-os
259398
runs-on: ${{ inputs.runsOnChaos }}
260399
steps:
261400
- run: echo "✔️"

.github/workflows/package.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ on:
2727
default: "{}"
2828
required: false
2929
type: string
30+
supportedChecksCommand:
31+
description: The make command to invoke listing the different tasks to run across all versions, will also act as a prefix for All, Direct on OS, Lowest, Locked, and Highest task lists.
32+
default: "task-list-ci"
33+
required: false
34+
type: string
3035
jobs:
3136
ci:
3237
name: Continuous Integration
@@ -36,6 +41,7 @@ jobs:
3641
workingDirectory: ${{ inputs.workingDirectory }}
3742
services: ${{ inputs.services }}
3843
env: ${{ inputs.env }}
44+
supportedChecksCommand: ${{ inputs.supportedChecksCommand }}
3945
markdown-link-check:
4046
name: Check Markdown links
4147
if: inputs.disableMarkdownLinkCheck == false

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ jobs:
270270
| env | string | Any additional environment variables | {} |
271271
| jsonPattern | string | The pattern to match which JSON files to check | \.json$ |
272272
| services | string | Any additional services to use | {} |
273+
| supportedChecksCommand | string | The make command to invoke listing the different tasks to run across all versions, will also act as a prefix for All, Direct on OS, Lowest, Locked, and Highest task lists. | task-list-ci |
273274
| workingDirectory | string | The directory to run this workflow in | |
274275
275276
#### Release Management

0 commit comments

Comments
 (0)