Skip to content

Commit db4405a

Browse files
anandgupta42claude
andcommitted
fix: use file redirect instead of tee for Bun crash resilience
The previous approach using `tee` failed because when Bun segfaults, the pipe breaks and tee doesn't flush output to the file. The grep then finds no summary and reports "crashed before producing results" even though all tests passed. Fix: redirect bun output to file directly (`> file 2>&1 || true`), then `cat` it for CI log visibility. Use portable `awk` instead of `grep -oP` for summary extraction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a8436cb commit db4405a

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,36 @@ jobs:
9494
# Bun 1.3.x has a known segfault during process cleanup after all tests
9595
# pass (exit code 143/SIGTERM or 134/SIGABRT). We capture test output and
9696
# check for real failures vs Bun crashes to avoid false CI failures.
97+
shell: bash
9798
run: |
98-
set +e
99-
bun test --timeout 30000 2>&1 | tee /tmp/test-output.txt
100-
TEST_EXIT=$?
101-
set -e
102-
103-
# Extract pass/fail counts from Bun test summary
104-
PASS_COUNT=$(grep -E '^\s+\d+ pass' /tmp/test-output.txt | awk '{print $1}' || echo "")
105-
FAIL_COUNT=$(grep -E '^\s+\d+ fail' /tmp/test-output.txt | awk '{print $1}' || echo "")
106-
107-
# If no summary at all, Bun crashed before running tests — real failure
108-
if [ -z "$PASS_COUNT" ] && [ -z "$FAIL_COUNT" ]; then
109-
echo "::error::Bun crashed before producing test results (exit code $TEST_EXIT)"
110-
exit 1
111-
fi
99+
# Redirect bun output to file, then cat it for CI visibility.
100+
# This avoids tee/pipe issues where SIGTERM kills tee before flush.
101+
bun test --timeout 30000 > /tmp/test-output.txt 2>&1 || true
102+
cat /tmp/test-output.txt
103+
104+
# Extract pass/fail counts from Bun test summary (e.g., " 5362 pass")
105+
PASS_COUNT=$(awk '/^ *[0-9]+ pass$/{print $1}' /tmp/test-output.txt || true)
106+
FAIL_COUNT=$(awk '/^ *[0-9]+ fail$/{print $1}' /tmp/test-output.txt || true)
112107
113-
# Real test failures
114-
if [ "$FAIL_COUNT" != "" ] && [ "$FAIL_COUNT" != "0" ]; then
108+
echo ""
109+
echo "--- Test Summary ---"
110+
echo "pass=${PASS_COUNT:-none} fail=${FAIL_COUNT:-none}"
111+
112+
# Real test failures — always fail CI
113+
if [ -n "$FAIL_COUNT" ] && [ "$FAIL_COUNT" != "0" ]; then
115114
echo "::error::$FAIL_COUNT test(s) failed"
116115
exit 1
117116
fi
118117
119-
echo "Tests passed: $PASS_COUNT pass, $FAIL_COUNT fail"
120-
121-
# If bun exited non-zero but all tests passed, it's a Bun crash during cleanup
122-
if [ "$TEST_EXIT" -ne 0 ]; then
123-
echo "::warning::Bun exited with code $TEST_EXIT after all tests passed (known Bun 1.3.x segfault during cleanup — not a test failure)"
118+
# Tests passed (we have a pass count and zero/no failures)
119+
if [ -n "$PASS_COUNT" ] && [ "$PASS_COUNT" -gt 0 ] 2>/dev/null; then
120+
exit 0
124121
fi
125122
123+
# No test summary at all — Bun crashed before running tests
124+
echo "::error::No test results found in output — Bun may have crashed before running tests"
125+
exit 1
126+
126127
# ---------------------------------------------------------------------------
127128
# Driver E2E tests — only when driver code changes.
128129
# Uses GitHub Actions services (no Docker-in-Docker).

0 commit comments

Comments
 (0)