Skip to content

Commit 2c8cdbd

Browse files
committed
complete-artifact-matrix: fail when an image chunk is missing
jq ran inside an echo argument, so set -e did not see its failure. A missing chunk or matrix file then gave empty outputs, and the image jobs skipped those chunks without an error. Assign the jq results first and use jq -e for the chunk. Assisted-by: Claude Opus 5.5 Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent 694a148 commit 2c8cdbd

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

‎.github/workflows/complete-artifact-matrix.yml‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,11 @@ jobs:
423423
run: |
424424
set -euo pipefail
425425
for chunk in 1 2 3 4; do
426-
echo "images-chunk-json-${chunk}=$(jq -c ".chunk${chunk}" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
427-
echo "images-chunk-not-empty-${chunk}=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
426+
# Assign first: set -e does not see a failed jq inside an echo argument.
427+
json=$(jq -ce ".chunk${chunk}" info/gha-all-images-matrix.json)
428+
not_empty=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)
429+
echo "images-chunk-json-${chunk}=${json}" >> "$GITHUB_OUTPUT"
430+
echo "images-chunk-not-empty-${chunk}=${not_empty}" >> "$GITHUB_OUTPUT"
428431
done
429432
outputs:
430433
images-chunk-json-1: ${{ steps.chunks.outputs.images-chunk-json-1 }}
@@ -450,8 +453,11 @@ jobs:
450453
run: |
451454
set -euo pipefail
452455
for chunk in 5 6 7 8; do
453-
echo "images-chunk-json-${chunk}=$(jq -c ".chunk${chunk}" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
454-
echo "images-chunk-not-empty-${chunk}=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
456+
# Assign first: set -e does not see a failed jq inside an echo argument.
457+
json=$(jq -ce ".chunk${chunk}" info/gha-all-images-matrix.json)
458+
not_empty=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)
459+
echo "images-chunk-json-${chunk}=${json}" >> "$GITHUB_OUTPUT"
460+
echo "images-chunk-not-empty-${chunk}=${not_empty}" >> "$GITHUB_OUTPUT"
455461
done
456462
outputs:
457463
images-chunk-json-5: ${{ steps.chunks.outputs.images-chunk-json-5 }}
@@ -477,8 +483,11 @@ jobs:
477483
run: |
478484
set -euo pipefail
479485
for chunk in 9 10 11 12; do
480-
echo "images-chunk-json-${chunk}=$(jq -c ".chunk${chunk}" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
481-
echo "images-chunk-not-empty-${chunk}=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
486+
# Assign first: set -e does not see a failed jq inside an echo argument.
487+
json=$(jq -ce ".chunk${chunk}" info/gha-all-images-matrix.json)
488+
not_empty=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)
489+
echo "images-chunk-json-${chunk}=${json}" >> "$GITHUB_OUTPUT"
490+
echo "images-chunk-not-empty-${chunk}=${not_empty}" >> "$GITHUB_OUTPUT"
482491
done
483492
outputs:
484493
images-chunk-json-9: ${{ steps.chunks.outputs.images-chunk-json-9 }}
@@ -504,8 +513,11 @@ jobs:
504513
run: |
505514
set -euo pipefail
506515
for chunk in 13 14 15 16; do
507-
echo "images-chunk-json-${chunk}=$(jq -c ".chunk${chunk}" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
508-
echo "images-chunk-not-empty-${chunk}=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)" >> "$GITHUB_OUTPUT"
516+
# Assign first: set -e does not see a failed jq inside an echo argument.
517+
json=$(jq -ce ".chunk${chunk}" info/gha-all-images-matrix.json)
518+
not_empty=$(jq -r "if any(.chunk${chunk}.include[]; .really == \"yes\") then \"yes\" else \"no\" end" info/gha-all-images-matrix.json)
519+
echo "images-chunk-json-${chunk}=${json}" >> "$GITHUB_OUTPUT"
520+
echo "images-chunk-not-empty-${chunk}=${not_empty}" >> "$GITHUB_OUTPUT"
509521
done
510522
outputs:
511523
images-chunk-json-13: ${{ steps.chunks.outputs.images-chunk-json-13 }}

0 commit comments

Comments
 (0)