Skip to content

ci(quality-gate): say what stopped the gate when it exits without a report - #1053

Merged
Tr00d merged 3 commits into
masterfrom
ci/gate-report-unexpected-exit
Dec 3, 2026
Merged

Tr00d merged 3 commits into
masterfrom
ci/gate-report-unexpected-exit

Conversation

@Tr00d

@Tr00d Tr00d commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Step 7 of the quality gate review, 3 of 3.

During #1049, a bug in the gate made it exit with no output at all. Under pipefail, a | head -n1 inside a $(...) killed the script. There was no report and no message, and finding the cause took a debugging round.

Changes

  • Crash message: an EXIT trap in gate.sh calls report_unexpected_exit in lib/common.sh. When the gate stops with a non-zero code and didn't mean to, it prints the failing command and the last stage it reported:
    gate.sh stopped unexpectedly (exit 5) on: v="$(jq -r .a <<<"{bad")"
    The last stage it reported: Build (Core). No report was written: this is a bug in the gate.
    
  • Intentional exits stay quiet:
    • The 10 usage and environment errors (exit 3) go through a new die helper. It prints the message as before and marks the exit as intended.
    • The normal end of a run marks its exit too, whatever the verdict.
    • Failures the code already tolerates, like code=$(curl …) || code="", don't trigger the trap.
  • Why an EXIT trap, not ERR: an ERR trap doesn't reach into functions without set -E. With set -E, it fires inside $(...) on failures the code already handles.

Tests

New suite fixtures-unexpected-exit/run.sh, 7 cases, added to the "Quality gate tests" CI job:

  • Real gate.sh:
    • an unknown option prints only its usage error
    • --help stays quiet
  • The library, sourced with the same trap:
    • a crash inside a function names the command
    • a crash names the last stage reported
    • a crash before any stage says no report was written
    • a tolerated failure stays quiet
    • die prints only its message

The real gate.sh can't be made to crash from outside without adding a test hook to it, which is why some cases use the library.

Verification

  • run-fixtures.sh: 57/57. compare-baselines: 12/12. compare-coverage: 7/7. identify-changes: 18/18. mark-api: 5/5. unexpected-exit: 7/7.
  • gate.sh packages locally, E2E included: GATE: PASS. A first run failed Functions and Gotrue E2E tests with "token is not valid yet" and invalid TOTP codes: the Docker VM's clock had drifted while the Mac slept. The clocks agreed again before the rerun.
  • After merging origin/master, which brought ci(quality-gate): report a non-blocking stage's finding as WARN #1051 and auto-merged the README, unexpected-exit still passes 7/7.

🤖 Generated with Claude Code

Tr00d and others added 2 commits December 3, 2026 08:40
…eport

A bug in the gate made it exit with no output at all, and finding the
cause took a debugging round. An EXIT trap now prints the command that
failed and the last stage the gate reported. Usage and environment
errors go through die and stay as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tr00d
Tr00d marked this pull request as ready for review December 3, 2026 07:42
bash 5 prints a here-string as <<< "x" where bash 3.2 prints <<<"x".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tr00d
Tr00d merged commit cc0e653 into master Dec 3, 2026
18 of 19 checks passed
@Tr00d
Tr00d deleted the ci/gate-report-unexpected-exit branch December 3, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant