Skip to content

Commit 4d11355

Browse files
authored
print the shard index and an error summary step (chainguard-images#2186)
Signed-off-by: Josh Wolf <josh@wolfs.io>
1 parent f13ca95 commit 4d11355

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/release.yaml

+19-5
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,33 @@ jobs:
172172
path: /tmp/shard-logs
173173
pattern: mega-module-*
174174

175-
# Cat all the files into one
175+
# Cat all the files into one, while maintaining their shard
176176
- run: |
177-
find /tmp/shard-logs -name 'mega-module.tf.json' -exec cat {} + >> logs.tf.json
177+
find '/tmp/shard-logs' -name 'mega-module.tf.json' | while read file; do
178+
shard_index=$(echo "$file" | sed -E 's/.*mega-module-([0-9]+)\.tf\.json.*/\1/')
179+
echo $shard_index
180+
jq -cr --arg shard_index "$shard_index" '. + {"shard_index":$shard_index}' $file >> logs.tf.json
181+
done
182+
183+
# process the logs
184+
- run: |
185+
# Create a file just for errors
186+
jq -r 'select(.["@level"]=="error")' logs.tf.json > errors.tf.json
178187
179188
# Build the markdown table
180189
- run: |
181-
echo "| Status | Image | Summary | Address |" >> $GITHUB_STEP_SUMMARY
182-
echo "| :-: | ----- | ------- | ------- |" >> $GITHUB_STEP_SUMMARY
190+
echo "| Status | Shard | Image | Summary | Address |" >> $GITHUB_STEP_SUMMARY
191+
echo "| :-: | ----- | ----- | ------- | ------- |" >> $GITHUB_STEP_SUMMARY
183192
184193
# append the rows to the table
185-
export rows="$(jq -r 'select(.["@level"]=="error") | ("| ❌ | " + (.diagnostic.address | split(".")[1]) + " | ```" + .diagnostic.summary + "``` | ```" + .diagnostic.address + "``` |")' logs.tf.json)"
194+
export rows="$(jq -r '"| ❌ | " + .shard_index + " | " + (.diagnostic.address | split(".")[1]) + " | ```" + .diagnostic.summary + "``` | ```" + .diagnostic.address + "``` |"' errors.tf.json)"
186195
echo "${rows}"
187196
188197
cat >> $GITHUB_STEP_SUMMARY <<EOR
189198
${rows}
190199
EOR
200+
201+
- name: Error Details
202+
run: |
203+
# Print the errors as expandable groups
204+
jq -r '"::group:: shard: " + .shard_index + " | " + (.diagnostic.address | split(".")[1]) + "\nresource: " + .diagnostic.address + "\n\nsummary: " + .diagnostic.summary + "\n\ndetails:\n\n" + .diagnostic.detail + "\n::endgroup::"' errors.tf.json || true

0 commit comments

Comments
 (0)