Skip to content

Commit 663f7a3

Browse files
authored
ci: Output tail of gotestsum.json if test timed out (#5411)
This is to eternalize the log in case "re-run failed" is used, which erases artifacts from previous run.
1 parent 2a4ef38 commit 663f7a3

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

.github/workflows/coder.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,16 @@ jobs:
338338
else
339339
echo ::set-output name=cover::false
340340
fi
341-
set -x
342341
gotestsum --junitfile="gotests.xml" --jsonfile="gotestsum.json" --packages="./..." --debug -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS
342+
ret=$?
343+
if ((ret)); then
344+
# Eternalize test timeout logs because "re-run failed" erases
345+
# artifacts and gotestsum doesn't always capture it:
346+
# 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
349+
fi
350+
exit $ret
343351
344352
- uses: actions/upload-artifact@v3
345353
if: success() || failure()
@@ -407,7 +415,17 @@ jobs:
407415
terraform_wrapper: false
408416

409417
- name: Test with PostgreSQL Database
410-
run: make test-postgres
418+
run: |
419+
make test-postgres
420+
ret=$?
421+
if ((ret)); then
422+
# Eternalize test timeout logs because "re-run failed" erases
423+
# artifacts and gotestsum doesn't always capture it:
424+
# https://github.com/gotestyourself/gotestsum/issues/292
425+
echo "Checking gotestsum.json for panic trace:"
426+
grep -A 999999 'panic: test timed out' gotestsum.json
427+
fi
428+
exit $ret
411429
412430
- uses: actions/upload-artifact@v3
413431
if: success() || failure()

0 commit comments

Comments
 (0)