Skip to content

Commit 436bd03

Browse files
authored
Merge pull request #4759 from AkihiroSuda/show-failing-tests
CI: show consistently failing test names at end of job log
2 parents b6d67fa + 89dbffb commit 436bd03

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

hack/github/gotestsum-reporter.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ readonly root
2424

2525
GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/null}"
2626

27+
# Identify consistently failing tests: those that failed but never passed, even on retry.
28+
# Tests that failed then passed on retry (flaky) are excluded.
29+
failing_tests="$(jq -rc 'select(.Test) | select(.Action == "fail" or .Action == "pass") | [.Action, .Test] | @tsv' < "$GOTESTSUM_JSONFILE" \
30+
| awk -F'\t' '
31+
$1 == "fail" { failed[$2] = 1 }
32+
$1 == "pass" { passed[$2] = 1 }
33+
END {
34+
for (t in failed) {
35+
if (!(t in passed)) print t
36+
}
37+
}
38+
' | sort)"
39+
2740
{
2841
github::md::h3 "Total number of tests: $TESTS_TOTAL"
2942
github::md::pie "Status" "Skipped" "$TESTS_SKIPPED" "Failed" "$TESTS_FAILED" "Passed" "$(( TESTS_TOTAL - TESTS_FAILED - TESTS_SKIPPED ))"
@@ -34,11 +47,20 @@ GITHUB_STEP_SUMMARY="${GITHUB_STEP_SUMMARY:-/dev/null}"
3447

3548
github::md::h3 "Failing tests"
3649
echo '```'
37-
jq -rc 'select(.Action == "fail") | select(.Test) | .Test' < "$GOTESTSUM_JSONFILE"
50+
echo "${failing_tests:-}"
3851
echo '```'
3952

4053
github::md::h3 "Tests taking more than 15 seconds"
4154
echo '```'
4255
gotestsum tool slowest --threshold 15s --jsonfile "$GOTESTSUM_JSONFILE"
4356
echo '```'
4457
} >> "$GITHUB_STEP_SUMMARY"
58+
59+
# Print failing tests to stdout so they are visible at the end of the job log.
60+
if [ -n "${failing_tests:-}" ]; then
61+
printf '\n=== Failing tests ===\n%s\n=====================\n' "$failing_tests"
62+
# Also emit as a GitHub Actions error annotation (visible in PR checks and annotations panel).
63+
# GitHub Actions uses %0A for newlines inside annotation messages.
64+
encoded="${failing_tests//$'\n'/%0A}"
65+
echo "::error title=Failing tests::${encoded}"
66+
fi

0 commit comments

Comments
 (0)