Skip to content

Commit 9d2c102

Browse files
committed
config(workflow/reusable-flake-checks-ci-matrix.yml): Support nested matrix artifacts
1 parent b392c99 commit 9d2c102

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/reusable-flake-checks-ci-matrix.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,25 @@ jobs:
124124
export PATH
125125
fi
126126
127-
ls */matrix-pre.json
128-
matrix="$(cat */matrix-pre.json | jq -cr '.include[]' | jq '[ select (.isCached == false) ]' | jq -s 'add' | jq -c '. | {include: .}')"
127+
matrix_files=()
128+
while IFS= read -r -d '' file; do
129+
matrix_files+=("$file")
130+
done < <(find . -type f -name 'matrix-pre.json' -print0 | sort -z)
131+
132+
if [[ "${#matrix_files[@]}" -eq 0 ]]; then
133+
echo "No matrix-pre.json artifacts found" >&2
134+
exit 1
135+
fi
136+
137+
echo "Found matrix-pre.json files:"
138+
for file in "${matrix_files[@]}"; do
139+
ls "$file"
140+
done
141+
142+
matrix="$(jq -sc '
143+
[.[].include[]? | select(.isCached == false)] as $filtered
144+
| {include: $filtered}
145+
' "${matrix_files[@]}")"
129146
130147
if [[ "$matrix" == '' ]] || [[ "$matrix" == '{}' ]] || [[ "$matrix" == '{"include":null}' ]] || [[ "$matrix" == '{"include":[]}' ]]; then
131148
matrix='{"include":[]}'
@@ -138,7 +155,10 @@ jobs:
138155
echo
139156
echo
140157
141-
fullMatrix="$(cat */matrix-pre.json | jq -cr '.include' | jq -s 'add' | jq -c '. | {include: .}')"
158+
fullMatrix="$(jq -sc '
159+
[.[].include[]?] as $all
160+
| {include: $all}
161+
' "${matrix_files[@]}")"
142162
143163
echo "---"
144164
echo "Full Matrix:"

0 commit comments

Comments
 (0)