Skip to content

Commit b32da7d

Browse files
zzzyxwvutchrisbra
authored andcommitted
CI: Include a job index in names of collected artifacts
And include "extra" Linux elements to further disambiguate archive names. The current naming of artifacts is inadequate when it comes to files whose differing name-parts only come from array values, as arrays are not automatically converted to string. For example, both artifacts for failing "socketserver" and "no_x11" CI jobs will claim the same name, and whichever job finishes last is allowed to overwrite another matching name artifact. Reference: https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#functions closes: #18556 Signed-off-by: Aliaksei Budavei <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 7193cab commit b32da7d

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

.github/actions/test_artifacts/action.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,39 @@ description: "Upload failed test artifacts"
33
runs:
44
using: "composite"
55
steps:
6+
- name: Collect matrix properties for naming
7+
uses: actions/github-script@v8
8+
id: matrix-props
9+
env:
10+
MATRIX_PROPS: ${{ toJSON(matrix) }}
11+
with:
12+
# An array-flattening-to-string JavaScript function.
13+
script: |
14+
const f = function (x) { return x.toString().length > 0; }
15+
const g = function (x) {
16+
return (Array.isArray(x))
17+
? x.filter(f)
18+
.map((function (h) { return function (y) { return h(y); }; })(g))
19+
.join('-')
20+
: x;
21+
}
22+
return Object.values(JSON.parse(process.env.MATRIX_PROPS))
23+
.filter(f)
24+
.map(g)
25+
.join('-');
26+
# By default, the JSON-encoded return value of the function is
27+
# set as the "result".
28+
result-encoding: string
629
- name: Upload failed tests
730
uses: actions/upload-artifact@v4
831
with:
932
# Name of the artifact to upload.
10-
name: GH-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ join(matrix.*, '-') }}-failed-tests
33+
name: ${{ format('GH-{0}-{1}-{2}-{3}-{4}-failed-tests',
34+
github.run_id,
35+
github.run_attempt,
36+
github.job,
37+
strategy.job-index,
38+
steps.matrix-props.outputs.result) }}
1139

1240
# A file, directory or wildcard pattern that describes what
1341
# to upload.

0 commit comments

Comments
 (0)