mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-22 08:01:32 +01:00
Pre-commit /verify fails on a timeout, and the review collector stops reading reviewers' scope lists as findings (GST-3201) (#4527)
Pre-commit /verify now fails a check that times out and runs its checks on one time budget; a reviewer's scope-list bullets no longer need an owner ruling to clear; stack tests fail when git can't list a PR's tests. Why: each let a result read clean with nothing proving it, or block on nothing (#4518, #4519). Goal: gates never pass on missing evidence. Nothing to do; `gstack-checks quick --timeout` is now one budget the checks share (540 s default). Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/outside-voice#1 reader=outside-voice Review-Finding: p1/outside-voice#2 reader=outside-voice
This commit is contained in:
1 parent
3cccf074ad
commit
bd449234aa
14 files changed
+197
-26
No files matched your search
+6
-3
@@ -21,7 +21,9 @@ const USAGE = `Usage: gstack-checks <detect|trust|run|status|quick> [options]
|
||||
runs nothing
|
||||
quick [--timeout <s>] the pre-commit pass: run's checks and tests with no consent prompt, ending with one line,
|
||||
VERIFY PASS|FAIL|skipped: <what>; untrusted commands, no pregate context or
|
||||
verify_before_commit=off skip instead of stopping; exit 1 only on FAIL
|
||||
verify_before_commit=off skip instead of stopping; exit 1 only on FAIL, and a TIMEOUT
|
||||
is a FAIL; --timeout (default 540) is one budget the checks share, and the test
|
||||
stage starts with what is left
|
||||
|
||||
--base <branch> the branch pregate selects against (default: origin/HEAD's branch, else main)
|
||||
|
||||
@@ -48,6 +50,7 @@ function loadOrRefuse(root: string, args: string[], timeoutMs: number): Loaded |
|
||||
const QUICK_RED_LINES = 10;
|
||||
|
||||
async function quick(root: string | null, args: string[], timeoutMs: number): Promise<number> {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
const skip = (why: string) => { process.stdout.write(`VERIFY skipped: ${why}\n`); return 0; };
|
||||
if (readConfigKey('verify_before_commit') === 'off') return skip('verify_before_commit is off (gstack-config set verify_before_commit on)');
|
||||
if (!root) return skip('not inside a git repository');
|
||||
@@ -60,7 +63,7 @@ async function quick(root: string | null, args: string[], timeoutMs: number): Pr
|
||||
if (nothingToRun(l)) return skip('the repo declares no checks or tests');
|
||||
if (!isTrusted(root, l.set)) return skip("the repo's check commands are not trusted yet; type /verify once to review them");
|
||||
for (const signal of ['SIGINT', 'SIGTERM'] as const) process.once(signal, () => { cancelActive(); process.exit(signal === 'SIGINT' ? 130 : 143); });
|
||||
const { outcomes } = await runChecks(l, { root, timeoutMs });
|
||||
const { outcomes } = await runChecks(l, { root, timeoutMs, deadline });
|
||||
const { line, red } = quickLine(outcomes);
|
||||
for (const o of red) for (const text of o.lines.slice(-QUICK_RED_LINES)) process.stdout.write(` | ${text}\n`);
|
||||
process.stdout.write(line + '\n');
|
||||
@@ -81,7 +84,7 @@ async function main(argv: string[]): Promise<number> {
|
||||
}
|
||||
const root = repoRoot();
|
||||
if (!root && verb !== 'quick') { process.stderr.write('gstack-checks: not inside a git repository\n'); return 3; }
|
||||
const timeoutS = Number(flag(args, '--timeout') ?? 600);
|
||||
const timeoutS = Number(flag(args, '--timeout') ?? (verb === 'quick' ? 540 : 600));
|
||||
if (!Number.isFinite(timeoutS) || timeoutS <= 0) { process.stderr.write('gstack-checks: --timeout needs a positive number of seconds\n'); return 64; }
|
||||
if (verb === 'quick') return quick(root, args, timeoutS * 1000);
|
||||
const l = loadOrRefuse(root, args, timeoutS * 1000);
|
||||
|
||||
Reference in new issue
Block a user