Skip to content

Commit ea3f70a

Browse files
committed
Another fix of the matrix
1 parent 46a36dd commit ea3f70a

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

.github/workflows/sync-base-images.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
exit 1
3939
fi
4040
echo "Matrix JSON length: ${#json} chars (output written to GITHUB_OUTPUT)"
41-
# Single-line matrix required: GITHUB_OUTPUT is newline-delimited and fromJson() needs valid JSON
42-
printf 'matrix=%s\n' "${json//%/%25}" >> "$GITHUB_OUTPUT"
41+
# strategy.matrix must be an object; use include: [...] for explicit list of jobs
42+
matrix_json="{\"include\":${json}}"
43+
printf 'matrix=%s\n' "${matrix_json//%/%25}" >> "$GITHUB_OUTPUT"
4344
images=$(yq -r '.images | keys | .[]' config/images.yaml | sort -u)
4445
echo "names<<NAMES_EOF" >> "$GITHUB_OUTPUT"
4546
echo "$images" >> "$GITHUB_OUTPUT"

test/scripts/test-prepare.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ fi
3131
echo "Matrix JSON length: ${#json} chars"
3232

3333
# Build GITHUB_OUTPUT-style file (same as in workflow)
34+
# strategy.matrix must be an object; use include: [...] for explicit list of jobs
35+
matrix_json="{\"include\":${json}}"
3436
if [ "$OUTPUT_FILE" = "-" ]; then
3537
TARGET="/dev/stdout"
3638
else
3739
TARGET="$OUTPUT_FILE"
3840
: > "$TARGET"
3941
fi
4042

41-
printf 'matrix=%s\n' "${json//%/%25}" >> "$TARGET"
43+
printf 'matrix=%s\n' "${matrix_json//%/%25}" >> "$TARGET"
4244
images=$(yq -r '.images | keys | .[]' config/images.yaml | sort -u)
4345
echo "names<<NAMES_EOF" >> "$TARGET"
4446
echo "$images" >> "$TARGET"
@@ -50,15 +52,15 @@ fi
5052

5153
# Validate: simulate fromJson() on matrix (requires jq)
5254
if command -v jq &>/dev/null; then
53-
if echo "$json" | jq -e . >/dev/null 2>&1; then
54-
count=$(echo "$json" | jq 'length')
55-
echo "Valid JSON matrix: $count entries (fromJson would succeed)"
55+
if echo "$matrix_json" | jq -e '.include | length' >/dev/null 2>&1; then
56+
count=$(echo "$matrix_json" | jq '.include | length')
57+
echo "Valid matrix (include: $count entries); fromJson would succeed"
5658
echo "First 3 entries:"
57-
echo "$json" | jq -c '.[:3][]'
59+
echo "$matrix_json" | jq -c '.include[:3][]'
5860
else
59-
echo "WARNING: matrix value is not valid JSON (fromJson would fail)" >&2
60-
echo "Raw (first 120 chars): ${json:0:120}..." >&2
61+
echo "WARNING: matrix value is not valid for strategy.matrix (fromJson would fail)" >&2
62+
echo "Raw (first 120 chars): ${matrix_json:0:120}..." >&2
6163
fi
6264
else
63-
echo "Tip: install jq to validate that the matrix is valid JSON for fromJson()"
65+
echo "Tip: install jq to validate that the matrix is valid for fromJson()"
6466
fi

0 commit comments

Comments
 (0)