Skip to content

Commit 25ebeba

Browse files
authored
ci: Improve gotestsum failure detection, prevent early exit (coder#5420)
1 parent d170d27 commit 25ebeba

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

.github/workflows/coder.yaml

+18-4
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,21 @@ jobs:
338338
else
339339
echo ::set-output name=cover::false
340340
fi
341+
set +e
341342
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=5m -short -failfast $COVERAGE_FLAGS
342343
ret=$?
343344
if ((ret)); then
344345
# Eternalize test timeout logs because "re-run failed" erases
345346
# artifacts and gotestsum doesn't always capture it:
346347
# https://github.com/gotestyourself/gotestsum/issues/292
347-
echo "Checking gotestsum.json for panic trace:"
348-
grep -A 999999 'panic: test timed out' gotestsum.json
348+
# Multiple test packages could've failed, each one may or may
349+
# not run into the edge case. PS. Don't summon ShellCheck here.
350+
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do
351+
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then
352+
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:"
353+
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json
354+
fi
355+
done
349356
fi
350357
exit $ret
351358
@@ -423,14 +430,21 @@ jobs:
423430

424431
- name: Test with PostgreSQL Database
425432
run: |
433+
set +e
426434
make test-postgres
427435
ret=$?
428436
if ((ret)); then
429437
# Eternalize test timeout logs because "re-run failed" erases
430438
# artifacts and gotestsum doesn't always capture it:
431439
# https://github.com/gotestyourself/gotestsum/issues/292
432-
echo "Checking gotestsum.json for panic trace:"
433-
grep -A 999999 'panic: test timed out' gotestsum.json
440+
# Multiple test packages could've failed, each one may or may
441+
# not run into the edge case. PS. Don't summon ShellCheck here.
442+
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do
443+
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then
444+
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:"
445+
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json
446+
fi
447+
done
434448
fi
435449
exit $ret
436450

0 commit comments

Comments
 (0)