Skip to content

Commit dddf07b

Browse files
Find Haxe 5 warnings in each job's error annotations
The warnings job looked for steps whose conclusion is "failure", but the jobs API gives a step that fails under continue-on-error the conclusion "success", so on 5ab1944 it listed nothing although three core jobs had a failed step. A failed step does leave an error annotation on its job, "Process completed with exit code", so the job now reads each job's annotations and warns once per job with a failed step, with how many, and passes on the other errors the steps reported. Checked against the haxe 5 preview run on 5ab1944, where it gives the three core jobs one failed step each.
1 parent 5ab1944 commit dddf07b

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

‎.github/workflows/haxe5.yml‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ concurrency:
2424
cancel-in-progress: true
2525

2626
# Haxe 5 is not released, so its failures are warnings: with warn_only, a
27-
# failing step leaves its job green, and the warnings job below lists every
28-
# step that failed. Each failure still gets an issue, but it holds back
27+
# failing step leaves its job green, and the warnings job below lists the
28+
# jobs that had one. Each failure still gets an issue, but it holds back
2929
# neither a merge nor a release (CONTRIBUTING.md).
3030
jobs:
3131
# Haxe 5.0.0-preview.1 passes API level 500 but generates code for the level
@@ -70,23 +70,37 @@ jobs:
7070
scope: smoke
7171
bindir: MacArm64
7272

73+
# A step that fails with continue-on-error has the conclusion "success" in the
74+
# jobs API, so the failures are read from each job's error annotations,
75+
# where "Process completed with exit code" marks one failed step
7376
warnings:
7477
name: Haxe 5.0.0-preview.1 / warnings
7578
needs: [haxe5-preview-linux, haxe5-preview-windows, haxe5-preview-macos]
7679
if: ${{ !cancelled() }}
7780
runs-on: ubuntu-latest
7881
permissions:
7982
actions: read
83+
checks: read
8084
steps:
81-
- name: list the steps that failed
85+
- name: list the jobs with failed steps
8286
env:
8387
GH_TOKEN: ${{ github.token }}
88+
REPO: ${{ github.repository }}
8489
run: |
85-
jobs="repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs"
86-
gh api --paginate "$jobs" --jq '.jobs[] | .name as $job | .steps[]? | select(.conclusion == "failure") | "\($job): \(.name)"' > failed.txt
90+
jobs="repos/$REPO/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs"
91+
gh api --paginate "$jobs" --jq '.jobs[] | select(.name | endswith("/ warnings") | not) | "\(.id)\t\(.name)"' > jobs.txt
92+
: > failed.txt
93+
while IFS=$'\t' read -r id name; do
94+
gh api "repos/$REPO/check-runs/$id/annotations" \
95+
--jq '.[] | select(.annotation_level == "failure") | .message | gsub("\n"; " ")' > errors.txt || continue
96+
[ -s errors.txt ] || continue
97+
steps=$(grep -c '^Process completed with exit code' errors.txt || true)
98+
[ "$steps" = 0 ] || echo "$name: $steps step(s) failed" >> failed.txt
99+
{ grep -v '^Process completed with exit code' errors.txt || true; } | sed "s|^|$name: |" >> failed.txt
100+
done < jobs.txt
87101
if [ -s failed.txt ]; then
88102
{ echo "### Haxe 5.0.0-preview.1 failures (warnings)"; sed 's/^/- /' failed.txt; } >> "$GITHUB_STEP_SUMMARY"
89-
while read -r line; do echo "::warning title=Haxe 5.0.0-preview.1::$line failed"; done < failed.txt
103+
while read -r line; do echo "::warning title=Haxe 5.0.0-preview.1::$line"; done < failed.txt
90104
else
91105
echo "No Haxe 5.0.0-preview.1 step failed." >> "$GITHUB_STEP_SUMMARY"
92106
fi

0 commit comments

Comments
 (0)