mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
/ship stops instead of running the whole test suite here when CI's run can't be reused (GST-3277) (#4565)
`gstack-ship-preflight` now stops with `SHIP_LANE_NOT_CARRIED` whenever a test suite mapped to CI has no reusable CI run, in a full preflight as well as `--tests-only`; `--run-uncarried-here` still runs it here. Why: a full preflight on gbrain-evals#547 ran the whole suite locally for 7 minutes after CI's run went stale, and the stop told an outside-author PR to dispatch a workflow that has no `workflow_dispatch` trigger. Nothing to do: a workflow that can't be dispatched now gets "merge the base and push it, or ask the author to" instead. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/adversarial-native#1 reader=adversarial-native
This commit is contained in:
1 parent
92c6c8a55c
commit
6121a19591
16 files changed
+149
-32
No files matched your search
@@ -0,0 +1 @@
|
||||
**/ship no longer starts the full test suite on your machine when CI's earlier run can't be reused (GST-3277).** A full `gstack-ship-preflight` now stops with `SHIP_LANE_NOT_CARRIED` whenever a mapped test lane has no verified CI run at this tree, whatever the reason (a base that moved after the run included), the same way `--tests-only` already did; `--run-uncarried-here` still runs the lane here, in either mode. When the lane's workflow has no `workflow_dispatch` trigger, or its run profile accepts no dispatched run, the stop no longer suggests a `gh workflow run` that would fail. It says to merge the base into the branch and push it, or to ask the pull request's author to. After a full preflight stops, it tells you to rerun with `--tests-only`, because rerunning the same full command would stop on its own open run.
|
||||
+2
-2
@@ -1370,8 +1370,8 @@ with every character outside `A-Za-z0-9._-` turned into `_` (`pnpm lint` is
|
||||
`pnpm_lint`, `db:test` is `db_test`), and `run`, `record-ci` and `check` all
|
||||
use that one spelling, so `check --label 'pnpm lint'` finds the row; `ci_carried`
|
||||
and `CI_CARRIED:` name the stored spelling. A mapped lane that cannot
|
||||
carry prints `CI_CARRY: none label=<label> (<reason>)` and runs here, except
|
||||
under `gstack-ship-preflight --tests-only`, which stops before any lane runs
|
||||
carry prints `CI_CARRY: none label=<label> (<reason>)`, and
|
||||
`gstack-ship-preflight`, full or `--tests-only`, then stops before any lane runs
|
||||
with [`SHIP_LANE_NOT_CARRIED`](troubleshooting.md#ship-lane-not-carried) unless
|
||||
it is given `--run-uncarried-here`. Every
|
||||
other lane runs through `gstack-evidence run --reuse`: the newest row for its
|
||||
|
||||
+1
-1
@@ -1300,7 +1300,7 @@ an hour or hide an empty diff (GST-3019):
|
||||
|
||||
| Code | When | Next |
|
||||
|---|---|---|
|
||||
| `SHIP_LANE_NOT_CARRIED` | `--tests-only` was given a lane `ship_lanes_from` maps, and no verified CI run carries it at this tree. Nothing runs, not even the other lanes. | Push, dispatch the workflow the `NEXT:` line names, `gstack-ci-carry wait`, rerun; or rerun with `--run-uncarried-here` to run it here. A full preflight still runs a lane that does not carry. [Troubleshooting](troubleshooting.md#ship-lane-not-carried) |
|
||||
| `SHIP_LANE_NOT_CARRIED` | A preflight, full or `--tests-only`, was given a lane `ship_lanes_from` maps, and no verified CI run carries it at this tree, whatever the `CI_CARRY: none` reason. Nothing runs, not even the other lanes. | Push and dispatch the workflow the `NEXT:` line names, or, when it cannot be dispatched, push a merge of the base (or ask the pull request's author to); `gstack-ci-carry wait`, rerun; or rerun with `--run-uncarried-here` to run it here. [Troubleshooting](troubleshooting.md#ship-lane-not-carried) |
|
||||
| `SHIP_BASE_UNKNOWN` | `--audit --base <base>` resolves to no commit: a sha-like value is tried as a commit first, then `origin/<base>`. | Fetch the base branch or the commit, then rerun. [Troubleshooting](troubleshooting.md#ship-base-unknown) |
|
||||
|
||||
A lane carries from a run at an earlier commit when git reads that commit's tree as HEAD's (a base merge
|
||||
|
||||
+14
-8
@@ -755,16 +755,17 @@ before the fetch instead of going on unprotected.
|
||||
process holding `<git dir>/gstack-leases/.lock`), then rerun.
|
||||
|
||||
<a id="ship-lane-not-carried"></a>
|
||||
### `STOP: SHIP_LANE_NOT_CARRIED: lane <label> did not carry from a verified CI run at this tree, and --tests-only never starts a lane on its own ...`
|
||||
### `STOP: SHIP_LANE_NOT_CARRIED: lane <label> did not carry from a verified CI run at this tree, and preflight never starts a mapped lane on its own ...`
|
||||
|
||||
**Meaning.** `gstack-ship-preflight --tests-only` was given a lane whose exact
|
||||
**Meaning.** `gstack-ship-preflight`, full or `--tests-only`, was given a lane whose exact
|
||||
command `origin/<base>`'s `.gstack/pregate.json` maps in `ship_lanes_from`,
|
||||
and no verified CI run carries it at this tree: the `CI_CARRY: none
|
||||
label=<label> (<reason>)` line above the STOP says why (`no_run`: CI has not
|
||||
run this tree yet; `dirty_tree`: uncommitted work). A mapped lane is the full
|
||||
suite, which can take most of an hour on a small machine (gbrain #9662: a
|
||||
50-minute unit lane on 4 CPUs), so `--tests-only` no longer starts it on its
|
||||
own (GST-3019).
|
||||
run this tree yet; `dirty_tree`: uncommitted work; `tree_mismatch`: the run
|
||||
tested a merge with an older base). A mapped lane is the full suite, which can
|
||||
take most of an hour on a small machine (gbrain #9662: a 50-minute unit lane on
|
||||
4 CPUs), so preflight never starts it on its own, whatever the reason (GST-3019;
|
||||
a full preflight did until GST-3277).
|
||||
|
||||
**What is kept.** Nothing ran: no lane, mapped or not, started. The pregate
|
||||
line above it is the pregate's own verdict.
|
||||
@@ -772,8 +773,13 @@ line above it is the pregate's own verdict.
|
||||
**Fix.** Follow the `NEXT:` lines. Commit and push the tree, dispatch the
|
||||
workflow they name (`gh workflow run <workflow> --ref <branch>`), wait with
|
||||
`gstack-ci-carry wait --base <base>`, and once it prints `CI_WAIT: green`
|
||||
rerun the same `--tests-only` command, which then carries the lane. To run the
|
||||
lane on this machine instead, rerun with `--run-uncarried-here`.
|
||||
rerun with `--tests-only` and the same `--lane` flags, which then carries the
|
||||
lane (a full preflight rerun with the same `--run` would stop on its open run). A workflow with no
|
||||
`workflow_dispatch` trigger, or a run profile that accepts no dispatched run,
|
||||
cannot be dispatched, so the `NEXT:` line says so: merge `origin/<base>` into
|
||||
the branch and push it, or, on a pull request you cannot push to, ask its
|
||||
author to. To run the lane on this machine instead, rerun with `--tests-only`
|
||||
and `--run-uncarried-here`.
|
||||
|
||||
**Expected result.** `LANE: <label> carried run=<id>/<attempt> …`, or with
|
||||
`--run-uncarried-here`, `LANE: <label> pass …` from the run here.
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ function newestVerified(src: RunSource, name: string, profile: RunProfile, heads
|
||||
const refusals: string[] = [];
|
||||
const docsOnly = src.docsOnly && ((sha: string) => src.docsOnly!(sha) && (sha === heads[0] || src.docsOnly!(heads[0]!)));
|
||||
for (const run of listed) {
|
||||
const v = verifyRun(src.deps, { repo: src.repo, runRef: String(run.id), profileName: name, profile, vetoHeads: heads, now: src.now, unchanged: src.unchanged, docsOnly });
|
||||
const v = verifyRun(src.deps, { repo: src.repo, runRef: String(run.id), profileName: name, profile, vetoHeads: heads, now: src.now, unchanged: src.unchanged, docsOnly, dispatchable: src.dispatchable?.(profile) });
|
||||
if (v.ok) return v;
|
||||
refusals.push(`run ${run.id}: ${v.reason}${v.reason === 'rerun_malformed' || v.reason === 'tree_log_unbound' || (v.reason === 'artifact_missing' && profile.tree_log_step) ? ` (${v.detail})` : ''}${v.fix ? ` (the pull request's base moved after the run; fix: ${v.fix})` : ''}`);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ export function findCarry(src: RunSource, o: { profiles: string[]; head: string;
|
||||
if (other) return no('tree_mismatch', `run ${other.run_id} tested tree ${other.tree.slice(0, 12)}, not ${o.tree.slice(0, 12)}`);
|
||||
const docsOnly = runs.every(e => e.docs_only);
|
||||
const empty = jobs.length || docsOnly ? undefined : runs.find(e => !e.files.length || e.tests === 0);
|
||||
if (empty) return no('no_tests', `run ${empty.run_id}'s tree.json ${empty.files.length ? 'records 0 tests' : `lists no test files (a rerun of only the failed jobs records none): dispatch a fresh full run of ${src.profiles[empty.profile]?.workflow ?? empty.profile} (gh workflow run ${src.profiles[empty.profile]?.workflow ?? '<workflow>'} --ref <branch>) and carry from that`}`);
|
||||
if (empty) return no('no_tests', `run ${empty.run_id}'s tree.json ${empty.files.length ? 'records 0 tests' : `lists no test files (a rerun of only the failed jobs records none): ${src.profiles[empty.profile] && src.dispatchable?.(src.profiles[empty.profile]!) === false ? `push a commit that starts a fresh full run of ${src.profiles[empty.profile]!.workflow} (it cannot be dispatched for this run profile)` : `dispatch a fresh full run of ${src.profiles[empty.profile]?.workflow ?? empty.profile} (gh workflow run ${src.profiles[empty.profile]?.workflow ?? '<workflow>'} --ref <branch>)`} and carry from that`}`);
|
||||
if (o.inventory && !docsOnly) {
|
||||
const listed = o.inventory();
|
||||
if ('error' in listed) return no('inventory_failed', listed.error);
|
||||
|
||||
@@ -277,7 +277,7 @@ function userPolicyChange(file: PregateFile): string | null {
|
||||
|
||||
export interface ClearInput { runUrl?: string; bundleLane?: string; receiptPath?: string; runs?: string[]; evidence?: RunCheck; flaky?: FlakyInput; allowRepoCommands?: boolean }
|
||||
/** What a run clear needs: the base branch's run profiles, the verifier's dependencies, the clock, and the remote gate's inventory. */
|
||||
export interface RunCheck { repo: string; deps: RunDeps; profiles: Record<string, RunProfile>; gateRuns: RemoteGateRuns | null; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean; inventory: (command: string, tree: string, selected?: string[]) => string[] | { error: string }; failures?: FailureDeps }
|
||||
export interface RunCheck { repo: string; deps: RunDeps; profiles: Record<string, RunProfile>; gateRuns: RemoteGateRuns | null; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean; dispatchable?: (p: RunProfile) => boolean; inventory: (command: string, tree: string, selected?: string[]) => string[] | { error: string }; failures?: FailureDeps }
|
||||
export type ClearDecision = { receipt: string; attested: boolean; substitution?: PregateReceiptSubstitution; exception?: PregateException } | { refused: 'usage' | 'PREGATE_RECEIPT_INVALID'; message: string; fix?: string };
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ import { wtreeFingerprint } from '../script-invocation';
|
||||
import { resolveBaseBranch } from '../ship-policy';
|
||||
import { normalizeRemoteUrl } from '../../crew/lib/ship-queue-train-record';
|
||||
import { REMOTE_GATE_LANE } from './checks/lanes';
|
||||
import { canDispatch } from './workflows';
|
||||
import { PREGATE_CONFIG_PATH, isConfigUnavailable, loadConfigFromBase, loadConfigFromHead } from './config';
|
||||
import type { RunCheck } from './index';
|
||||
|
||||
@@ -72,6 +73,7 @@ export function buildRunCheck(root: string, lane: string | null, allowRepoComman
|
||||
return {
|
||||
repo, deps: ghRunDeps(repo, root), failures: ghArtifactDeps(repo), profiles: loaded.config.run_profiles, gateRuns: loaded.config.remote_gate_runs, now: new Date(),
|
||||
unchanged: p => gateInputsChanged(root, base, p),
|
||||
dispatchable: p => canDispatch(root, policy === 'head' ? 'HEAD' : `origin/${base}`, p),
|
||||
docsOnly: head => {
|
||||
const mb = spawnSync('git', ['merge-base', `origin/${base}`, head], { cwd: root, encoding: 'utf8', timeout: 30_000 });
|
||||
try { return mb.status === 0 && classifyDocsOnly({ root, base: mb.stdout.trim(), head, policyRef: `origin/${base}` }).docsOnly; } catch { return false; }
|
||||
|
||||
@@ -227,6 +227,11 @@ export function workflowCallers(repoRoot: string, tree: string, workflow: string
|
||||
return { dispatch, jobName, callers };
|
||||
}
|
||||
|
||||
/** Whether a workflow_dispatch run of `profile.workflow` could carry: the workflow at git `ref` has the trigger and the run profile accepts the event. */
|
||||
export function canDispatch(repoRoot: string, ref: string, profile: { workflow: string; events: string[] }): boolean {
|
||||
return profile.events.includes('workflow_dispatch') && workflowCallers(repoRoot, ref, profile.workflow, '').dispatch;
|
||||
}
|
||||
|
||||
/** A regex source matching a display name GitHub renders from `name`: each `${{ … }}` expression matches any text without ` / `. */
|
||||
export function displayNamePattern(name: string): string {
|
||||
return name.split(/\$\{\{.*?\}\}/).map(s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('(?:(?! / ).)+?');
|
||||
|
||||
+5
-3
@@ -180,7 +180,7 @@ export const normalPath = (f: string): string => f.replace(/^(\.\/)+/, '');
|
||||
* The verdict for run `runRef` under `profile`. `vetoHeads` are further heads
|
||||
* whose newer runs of the same workflow can veto (the consumer's own head).
|
||||
*/
|
||||
export function verifyRun(deps: RunDeps, o: { repo: string; runRef: string; profileName: string; profile: RunProfile; vetoHeads?: string[]; ignoreRun?: number; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean }): RunVerdict {
|
||||
export function verifyRun(deps: RunDeps, o: { repo: string; runRef: string; profileName: string; profile: RunProfile; vetoHeads?: string[]; ignoreRun?: number; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean; dispatchable?: boolean }): RunVerdict {
|
||||
const id = parseRunRef(o.runRef, o.repo);
|
||||
if (id === null) return fail('run_ref_invalid', `${JSON.stringify(o.runRef)} is not a run id or a run URL on ${o.repo}`);
|
||||
const p = o.profile;
|
||||
@@ -251,7 +251,9 @@ export function verifyRun(deps: RunDeps, o: { repo: string; runRef: string; prof
|
||||
if (wrong.length) return fail('artifact_mismatch', `${at}'s ${p.artifact} records ${wrong.map(([k, got, want]) => `${k} ${String(got)} (expected ${want})`).join(', ')}`);
|
||||
const headTree = deps.commitTree(run.head_sha);
|
||||
if (!headTree) return fail('api_error', `git cannot read the tree of ${run.head_sha}`);
|
||||
const baseMoved = `gh workflow run ${p.workflow} --ref ${run.head_branch || '<branch>'}, then gstack-ci-carry wait`;
|
||||
const baseMoved = o.dispatchable === false
|
||||
? `push a merge of the base to ${run.head_branch || '<branch>'}, or ask the pull request's author to (${p.workflow} cannot be dispatched for this run profile), then gstack-ci-carry wait`
|
||||
: `gh workflow run ${p.workflow} --ref ${run.head_branch || '<branch>'}, then gstack-ci-carry wait`;
|
||||
if (rec.tree !== headTree) {
|
||||
const testedMerge = pr && typeof rec.sha === 'string' && SHA.test(rec.sha) && deps.commitTree(rec.sha) === rec.tree;
|
||||
if (testedMerge) return fail('tree_mismatch', `${at} tested merge commit ${(rec.sha as string).slice(0, 12)} (tree ${String(rec.tree)}), not its head ${run.head_sha.slice(0, 12)}'s tree ${headTree}: the pull request was behind its base (the base moved after the run, or the branch lacks its tip)`, baseMoved);
|
||||
@@ -377,7 +379,7 @@ export function uncoveredFiles(inventory: string[], evidence: RunEvidence[], ski
|
||||
|
||||
/** What a run check reads: the repository, the verifier's dependencies, the base branch's profiles and the clock. */
|
||||
/** `unchanged` (findCarry only): null when a profile's workflow and gate inputs match the base, else which file differs. */
|
||||
export interface RunSource { repo: string; deps: RunDeps; profiles: Record<string, RunProfile>; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean }
|
||||
export interface RunSource { repo: string; deps: RunDeps; profiles: Record<string, RunProfile>; now: Date; unchanged?: (p: RunProfile) => string | null; docsOnly?: (head: string) => boolean; dispatchable?: (p: RunProfile) => boolean }
|
||||
export type FromRunVerdict = { ok: true; evidence: RunEvidence; receipt: string } | { ok: false; reason: string; detail: string };
|
||||
|
||||
/**
|
||||
|
||||
+16
-11
@@ -11,6 +11,7 @@ import * as path from 'node:path';
|
||||
import { findCarry, laneMapping, mappingCoverage } from './ci-carry';
|
||||
import { defaultBaseBranch } from './default-base';
|
||||
import { isConfigUnavailable, loadConfigFromBase, loadConfigFromHead } from './pregate/config';
|
||||
import { canDispatch } from './pregate/workflows';
|
||||
import { buildRunCheck } from './pregate/run-check';
|
||||
import { classifyDiff } from './review-depth';
|
||||
import { wtreeFingerprint } from './script-invocation';
|
||||
@@ -24,9 +25,9 @@ export const PREFLIGHT_HELP = `gstack-ship-preflight — /ship Steps 1-3 and Ste
|
||||
--run <id> the /ship run (SESSION_ID, or the driver's run dir name): once Steps 1-3 pass it is recorded in
|
||||
this checkout's git dir and opened on its lease, and a later full preflight stops until finish
|
||||
clears it or 120 minutes pass, because its merge would move the tree the run's readers diff (GST-1204)
|
||||
--run-uncarried-here run a lane origin/<base> maps in ship_lanes_from here when its CI carry refuses; without it any
|
||||
refused carry stops with SHIP_LANE_NOT_CARRIED before any lane runs, naming the CI route (GST-3019, GST-3277)
|
||||
gstack-ship-preflight --tests-only --base <base> --lane <label>=<command>... Step 5 only (after a repair)
|
||||
--run-uncarried-here run a lane origin/<base> maps in ship_lanes_from here when its CI carry refuses; without it a refused
|
||||
carry stops with SHIP_LANE_NOT_CARRIED before any lane runs, naming the CI dispatch (GST-3019)
|
||||
--lanes serial|parallel how Step 5 runs its lanes; unset, one at a time on 4 or fewer cores, all at once above
|
||||
--policy-from head Step 5's pregate reads the branch's .gstack/pregate.json, which may only add test lanes
|
||||
(a branch that adds the lane for a file it touches); anything else is PREGATE_HEAD_POLICY_LOOSENS
|
||||
@@ -46,8 +47,8 @@ export const PREFLIGHT_HELP = `gstack-ship-preflight — /ship Steps 1-3 and Ste
|
||||
Prints at most 30 lines: BRANCH, STATUS, DIFF, PR/CARRY, APPLE, SCOPE, MERGE, DISTRIBUTION, POLICY,
|
||||
RUNTIME_LINES, PREGATE (with up to three PREGATE_DETAIL lines when it does not pass), LANES, one LANE line per lane
|
||||
(a lane the base maps in .gstack/pregate.json ship_lanes_from is carried from a verified CI run at this exact clean tree:
|
||||
LANE: <label> carried run=<id>/<attempt> tests_ran=<n>, else CI_CARRY: none (<reason>) and it runs, under --tests-only only with
|
||||
--run-uncarried-here; any other lane that
|
||||
LANE: <label> carried run=<id>/<attempt> tests_ran=<n>, else CI_CARRY: none (<reason>) and STOP: SHIP_LANE_NOT_CARRIED, or with
|
||||
--run-uncarried-here it runs here; any other lane that
|
||||
passed at this tree, command and runtime is reused: reused=<original time>), then NEXT: lines. STOP: names what the agent must
|
||||
decide or repair; nothing after it ran. Exit codes: 0 ok · 2 usage · 3 STOP`;
|
||||
|
||||
@@ -201,7 +202,7 @@ function merge(cwd: string, base: string, r: Report): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async function tests(cwd: string, base: string, list: { label: string; command: string }[], policyFrom: string, timeout: string | undefined, step: { seconds: number; source: string }, run: { concurrency: number; line: string; hold: boolean }, r: Report): Promise<void> {
|
||||
async function tests(cwd: string, base: string, list: { label: string; command: string }[], policyFrom: string, timeout: string | undefined, step: { seconds: number; source: string }, run: { concurrency: number; line: string; hold: boolean; testsOnly: boolean }, r: Report): Promise<void> {
|
||||
const pg = bin(cwd, 'gstack-pregate', ['--allow-repo-commands', '--base', base, '--policy-from', policyFrom, ...(timeout ? ['--timeout', timeout] : [])], step.seconds * 1000);
|
||||
if (pg.timedOut) {
|
||||
r.add(`PREGATE: time limit hit (Step 5's whole pregate ran past its ${step.seconds} s budget, ${step.source}, and was stopped with exit ${pg.status ?? 'none'}; no verdict)`);
|
||||
@@ -227,11 +228,16 @@ async function tests(cwd: string, base: string, list: { label: string; command:
|
||||
const lane = `lane${refused.length > 1 ? 's' : ''} ${names}`;
|
||||
const loaded = loadConfigFromBase(cwd, base);
|
||||
const mapped = mappedLanes(cwd, base, list);
|
||||
const workflows = isConfigUnavailable(loaded) ? [] : [...new Set(refused.flatMap(l => mapped.get(l.label)?.profiles ?? []).map(p => loaded.config.run_profiles?.[p]?.workflow).filter((w): w is string => !!w))];
|
||||
const profiles = isConfigUnavailable(loaded) ? [] : [...new Set(refused.flatMap(l => mapped.get(l.label)?.profiles ?? []))].map(p => loaded.config.run_profiles?.[p]).filter((p): p is NonNullable<typeof p> => !!p);
|
||||
const dispatch = profiles.map(p => canDispatch(cwd, `origin/${base}`, p));
|
||||
const workflows = [...new Set(profiles.filter((_, i) => dispatch[i]).map(p => p.workflow))];
|
||||
const pushOnly = [...new Set(profiles.filter((_, i) => !dispatch[i]).map(p => p.workflow))].filter(w => !workflows.includes(w));
|
||||
const branch = git(cwd, ['branch', '--show-current']).stdout.trim() || '<branch>';
|
||||
r.stop(`SHIP_LANE_NOT_CARRIED: ${lane} did not carry from a verified CI run at this tree, and --tests-only never starts a lane on its own: nothing ran here (docs/troubleshooting.md#ship-lane-not-carried)`);
|
||||
r.next(`commit and push this tree, then ${workflows.length ? workflows.map(w => `gh workflow run ${w} --ref ${branch}`).join(' and ') : 'run its CI workflow on the branch'} and gstack-ci-carry wait --base ${base}; once it prints CI_WAIT: green, rerun this command`);
|
||||
r.next(`or rerun this command with --run-uncarried-here to run ${lane} on this machine`);
|
||||
const rerun = run.testsOnly ? 'rerun this command' : `rerun with --tests-only --base ${base} and the same --lane flags`;
|
||||
r.stop(`SHIP_LANE_NOT_CARRIED: ${lane} did not carry from a verified CI run at this tree, and preflight never starts a mapped lane on its own: nothing ran here (docs/troubleshooting.md#ship-lane-not-carried)`);
|
||||
if (workflows.length || !pushOnly.length) r.next(`commit and push this tree, then ${workflows.length ? workflows.map(w => `gh workflow run ${w} --ref ${branch}`).join(' and ') : 'run its CI workflow on the branch'} and gstack-ci-carry wait --base ${base}; once it prints CI_WAIT: green, ${rerun}`);
|
||||
if (pushOnly.length) r.next(`${pushOnly.join(' and ')} cannot be dispatched for this run profile: merge origin/${base} into ${branch} and push it, or ask the pull request's author to; then gstack-ci-carry wait --base ${base}; once it prints CI_WAIT: green, ${rerun}`);
|
||||
r.next(`or ${rerun}${run.testsOnly ? ' with' : ', adding'} --run-uncarried-here to run ${lane} on this machine`);
|
||||
return;
|
||||
}
|
||||
const bad = results.filter(l => !l.ok);
|
||||
@@ -295,14 +301,13 @@ export async function preflight(argv: readonly string[], cwd: string): Promise<{
|
||||
const run = flag('--run');
|
||||
if (has('--run') && !(run && RUN_ID.test(run))) return { text: 'gstack-ship-preflight: --run needs a run id: letters, digits, dot, underscore or dash, at most 128\n', exit: 2 };
|
||||
if (has('--tests-only') && !list.length) return { text: 'gstack-ship-preflight: --tests-only needs at least one --lane <label>=<command>\n', exit: 2 };
|
||||
if (has('--run-uncarried-here') && !has('--tests-only')) return { text: 'gstack-ship-preflight: --run-uncarried-here goes with --tests-only (a full preflight runs a lane that does not carry here)\n', exit: 2 };
|
||||
if (has('--simulate')) return has('--tests-only') && policyFrom === 'head' && list.length ? simulate(cwd, base, list, has('--allow-repo-commands')) : { text: 'gstack-ship-preflight: --simulate needs --tests-only --policy-from head and at least one --lane <label>=<command>\n', exit: 2 };
|
||||
const mode = flag('--lanes');
|
||||
const concurrency = has('--lanes') && mode === undefined ? '--lanes needs serial or parallel' : laneConcurrency(mode);
|
||||
if (typeof concurrency === 'string') return { text: `gstack-ship-preflight: ${concurrency}\n`, exit: 2 };
|
||||
const r = new Report();
|
||||
if (has('--tests-only') || integrate(cwd, base, run, r)) {
|
||||
if (list.length) await tests(cwd, base, list, policyFrom, timeout, step, { concurrency, line: `LANES: ${concurrency === 1 ? 'serial' : 'parallel'} (${mode ? '--lanes' : `${os.availableParallelism()} cores`})`, hold: has('--tests-only') && !has('--run-uncarried-here') }, r);
|
||||
if (list.length) await tests(cwd, base, list, policyFrom, timeout, step, { concurrency, line: `LANES: ${concurrency === 1 ? 'serial' : 'parallel'} (${mode ? '--lanes' : `${os.availableParallelism()} cores`})`, hold: !has('--run-uncarried-here'), testsOnly: has('--tests-only') }, r);
|
||||
else if (r.exit === 0) r.next('Step 4: confirm the test framework, then rerun with --tests-only --lane <label>=<command> per suite (Step 5)');
|
||||
}
|
||||
return { text: r.render(), exit: r.exit };
|
||||
|
||||
@@ -412,6 +412,10 @@ export const KNOWN_WINDOWS_INCOMPATIBLE: Array<{ file: string; reason: string }>
|
||||
file: 'test/ship-ci-carry.test.ts',
|
||||
reason: 'drives bin/gstack-ship-release, gstack-evidence, gstack-ci-carry and gstack-pregate (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-release.test.ts; windows-latest fails every bin case at the first spawn (windows-scoped-shard, run 41607840098)',
|
||||
},
|
||||
{
|
||||
file: 'test/ship-preflight-carry-stop.test.ts',
|
||||
reason: 'drives bin/gstack-ship-preflight, gstack-ci-carry, gstack-evidence and gstack-pregate (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-ci-carry.test.ts, which windows-latest fails at the first bin spawn (windows-scoped-shard, run 41607840098)',
|
||||
},
|
||||
{
|
||||
file: 'test/ship-rereview-triggers.test.ts',
|
||||
reason: 'drives bin/gstack-ship-release, gstack-docs-candidate and gstack-wtree (shebangs) through test/helpers/ship-bin-fixture.ts like test/ship-release.test.ts; windows-latest fails every bin case at the first spawn (windows-free-shard 6, run 41193336209)',
|
||||
|
||||
@@ -234,7 +234,7 @@ merge-check code: `lib/ship-*`, `lib/pregate/*`, the ship and pregate bins,
|
||||
(`gstack-post pr-create --base <base> --draft --title-file <f> --body-file <f>`), then `gstack-ci-carry wait` in
|
||||
the background; once it prints `CI_WAIT: green`, rerun `--tests-only` and the mapped lane is carried. A red
|
||||
run is a failed lane: triage it below. Batch review fixes into one commit and one push. `CI_CARRY: none
|
||||
label=<l> (<reason>)` names why a mapped lane did not carry; under `--tests-only` that is `STOP: SHIP_LANE_NOT_CARRIED` before
|
||||
label=<l> (<reason>)` names why a mapped lane did not carry; any preflight then stops with `STOP: SHIP_LANE_NOT_CARRIED` before
|
||||
any lane runs: dispatch CI and wait as its `NEXT:` lines say, or rerun with `--run-uncarried-here` to run the lane here. A docs-only change ([docs/pregate.md#docs-only](../../docs/pregate.md#docs-only)) owes no test lane: pregate runs
|
||||
the docs lane, and a mapped lane prints `LANE: <label> not owed: docs-only change …` from CI's skipped run. Any other lane that already passed at this
|
||||
tree, command and runtime is reused (`reused=<time>`). In Step 16, `finish` defers a mapped
|
||||
|
||||
@@ -30,7 +30,7 @@ merge-check code: `lib/ship-*`, `lib/pregate/*`, the ship and pregate bins,
|
||||
(`gstack-post pr-create --base <base> --draft --title-file <f> --body-file <f>`), then `gstack-ci-carry wait` in
|
||||
the background; once it prints `CI_WAIT: green`, rerun `--tests-only` and the mapped lane is carried. A red
|
||||
run is a failed lane: triage it below. Batch review fixes into one commit and one push. `CI_CARRY: none
|
||||
label=<l> (<reason>)` names why a mapped lane did not carry; under `--tests-only` that is `STOP: SHIP_LANE_NOT_CARRIED` before
|
||||
label=<l> (<reason>)` names why a mapped lane did not carry; any preflight then stops with `STOP: SHIP_LANE_NOT_CARRIED` before
|
||||
any lane runs: dispatch CI and wait as its `NEXT:` lines say, or rerun with `--run-uncarried-here` to run the lane here. A docs-only change ([docs/pregate.md#docs-only](../../docs/pregate.md#docs-only)) owes no test lane: pregate runs
|
||||
the docs lane, and a mapped lane prints `LANE: <label> not owed: docs-only change …` from CI's skipped run. Any other lane that already passed at this
|
||||
tree, command and runtime is reused (`reused=<time>`). In Step 16, `finish` defers a mapped
|
||||
|
||||
@@ -774,7 +774,7 @@ describe('GST-3019: --tests-only never starts a lane on its own when its carry r
|
||||
const held = preflight(f);
|
||||
expect(held.status).toBe(3);
|
||||
expect(held.stdout).toContain('CI_CARRY: none label=free (no_run: ');
|
||||
expect(lineOf(held.stdout, 'STOP')).toBe('STOP: SHIP_LANE_NOT_CARRIED: lane free did not carry from a verified CI run at this tree, and --tests-only never starts a lane on its own: nothing ran here (docs/troubleshooting.md#ship-lane-not-carried)');
|
||||
expect(lineOf(held.stdout, 'STOP')).toBe('STOP: SHIP_LANE_NOT_CARRIED: lane free did not carry from a verified CI run at this tree, and preflight never starts a mapped lane on its own: nothing ran here (docs/troubleshooting.md#ship-lane-not-carried)');
|
||||
expect(held.stdout).toContain(`NEXT: commit and push this tree, then gh workflow run free.yml --ref ${branch} and gstack-ci-carry wait --base main; once it prints CI_WAIT: green, rerun this command`);
|
||||
expect(held.stdout).toContain('NEXT: or rerun this command with --run-uncarried-here to run lane free on this machine');
|
||||
expect([runs(f, 'free-runs'), runs(f, 'unit-runs')]).toEqual([0, 0]);
|
||||
@@ -783,7 +783,7 @@ describe('GST-3019: --tests-only never starts a lane on its own when its carry r
|
||||
expect(here.stdout).toContain('CI_CARRY: none label=free (no_run: ');
|
||||
expect(lane(here.stdout, 'free')).toMatch(/^LANE: free pass exit=0 tests_ran=3 /);
|
||||
expect([runs(f, 'free-runs'), runs(f, 'unit-runs')]).toEqual([1, 1]);
|
||||
expect(f.run(PREFLIGHT, ['--base', 'main', '--run-uncarried-here', '--lane', `free=${FREE}`]).status).toBe(2);
|
||||
expect(f.run(PREFLIGHT, ['--base', 'main', '--run-uncarried-here', '--lane', `free=${FREE}`]).status).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* GST-3277: every refused CI carry stops gstack-ship-preflight with SHIP_LANE_NOT_CARRIED before a mapped lane runs here, in a
|
||||
* full preflight as well as under --tests-only, unless --run-uncarried-here is passed; and the stop never suggests a
|
||||
* workflow_dispatch the lane's workflow cannot take. Fixture repository with a fake gh, so nothing reaches GitHub.
|
||||
*/
|
||||
import { afterEach, describe, expect, setDefaultTimeout, test } from 'bun:test';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { fakeGhScript, type FakeWorld } from './helpers/fake-gh-runs';
|
||||
import { lineOf, PREFLIGHT, shipFixture, type ShipFx } from './helpers/ship-bin-fixture';
|
||||
|
||||
setDefaultTimeout(120_000);
|
||||
const fixtures: ShipFx[] = [];
|
||||
afterEach(() => { while (fixtures.length) fixtures.pop()!.cleanup(); });
|
||||
|
||||
const FREE = "printf x >> ../free-runs; printf ' 3 pass\\n 0 fail\\nRan 3 tests across 1 file. [1.00ms]\\n' >&2";
|
||||
const fx = (on: string, events: string[]) => {
|
||||
const profile = { workflow: 'free.yml', events, jobs: ['suite'], artifact: 'tested-tree', os: 'Linux' };
|
||||
const f = shipFixture({
|
||||
'.gstack/pregate.json': JSON.stringify({ run_profiles: { 'ci/free': profile }, ship_lanes_from: { [FREE]: { profiles: ['ci/free'], inventory: "printf 'test/a.test.ts\\ntest/b.test.ts\\n'" } } }, null, 2) + '\n',
|
||||
'.github/workflows/free.yml': `name: Free\non: ${on}\njobs:\n suite:\n runs-on: ubuntu-latest\n steps:\n - run: bun test\n`,
|
||||
});
|
||||
fixtures.push(f);
|
||||
return f;
|
||||
};
|
||||
const freeRuns = (f: ShipFx) => { const p = path.join(f.root, 'free-runs'); return fs.existsSync(p) ? fs.readFileSync(p, 'utf8').length : 0; };
|
||||
const at = (minutesAgo: number) => new Date(Date.now() - minutesAgo * 60_000).toISOString();
|
||||
|
||||
/** One green pull_request run of free.yml at HEAD that tested a merge with an older origin/main: the base moved after the run. */
|
||||
function baseMovedWorld(f: ShipFx): void {
|
||||
const head = f.git('rev-parse', 'HEAD').stdout.trim();
|
||||
const merge = f.git('rev-parse', 'origin/main').stdout.trim();
|
||||
const run = { id: 7, run_attempt: 1, status: 'completed', conclusion: 'success', event: 'pull_request', head_sha: head, head_branch: 'feat', path: '.github/workflows/free.yml', created_at: at(20), run_started_at: at(20), updated_at: at(5), repository: { full_name: 'fx/fx' }, head_repository: { full_name: 'fx/fx' } };
|
||||
const w: FakeWorld = {
|
||||
runs: [run] as FakeWorld['runs'],
|
||||
jobs: { 7: [{ name: 'suite', conclusion: 'success', completed_at: at(5) }] },
|
||||
trees: { 7: { run_id: 7, run_attempt: 1, event: 'pull_request', sha: merge, head_sha: head, tree: f.git('rev-parse', 'origin/main^{tree}').stdout.trim(), files: ['test/a.test.ts', 'test/b.test.ts'], tests: 12, os: 'Linux' } },
|
||||
};
|
||||
const file = path.join(f.root, 'world.json');
|
||||
fs.writeFileSync(file, JSON.stringify(w));
|
||||
f.gh(fakeGhScript(file));
|
||||
}
|
||||
const STOP = 'STOP: SHIP_LANE_NOT_CARRIED: lane free did not carry from a verified CI run at this tree, and preflight never starts a mapped lane on its own: nothing ran here (docs/troubleshooting.md#ship-lane-not-carried)';
|
||||
|
||||
describe('GST-3277: a refused CI carry stops every preflight unless --run-uncarried-here', () => {
|
||||
// Value: protects=a full preflight (ship/DRIVER.md's Phase 2 call) stops on CI_CARRY: none instead of running the full suite here
|
||||
// (GBEV-115: 7 minutes of a keyless local suite on a base-moved tree_mismatch); fails_when=the mapped lane runs without the flag, the
|
||||
// stop has no code, or the flag no longer runs it here; why_new=GST-3277; seam=fake gh, gstack-ci-carry find, gstack-evidence ledger
|
||||
test('a full preflight with a base-moved tree_mismatch stops before the lane runs; --run-uncarried-here runs it here', () => {
|
||||
const f = fx('[pull_request, workflow_dispatch]', ['pull_request', 'workflow_dispatch']);
|
||||
baseMovedWorld(f);
|
||||
const held = f.run(PREFLIGHT, ['--base', 'main', '--lane', `free=${FREE}`]);
|
||||
expect(held.status, held.stdout + held.stderr).toBe(3);
|
||||
expect(held.stdout).toMatch(/^CI_CARRY: none label=free \(no_verified_run: ci\/free: run 7: tree_mismatch \(the pull request's base moved after the run; fix: gh workflow run free\.yml --ref /m);
|
||||
expect(lineOf(held.stdout, 'STOP')).toBe(STOP);
|
||||
expect(held.stdout).toContain('once it prints CI_WAIT: green, rerun with --tests-only --base main and the same --lane flags');
|
||||
expect(held.stdout).toContain('NEXT: or rerun with --tests-only --base main and the same --lane flags, adding --run-uncarried-here to run lane free on this machine');
|
||||
expect(held.stdout).not.toContain('rerun this command');
|
||||
expect(freeRuns(f)).toBe(0);
|
||||
const tests = f.run(PREFLIGHT, ['--tests-only', '--base', 'main', '--lane', `free=${FREE}`]);
|
||||
expect([tests.status, lineOf(tests.stdout, 'STOP'), freeRuns(f)]).toEqual([3, STOP, 0]);
|
||||
const here = f.run(PREFLIGHT, ['--base', 'main', '--run-uncarried-here', '--lane', `free=${FREE}`]);
|
||||
expect(here.status, here.stdout + here.stderr).toBe(0);
|
||||
expect(here.stdout).toContain('CI_CARRY: none label=free (no_verified_run: ');
|
||||
expect(here.stdout).toMatch(/^LANE: free pass exit=0 tests_ran=3 /m);
|
||||
expect(freeRuns(f)).toBe(1);
|
||||
});
|
||||
|
||||
// Value: protects=the stop never tells an outside-author PR to dispatch a workflow with no workflow_dispatch trigger (gbrain-evals ci.yml)
|
||||
// and names the ways that work: push a merge of the base, or ask the author to; fails_when=a gh workflow run is suggested for a
|
||||
// workflow that cannot take it, or the merge route is missing; why_new=GST-3277; seam=fake gh, .github/workflows trigger read from origin/main
|
||||
test('a workflow with no workflow_dispatch trigger gets the merge-and-push route, never a dispatch', () => {
|
||||
for (const [on, events] of [['[pull_request]', ['pull_request', 'workflow_dispatch']], ['[pull_request, workflow_dispatch]', ['pull_request']]] as const) {
|
||||
const f = fx(on, [...events]);
|
||||
baseMovedWorld(f);
|
||||
const branch = f.git('branch', '--show-current').stdout.trim();
|
||||
const held = f.run(PREFLIGHT, ['--tests-only', '--base', 'main', '--lane', `free=${FREE}`]);
|
||||
expect([on, held.status]).toEqual([on, 3]);
|
||||
expect(held.stdout).not.toContain('gh workflow run');
|
||||
expect(held.stdout).toContain(`fix: push a merge of the base to ${branch}, or ask the pull request's author to`);
|
||||
const find = f.run(path.join(path.dirname(PREFLIGHT), 'gstack-ci-carry'), ['find', '--base', 'main', '--command', FREE, '--allow-repo-commands']);
|
||||
expect(find.stdout).toContain(`fix: push a merge of the base to ${branch}, or ask the pull request's author to (free.yml cannot be dispatched for this run profile), then gstack-ci-carry wait)`);
|
||||
expect(find.stdout).not.toContain('gh workflow run');
|
||||
expect(held.stdout).toContain(`NEXT: free.yml cannot be dispatched for this run profile: merge origin/main into ${branch} and push it, or ask the pull request's author to; then gstack-ci-carry wait --base main; once it prints CI_WAIT: green, rerun this command`);
|
||||
expect(freeRuns(f)).toBe(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"bytes": 1,
|
||||
"why": "GST-3277: tests section says any preflight stops on a refused CI carry"
|
||||
}
|
||||
Reference in new issue
Block a user