@@ -272,20 +272,39 @@ jobs:
272272 - name : Run gorm upstream test suite
273273 run : |
274274 cd "$WORK_DIR/gorm/tests"
275+ # tee duplicates output to a file we parse for PASS/FAIL counts
276+ # below. Two pitfalls we work around here:
277+ # 1. GitHub Actions prefixes every line with a UTC timestamp,
278+ # even in the file written by tee — so we cannot anchor our
279+ # grep with `^--- PASS:`. We use an unanchored match.
280+ # 2. `go test`'s exit code is masked by tee's (always 0). We
281+ # capture it via PIPESTATUS before the next command resets
282+ # $?, and disable errexit around the pipeline so a
283+ # legitimate test-fail doesn't abort our reporter.
284+ set +e
275285 go test -count=1 -timeout 5m -v ./... 2>&1 | tee /tmp/gorm-upstream.log
286+ rc=${PIPESTATUS[0]}
287+ set -e
288+ # `grep -c` exits 1 on zero matches; `|| true` keeps the
289+ # outer script alive so we can report the actual counts.
290+ PASS=$(grep -c -- '--- PASS:' /tmp/gorm-upstream.log || true)
291+ FAIL=$(grep -c -- '--- FAIL:' /tmp/gorm-upstream.log || true)
292+ SKIP=$(grep -c -- '--- SKIP:' /tmp/gorm-upstream.log || true)
276293 echo "--- summary ---"
277- PASS=$(grep -cE '^--- PASS:' /tmp/gorm-upstream.log)
278- FAIL=$(grep -cE '^--- FAIL:' /tmp/gorm-upstream.log)
279- SKIP=$(grep -cE '^--- SKIP:' /tmp/gorm-upstream.log)
280- echo "PASS=$PASS FAIL=$FAIL SKIP=$SKIP"
281- # Floor matches docs/gorm-upstream.md (386 PASS / 0 FAIL on
282- # 2026-05-26). If gorm adds tests, bump the floor; if it removes
283- # tests, this catches a silent regression.
294+ echo "PASS=$PASS FAIL=$FAIL SKIP=$SKIP go-test-exit=$rc"
295+ if [ "$rc" -ne 0 ]; then
296+ echo "::error::go test exited with $rc"
297+ exit "$rc"
298+ fi
284299 if [ "$FAIL" -ne 0 ]; then
285300 echo "::error::gorm upstream suite reports $FAIL failures"
286301 exit 1
287302 fi
288- if [ "$PASS" -lt 380 ]; then
289- echo "::error::gorm upstream PASS count regressed: got $PASS, expected >= 380"
303+ # PASS count includes sub-test lines (which are indented in the
304+ # file too) — for gorm v1.31.1 the total is ~15000. Floor at
305+ # 10000 to catch a "no tests ran at all" regression without
306+ # being brittle on minor gorm bumps.
307+ if [ "$PASS" -lt 10000 ]; then
308+ echo "::error::gorm upstream PASS count regressed: got $PASS, expected >= 10000"
290309 exit 1
291310 fi
0 commit comments