@futurelastic/colab-handbook 1.20.1-rc.6 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tools/colab +13 -27
- package/tools/lib/batch-stats.js +11 -31
- package/tools/lib/git.js +0 -11
- package/tools/lib/ship-batch.js +11 -55
- package/tools/lib/stale-base.js +1 -40
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -12409,27 +12409,17 @@ function shipStaleBaseCheck(repoAbs, gh, base, branch) {
|
|
|
12409
12409
|
// the trunk-CI row reads (commit statuses on Forgejo) — never keyed on the gh flag, so a stale or red
|
|
12410
12410
|
// branch head cannot pass here as `unread` while the CI row passes on the forge's statuses.
|
|
12411
12411
|
const fc = forgeCi(repoAbs);
|
|
12412
|
-
let verifiedRun = null;
|
|
12413
12412
|
if (headSha && fc) run = fc.ciVerdict(headSha, { branch });
|
|
12414
|
-
else if (headSha && gh)
|
|
12415
|
-
// #691: one read, two summaries. `run` stays exactly what the stale-base and docs-only rows have
|
|
12416
|
-
// always read; `verifiedRun` applies the verifying-runs policy (#503) the trunk row uses, so the
|
|
12417
|
-
// head row below never refuses on a run that policy sets aside (a release lane, an ignored workflow).
|
|
12418
|
-
const rows = git.ghRunsForCommit(repoAbs, branch, headSha);
|
|
12419
|
-
run = git.summarizeRunsForCommit(rows, headSha);
|
|
12420
|
-
verifiedRun = git.summarizeRunsForCommit(rows, headSha, { verifying: verifyingPolicy(repoAbs), finishedRed: true });
|
|
12421
|
-
}
|
|
12413
|
+
else if (headSha && gh) run = git.ghRunForCommit(repoAbs, branch, headSha);
|
|
12422
12414
|
// #606: `run`/`headSha` are additive — the docs-only row reads whether that run finished red.
|
|
12423
12415
|
// #682: on a forge, `headCi` is the branch head's own CI verdict (green / red / pending), its own
|
|
12424
|
-
// row
|
|
12425
|
-
//
|
|
12426
|
-
|
|
12427
|
-
const headCi = fc ? staleBase.branchHeadCiVerdict({ headSha, run, branch, engine: fc.kind })
|
|
12428
|
-
: (gh ? staleBase.githubBranchHeadRedVerdict({ headSha, run: verifiedRun, branch }) : null);
|
|
12416
|
+
// row — the class code-ship B1a reads through `colab ci-wait` on GitHub. null on GitHub, and where
|
|
12417
|
+
// the head has no run to judge (the stale-base row speaks for those).
|
|
12418
|
+
const headCi = fc ? staleBase.branchHeadCiVerdict({ headSha, run, branch, engine: fc.kind }) : null;
|
|
12429
12419
|
return { ...staleBase.staleBaseVerdict({ headSha, run, baseTip, contains, behind, base, ciReadable: !!(fc || gh) }), run, headSha, headCi };
|
|
12430
12420
|
}
|
|
12431
12421
|
|
|
12432
|
-
/** #682: the branch-head CI row's name
|
|
12422
|
+
/** #682: the forge branch-head CI row's name — one spelling for the JSON and the prose table. */
|
|
12433
12423
|
const BRANCH_HEAD_CI_ROW = 'branch CI green at its head (#682)';
|
|
12434
12424
|
|
|
12435
12425
|
/**
|
|
@@ -13253,7 +13243,7 @@ function cmdShipDryJson(opts) {
|
|
|
13253
13243
|
} else {
|
|
13254
13244
|
checks.push({ name: 'branch run contains current base (#395)', ok: staleJson.ok,
|
|
13255
13245
|
class: staleJson.ok ? null : SELF_CLEARING, verdict: staleJson.verdict, detail: staleJson.detail });
|
|
13256
|
-
const hc = staleJson.headCi; // #682 forge
|
|
13246
|
+
const hc = staleJson.headCi; // #682: forge only — a red head needs a person, a running one clears
|
|
13257
13247
|
if (hc) checks.push({ name: BRANCH_HEAD_CI_ROW, ok: hc.ok, class: hc.ok ? null : (hc.selfClearing ? SELF_CLEARING : HUMAN_GATED), verdict: hc.verdict, detail: hc.detail });
|
|
13258
13248
|
}
|
|
13259
13249
|
// #610: the same gated heavy-lane read as the prose path. A missing or running heavy run clears on
|
|
@@ -15618,7 +15608,7 @@ function shipBatchLaneCheck(repoAbs, doc, trunk, target, gh, ciResult = null) {
|
|
|
15618
15608
|
let t = git.git(['log', '-1', '--format=%cI', x.sha], repoAbs);
|
|
15619
15609
|
if (!t.ok) { git.git(['fetch', '-q', remote, `refs/heads/${x.parsed.ref}`], repoAbs); t = git.git(['log', '-1', '--format=%cI', x.sha], repoAbs); }
|
|
15620
15610
|
const built = t.ok ? Date.parse(t.stdout.trim()) : NaN;
|
|
15621
|
-
return { ref: x.parsed.ref, base7: x.parsed.base7, rooted: true, verdict: shipBatch.combinedVerdict(runs
|
|
15611
|
+
return { ref: x.parsed.ref, base7: x.parsed.base7, rooted: true, verdict: shipBatch.combinedVerdict(runs),
|
|
15622
15612
|
builtAtMs: Number.isFinite(built) ? built : null, settledAtMs: shipBatch.settledAt(runs) };
|
|
15623
15613
|
});
|
|
15624
15614
|
const r = shipBatch.laneHold({ batches, trunkNow, nowMs: Date.now() });
|
|
@@ -15723,8 +15713,6 @@ function cmdShipBatch(opts) {
|
|
|
15723
15713
|
const repoAbs = resolveRepo(opts);
|
|
15724
15714
|
if (!git.repoRoot(repoAbs)) throw new UserError(`${repoAbs} is not a git repo`);
|
|
15725
15715
|
const doc = projectDoc(repoAbs);
|
|
15726
|
-
// #692: the combined run reads a wholly skipped workflow as #688 does, unless ship-gate-workflows names it.
|
|
15727
|
-
const batchRead = { verifying: verifyRuns.parsePolicy(doc) };
|
|
15728
15716
|
const trunk = resolveTrunk(repoAbs, doc);
|
|
15729
15717
|
if (!trunk) throw new UserError('Could not determine trunk branch (set project.yml trunk:)');
|
|
15730
15718
|
// #591: a member built on another machine names its hand-off inline — `<branch>@<hand-off-url>`.
|
|
@@ -15912,7 +15900,7 @@ function cmdShipBatch(opts) {
|
|
|
15912
15900
|
print(` ${want} is gone and ${atTip.parsed.ref} at ${trunk}'s tip carries this batch — its parent landed; resuming on ${trunk}'s tip`);
|
|
15913
15901
|
} else {
|
|
15914
15902
|
const pc = chains.get(want);
|
|
15915
|
-
const verdict = shipBatch.combinedVerdict(git.ghRunsForRef(repoAbs, want, p.sha)
|
|
15903
|
+
const verdict = shipBatch.combinedVerdict(git.ghRunsForRef(repoAbs, want, p.sha));
|
|
15916
15904
|
const child = rooted.find((x) => x !== p && p.sha.startsWith(x.parsed.base7)) || null;
|
|
15917
15905
|
if (verdict.state === 'red') {
|
|
15918
15906
|
if (child) {
|
|
@@ -15946,7 +15934,7 @@ function cmdShipBatch(opts) {
|
|
|
15946
15934
|
let foreignStep = null;
|
|
15947
15935
|
if (foreign.length) {
|
|
15948
15936
|
const runs = git.ghRunsForRef(repoAbs, atBase.parsed.ref, atBase.sha);
|
|
15949
|
-
foreignStep = shipBatch.foreignBatchStep(shipBatch.combinedVerdict(runs
|
|
15937
|
+
foreignStep = shipBatch.foreignBatchStep(shipBatch.combinedVerdict(runs), { settledAtMs: shipBatch.settledAt(runs), nowMs: Date.now() });
|
|
15950
15938
|
}
|
|
15951
15939
|
if (foreignStep && foreignStep.step === 'wait') {
|
|
15952
15940
|
print(`⏸ ship-batch: another batch is in flight at this base — ${atBase.parsed.ref} carries ${inBatch.map((m) => m.branch).join(', ')}${foreignStep.why ? ` (${foreignStep.why})` : ''}.`);
|
|
@@ -15975,7 +15963,7 @@ function cmdShipBatch(opts) {
|
|
|
15975
15963
|
}
|
|
15976
15964
|
}
|
|
15977
15965
|
}
|
|
15978
|
-
let verdict = existing && existing.matches ? shipBatch.combinedVerdict(git.ghRunsForRef(repoAbs, existing.ref, existing.sha)
|
|
15966
|
+
let verdict = existing && existing.matches ? shipBatch.combinedVerdict(git.ghRunsForRef(repoAbs, existing.ref, existing.sha)) : null;
|
|
15979
15967
|
// #610: integration-profile: gated — a wave lands only on a green heavy run at its head too. The
|
|
15980
15968
|
// heavy verdict joins the combined one (integration-profile.js waveVerdict), so a heavy red takes
|
|
15981
15969
|
// the same re-run / split path a light red does, and the split walks toward the culprit.
|
|
@@ -16977,7 +16965,7 @@ function cmdBatchStats(argv) {
|
|
|
16977
16965
|
if (!isGhUsable(repoAbs)) {
|
|
16978
16966
|
notes.push(`gh not usable (${ghUnusableWhy(repoAbs)}) — trunk commits only: no combined runs, no green times, no partner matching`);
|
|
16979
16967
|
} else {
|
|
16980
|
-
const jq = '.workflow_runs[] | [.id, .head_branch, .head_sha, .event, .status, .conclusion, .run_attempt, .created_at, .updated_at, (if ((.head_branch // "") | startswith("ship-batch/")) then .head_commit.message else null end)
|
|
16968
|
+
const jq = '.workflow_runs[] | [.id, .head_branch, .head_sha, .event, .status, .conclusion, .run_attempt, .created_at, .updated_at, (if ((.head_branch // "") | startswith("ship-batch/")) then .head_commit.message else null end)] | @json';
|
|
16981
16969
|
// One query per UTC day: GitHub answers at most 1000 rows for a filtered run list, and a busy
|
|
16982
16970
|
// repo passes that inside a fortnight. A day that still hits the cap is named, never hidden.
|
|
16983
16971
|
const days = [];
|
|
@@ -16992,9 +16980,7 @@ function cmdBatchStats(argv) {
|
|
|
16992
16980
|
if (!line.trim()) continue;
|
|
16993
16981
|
let a; try { a = JSON.parse(line); } catch (_) { continue; }
|
|
16994
16982
|
n++;
|
|
16995
|
-
|
|
16996
|
-
// ship's gate list and #688's per-workflow rule key on.
|
|
16997
|
-
runs.push({ id: a[0], branch: a[1], sha: a[2], event: a[3], status: a[4], conclusion: a[5], attempt: a[6], createdMs: Date.parse(a[7]), updatedMs: Date.parse(a[8]), message: a[9], workflowName: a[10] || undefined });
|
|
16983
|
+
runs.push({ id: a[0], branch: a[1], sha: a[2], event: a[3], status: a[4], conclusion: a[5], attempt: a[6], createdMs: Date.parse(a[7]), updatedMs: Date.parse(a[8]), message: a[9] });
|
|
16998
16984
|
}
|
|
16999
16985
|
if (n >= 1000) capped.push(day);
|
|
17000
16986
|
}
|
|
@@ -17017,7 +17003,7 @@ function cmdBatchStats(argv) {
|
|
|
17017
17003
|
|
|
17018
17004
|
const cfg = shipBatch.parseShipBatch(doc);
|
|
17019
17005
|
const waitCfg = shipBatch.parseShipBatchWait(doc);
|
|
17020
|
-
const rep = batchStats.derive({ commits, runs, builds, trunk, config: { n: cfg.n, waitSec: waitCfg.sec }
|
|
17006
|
+
const rep = batchStats.derive({ commits, runs, builds, trunk, config: { n: cfg.n, waitSec: waitCfg.sec } });
|
|
17021
17007
|
rep.repo = shortRepo(repoAbs);
|
|
17022
17008
|
rep.since = sinceIso;
|
|
17023
17009
|
rep.until = new Date(nowMs).toISOString();
|
package/tools/lib/batch-stats.js
CHANGED
|
@@ -64,12 +64,11 @@ const isBatchRef = (b) => String(b || '').startsWith(shipBatch.REF_PREFIX);
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* When did `branch` go green at the head it had at time `atMs`? Its runs created before `atMs` are
|
|
67
|
-
* read; the newest sha among them is the head at that moment. Green only when
|
|
68
|
-
*
|
|
67
|
+
* read; the newest sha among them is the head at that moment. Green only when every run at that sha
|
|
68
|
+
* finished success (cancelled aside, as combinedVerdict reads it) by `atMs` → the latest finish.
|
|
69
69
|
* Null when there is no run, or the head was not green yet — unknown, never a guess.
|
|
70
|
-
* `verifying` (#692): the ship's policy, so a wholly skipped workflow reads as the batch lane reads it.
|
|
71
70
|
*/
|
|
72
|
-
function greenAt(runsByBranch, branch, atMs, sha = null
|
|
71
|
+
function greenAt(runsByBranch, branch, atMs, sha = null) {
|
|
73
72
|
const rows = (runsByBranch.get(branch) || []).filter((r) => r.createdMs <= atMs);
|
|
74
73
|
if (!rows.length) return null;
|
|
75
74
|
const headSha = sha
|
|
@@ -77,28 +76,12 @@ function greenAt(runsByBranch, branch, atMs, sha = null, verifying = null) {
|
|
|
77
76
|
: rows.reduce((a, b) => (b.createdMs > a.createdMs ? b : a)).sha;
|
|
78
77
|
if (!headSha) return null;
|
|
79
78
|
const at = rows.filter((r) => r.sha === headSha);
|
|
80
|
-
const v = shipBatch.combinedVerdict(at.map(
|
|
79
|
+
const v = shipBatch.combinedVerdict(at.map((r) => ({ status: r.status, conclusion: r.conclusion, attempt: r.attempt })));
|
|
81
80
|
if (v.state !== 'green') return null;
|
|
82
81
|
const done = Math.max(...at.filter((r) => r.conclusion === 'success').map((r) => r.updatedMs));
|
|
83
82
|
return done <= atMs ? done : null;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
/**
|
|
87
|
-
* #692: the projection combinedVerdict reads. `workflowName` and `event` ride along so #688's rule
|
|
88
|
-
* (a wholly skipped workflow is not judged beside a run that can verify the code) reads these rows
|
|
89
|
-
* exactly as `colab ship --batch` reads its own. A side effect of the name, wanted for the same
|
|
90
|
-
* reason: #629 now applies here too, so a named workflow whose only run was cancelled no longer reads
|
|
91
|
-
* green beside another workflow's success. A row without the field stays unnamed, read as before.
|
|
92
|
-
*/
|
|
93
|
-
function verdictRow(r) {
|
|
94
|
-
return {
|
|
95
|
-
status: r.status, conclusion: r.conclusion, attempt: r.attempt, databaseId: r.id,
|
|
96
|
-
...(r.workflowName ? { workflowName: r.workflowName } : {}),
|
|
97
|
-
...(r.event ? { event: r.event } : {}),
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const verdictOpts = (verifying) => (verifying ? { verifying } : {});
|
|
101
|
-
|
|
102
85
|
/** Which feature branch carried a serial landing that closed `issues`, as of `atMs`? Newest run wins. */
|
|
103
86
|
function branchForIssues(runsByBranch, issues, atMs) {
|
|
104
87
|
if (!issues.length) return null;
|
|
@@ -117,17 +100,14 @@ function branchForIssues(runsByBranch, issues, atMs) {
|
|
|
117
100
|
/**
|
|
118
101
|
* The report. Inputs:
|
|
119
102
|
* commits [{ sha, dateMs, body }] — trunk first-parent, inside the window, any order
|
|
120
|
-
* runs [{ id, branch, sha, event, status, conclusion, attempt, createdMs, updatedMs, message
|
|
121
|
-
* workflowName? }]
|
|
103
|
+
* runs [{ id, branch, sha, event, status, conclusion, attempt, createdMs, updatedMs, message? }]
|
|
122
104
|
* `message` is the head commit's message, needed only for ship-batch/** rows
|
|
123
|
-
* verifying optional — the ship's verify-runs policy (`{gate, ignore}`, #692); absent, a skipped
|
|
124
|
-
* row reads red as before
|
|
125
105
|
* builds optional { [sha]: [message, …] } — every commit message of an UNLANDED build, when the
|
|
126
106
|
* caller could read them (compare API); a landed build is read from trunk instead
|
|
127
107
|
* trunk trunk branch name
|
|
128
108
|
* config { n, waitSec } — the repo's declared knobs, echoed so the report says what it tunes
|
|
129
109
|
*/
|
|
130
|
-
function derive({ commits = [], runs = [], builds = {}, trunk = 'main', config = {}
|
|
110
|
+
function derive({ commits = [], runs = [], builds = {}, trunk = 'main', config = {} } = {}) {
|
|
131
111
|
const notes = [];
|
|
132
112
|
const runsByBranch = new Map();
|
|
133
113
|
const trunkRuns = new Map(); // sha → rows
|
|
@@ -177,12 +157,12 @@ function derive({ commits = [], runs = [], builds = {}, trunk = 'main', config =
|
|
|
177
157
|
for (const l of landings) {
|
|
178
158
|
if (l.kind === 'batch') {
|
|
179
159
|
for (const m of l.members) {
|
|
180
|
-
changes.push({ landing: l, branch: m.branch, issues: branchName.branchIssueNumbers(m.branch), greenMs: greenAt(runsByBranch, m.branch, l.atMs, m.sha
|
|
160
|
+
changes.push({ landing: l, branch: m.branch, issues: branchName.branchIssueNumbers(m.branch), greenMs: greenAt(runsByBranch, m.branch, l.atMs, m.sha), atMs: l.atMs });
|
|
181
161
|
}
|
|
182
162
|
} else {
|
|
183
163
|
const br = branchForIssues(runsByBranch, l.issues, l.atMs);
|
|
184
164
|
l.branch = br;
|
|
185
|
-
changes.push({ landing: l, branch: br, issues: l.issues, greenMs: br ? greenAt(runsByBranch, br, l.atMs
|
|
165
|
+
changes.push({ landing: l, branch: br, issues: l.issues, greenMs: br ? greenAt(runsByBranch, br, l.atMs) : null, atMs: l.atMs });
|
|
186
166
|
}
|
|
187
167
|
}
|
|
188
168
|
|
|
@@ -191,7 +171,7 @@ function derive({ commits = [], runs = [], builds = {}, trunk = 'main', config =
|
|
|
191
171
|
const buildRows = [];
|
|
192
172
|
for (const [k, rows] of batchRuns) {
|
|
193
173
|
const [ref, sha] = k.split(' ');
|
|
194
|
-
const v = shipBatch.combinedVerdict(rows.map(
|
|
174
|
+
const v = shipBatch.combinedVerdict(rows.map((r) => ({ status: r.status, conclusion: r.conclusion, attempt: r.attempt, databaseId: r.id })));
|
|
195
175
|
const landed = landedHeads.has(sha);
|
|
196
176
|
const messages = landed ? null : (builds[sha] || rows.map((r) => r.message).filter(Boolean).slice(0, 1));
|
|
197
177
|
buildRows.push({ ref, sha, state: v.state, attempt: v.attempt, landed, createdMs: Math.min(...rows.map((r) => r.createdMs)), messages });
|
|
@@ -255,14 +235,14 @@ function derive({ commits = [], runs = [], builds = {}, trunk = 'main', config =
|
|
|
255
235
|
const via = tagVia ? { via: c.landing.kind === 'serial' ? 'serial' : 'batch-of-one' } : {};
|
|
256
236
|
for (const o of changes) {
|
|
257
237
|
if (o === c || o.landing === c.landing || o.atMs <= c.atMs || !o.branch || o.branch === c.branch) continue;
|
|
258
|
-
const gNow = greenAt(runsByBranch, o.branch, c.atMs
|
|
238
|
+
const gNow = greenAt(runsByBranch, o.branch, c.atMs);
|
|
259
239
|
if (gNow !== null) {
|
|
260
240
|
missed = true;
|
|
261
241
|
pairs.push({ kind: 'missed', landed: label, partner: o.branch, ...via });
|
|
262
242
|
continue;
|
|
263
243
|
}
|
|
264
244
|
if (end === null) continue;
|
|
265
|
-
const gEnd = greenAt(runsByBranch, o.branch, end
|
|
245
|
+
const gEnd = greenAt(runsByBranch, o.branch, end);
|
|
266
246
|
if (gEnd !== null && gEnd > c.atMs) {
|
|
267
247
|
near = true;
|
|
268
248
|
const from = c.greenMs !== null ? c.greenMs : c.atMs;
|
package/tools/lib/git.js
CHANGED
|
@@ -1280,12 +1280,6 @@ function summarizeRunsForCommit(allForSha, sha, opts = {}) {
|
|
|
1280
1280
|
...(allSkipped ? { allSkipped: true } : {}),
|
|
1281
1281
|
...(setAside.length ? { setAside: excludedRunSummary(setAside) } : {}),
|
|
1282
1282
|
...(dispatchCounted.length ? { dispatchCounted: excludedRunSummary(dispatchCounted) } : {}),
|
|
1283
|
-
// #691: opt-in (`opts.finishedRed`), so no reader that never asked sees a new field — every
|
|
1284
|
-
// JUDGED run that finished red: completed, and not success, cancelled or skipped (neither of
|
|
1285
|
-
// those two executed anything). The summary's single `conclusion` names only the first not-green
|
|
1286
|
-
// row it meets, which can be a `skipped` one beside a real failure; a caller asking "did any run
|
|
1287
|
-
// finish red here" reads this list instead. Absent when none did.
|
|
1288
|
-
...(opts && opts.finishedRed && judged.some(isFinishedRed) ? { finishedRed: excludedRunSummary(judged.filter(isFinishedRed)) } : {}),
|
|
1289
1283
|
// #651: the rows came from the unfiltered listing because the forge's filter index was empty.
|
|
1290
1284
|
...(allForSha.some((x) => x && x.readVia === 'unfiltered-listing') ? { readVia: 'unfiltered-listing' } : {}),
|
|
1291
1285
|
};
|
|
@@ -1293,11 +1287,6 @@ function summarizeRunsForCommit(allForSha, sha, opts = {}) {
|
|
|
1293
1287
|
return { ...r, ...extra };
|
|
1294
1288
|
}
|
|
1295
1289
|
|
|
1296
|
-
/** #691: a run that ran and failed — completed, and not success, cancelled or skipped. */
|
|
1297
|
-
function isFinishedRed(x) {
|
|
1298
|
-
return !!x && x.status === 'completed' && x.conclusion !== 'success' && x.conclusion !== 'cancelled' && x.conclusion !== 'skipped';
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1290
|
/** Sort key for "which run of one workflow is newer": createdAt, then databaseId; null = unknown. */
|
|
1302
1291
|
function runRecency(x) {
|
|
1303
1292
|
const t = x && x.createdAt ? Date.parse(x.createdAt) : NaN;
|
package/tools/lib/ship-batch.js
CHANGED
|
@@ -18,8 +18,6 @@
|
|
|
18
18
|
* semantic conflicts need no shared file. The combined run is the gate.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
const verifyRuns = require('./verify-runs');
|
|
22
|
-
|
|
23
21
|
// The SAFETY ceiling (#557): what any repo may declare, never what it gets. 3 until a red batch had
|
|
24
22
|
// a cheaper exit than N serial cycles; split-and-retry (nextStep's `split`) is that exit, so the
|
|
25
23
|
// ceiling is now 8 — the size from which bisection beats a serial fallback. A repo's own
|
|
@@ -386,71 +384,33 @@ function wiring(fires) {
|
|
|
386
384
|
* least one success. `attempt` is the highest run attempt seen — how many times it was re-run.
|
|
387
385
|
* Unlike summarizeRunsForCommit it does NOT reduce to the newest run per workflow (#461): a batch
|
|
388
386
|
* ref is built fresh and re-run in place (same run, higher `attempt`), so it carries no superseded
|
|
389
|
-
* attempts of a workflow for that reduction to set aside.
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* a named workflow whose every row is `skipped` executed nothing, so it is set aside beside a row
|
|
393
|
-
* that can verify the code, unless `ship-gate-workflows` names it. Measured shape (#688): a
|
|
394
|
-
* workflow with every job gated on an unset repository variable fires on the batch push, concludes
|
|
395
|
-
* skipped, and read every batch red. Without `opts.verifying` nothing is set aside — a skip reads
|
|
396
|
-
* red, as before; batchGreenCoversTrunk asks that strict reading on purpose.
|
|
387
|
+
* attempts of a workflow for that reduction to set aside. Nor does it set a wholly skipped workflow
|
|
388
|
+
* aside (#688): a skip here reads red, so a workflow gated off on `ship-batch/**` costs a split or
|
|
389
|
+
* a serial landing rather than a refusal of trunk.
|
|
397
390
|
*/
|
|
398
|
-
function combinedVerdict(rows
|
|
391
|
+
function combinedVerdict(rows) {
|
|
399
392
|
const list = Array.isArray(rows) ? rows : null;
|
|
400
393
|
if (list === null) return { state: 'pending', attempt: 1, runIds: [], why: 'the run list could not be read' };
|
|
401
394
|
const runIds = list.map((r) => r.databaseId).filter((x) => x !== null && x !== undefined);
|
|
402
395
|
const attempt = list.reduce((m, r) => Math.max(m, Number(r.attempt) || 1), 1);
|
|
403
396
|
if (list.length === 0) return { state: 'none', attempt, runIds, why: 'no run at the batch head yet' };
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const bad = judged.find((r) => r.status === 'completed' && r.conclusion !== 'success' && r.conclusion !== 'cancelled');
|
|
408
|
-
if (bad) {
|
|
409
|
-
const gated = bad.conclusion === 'skipped' && bad.workflowName && policy && Array.isArray(policy.gate) && policy.gate.includes(bad.workflowName);
|
|
410
|
-
return { state: 'red', attempt, runIds, why: gated
|
|
411
|
-
? `workflow "${bad.workflowName}" finished skipped — ${verifyRuns.GATE_KEY} names it, so it must run here (#692)`
|
|
412
|
-
: `a run finished ${bad.conclusion}` };
|
|
413
|
-
}
|
|
414
|
-
if (judged.some((r) => r.status !== 'completed')) return { state: 'pending', attempt, runIds, why: `a run is still in flight${note}` };
|
|
397
|
+
const bad = list.find((r) => r.status === 'completed' && r.conclusion !== 'success' && r.conclusion !== 'cancelled');
|
|
398
|
+
if (bad) return { state: 'red', attempt, runIds, why: `a run finished ${bad.conclusion}` };
|
|
399
|
+
if (list.some((r) => r.status !== 'completed')) return { state: 'pending', attempt, runIds, why: 'a run is still in flight' };
|
|
415
400
|
// #629 (the batch-ref twin of #628): a NAMED workflow whose rows here are all cancelled verified
|
|
416
401
|
// nothing, and another workflow's success must not carry the verdict for it — measured shape: the
|
|
417
402
|
// test workflow hung and was cancelled, a lint workflow passed, and the batch read green. A
|
|
418
403
|
// batch ref is re-run in place (same run, higher attempt), so a cancelled row is never a
|
|
419
404
|
// superseded straggler beside a newer run of its workflow; a same-workflow success still clears
|
|
420
405
|
// it. Unnamed rows (batch-stats.js projections, older fixtures) stay neutral, as in #628.
|
|
421
|
-
const succeeded = new Set(
|
|
422
|
-
const cancelledOnly =
|
|
406
|
+
const succeeded = new Set(list.filter((r) => r.conclusion === 'success' && r.workflowName).map((r) => r.workflowName));
|
|
407
|
+
const cancelledOnly = list.find((r) => r.workflowName && r.conclusion === 'cancelled' && !succeeded.has(r.workflowName));
|
|
423
408
|
if (cancelledOnly) {
|
|
424
409
|
const id = cancelledOnly.databaseId !== null && cancelledOnly.databaseId !== undefined ? ` (run ${cancelledOnly.databaseId})` : '';
|
|
425
410
|
return { state: 'red', attempt, runIds, why: `workflow "${cancelledOnly.workflowName}" never finished here — its only run${id} was cancelled, so it verified nothing; re-run it` };
|
|
426
411
|
}
|
|
427
|
-
if (
|
|
428
|
-
return { state: 'red', attempt, runIds, why:
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* #692: #688's rule (git.js setAsideWhollySkipped) for the rows at one batch head. A NAMED workflow
|
|
433
|
-
* whose every row is a finished `skipped` is set aside — returned as `skippedOnly` — when:
|
|
434
|
-
* - `ship-gate-workflows` does not name it. A named gate workflow that skipped reads red: the
|
|
435
|
-
* owner said exactly these must count. (git.js sets nothing aside once the list is declared,
|
|
436
|
-
* because its rows were already narrowed to the list; batch rows are not, so the test is per
|
|
437
|
-
* name.)
|
|
438
|
-
* - another row can verify the code (a verifying trigger, or no `event` field). All-skipped
|
|
439
|
-
* stays red (#514): nothing verified the batch.
|
|
440
|
-
* Unnamed rows are never set aside (#92). A workflow with any row that is not a finished skip is
|
|
441
|
-
* left whole, so its skipped row still reads red beside it, as before #692.
|
|
442
|
-
*/
|
|
443
|
-
function setAsideSkippedWorkflows(list, policy) {
|
|
444
|
-
const gate = policy && Array.isArray(policy.gate) ? policy.gate : null;
|
|
445
|
-
const isSkipped = (r) => !!r && r.status === 'completed' && r.conclusion === 'skipped';
|
|
446
|
-
const names = new Set(list.filter((r) => r && r.workflowName).map((r) => r.workflowName));
|
|
447
|
-
const wholly = new Set([...names].filter((n) => (!gate || !gate.includes(n))
|
|
448
|
-
&& list.every((r) => !r || r.workflowName !== n || isSkipped(r))));
|
|
449
|
-
const unchanged = { judged: list, skippedOnly: [] };
|
|
450
|
-
if (!wholly.size) return unchanged;
|
|
451
|
-
const rest = list.filter((r) => !r || !wholly.has(r.workflowName));
|
|
452
|
-
if (!rest.some((r) => !isSkipped(r) && verifyRuns.setAsideReason(r, null) === null)) return unchanged;
|
|
453
|
-
return { judged: rest, skippedOnly: list.filter((r) => r && wholly.has(r.workflowName)) };
|
|
412
|
+
if (list.some((r) => r.conclusion === 'success')) return { state: 'green', attempt, runIds, why: `${list.length} run(s): all success` };
|
|
413
|
+
return { state: 'red', attempt, runIds, why: 'every run was cancelled' };
|
|
454
414
|
}
|
|
455
415
|
|
|
456
416
|
/**
|
|
@@ -564,10 +524,6 @@ function givenUpRefs({ refs, members } = {}) {
|
|
|
564
524
|
* - the workflow FILES firing on a trunk push and on a `ship-batch/**` push are the same set;
|
|
565
525
|
* - there are at least as many batch rows as trunk-firing workflows.
|
|
566
526
|
* Anything else → false, and trunk waits for its own run exactly as today.
|
|
567
|
-
*
|
|
568
|
-
* #692: the batch rows are read WITHOUT the skipped-workflow rule (combinedVerdict with no policy).
|
|
569
|
-
* A workflow gated on the trunk ref is `skipped` on every batch ref, so a skip here would vouch for
|
|
570
|
-
* a trunk run that will execute; the stand-in needs every batch row to have run and passed.
|
|
571
527
|
*/
|
|
572
528
|
function batchGreenCoversTrunk({ trunkRows, batchRows, trunkFires, batchFires }) {
|
|
573
529
|
const t = Array.isArray(trunkRows) ? trunkRows : [];
|
package/tools/lib/stale-base.js
CHANGED
|
@@ -123,43 +123,4 @@ function branchHeadCiVerdict(a) {
|
|
|
123
123
|
`Wait with \`colab ci-wait --sha ${a.headSha} --branch ${a.branch}\`, then run ship again` };
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
* #691: the GitHub half of #682's row. On GitHub the branch head's class used to be left wholly to
|
|
128
|
-
* code-ship B1a (`colab ci-wait`), so `colab ship --dry --json` read READY on a head whose run had
|
|
129
|
-
* FINISHED red — measured on a required secret-scan job that failed before scanning anything. The
|
|
130
|
-
* row now refuses that one state, human-gated, in dry and real ship alike; everything else stays as
|
|
131
|
-
* it was on GitHub (null — no row):
|
|
132
|
-
*
|
|
133
|
-
* a run at the head finished red -> red, human-gated (red:infra or red:finding is B1a's call)
|
|
134
|
-
* green / in flight / no run / unread -> null: B1a's ci-wait still owns the wait, the stale-base
|
|
135
|
-
* row still speaks for `none` and an unread run
|
|
136
|
-
*
|
|
137
|
-
* "Finished red" is #606's docs-only rule (`docsOnlyBranchRow`): completed, and not success,
|
|
138
|
-
* cancelled or skipped — so a code branch is never held to a weaker rule than a docs-only one.
|
|
139
|
-
* `run` is the head's summary read under the verifying-runs policy (#503), the same rule the trunk
|
|
140
|
-
* row uses, so a run that policy sets aside (a release lane, a `ship-ignore-workflows` entry) never
|
|
141
|
-
* refuses here. `run.finishedRed` (tools/lib/git.js) lists every judged red run; without it the
|
|
142
|
-
* summary's own status/conclusion decides.
|
|
143
|
-
*
|
|
144
|
-
* @param {object} a
|
|
145
|
-
* @param {string|null} a.headSha - the branch head on the remote
|
|
146
|
-
* @param {object|null} a.run - summarizeRunsForCommit's verdict at headSha, verifying policy applied
|
|
147
|
-
* @param {string} a.branch
|
|
148
|
-
* @returns {null|{ok:false, verdict:'red', selfClearing:false, detail:string}}
|
|
149
|
-
*/
|
|
150
|
-
function githubBranchHeadRedVerdict(a) {
|
|
151
|
-
const run = a && a.run;
|
|
152
|
-
if (!a || !a.headSha || !run || run.status === 'none') return null;
|
|
153
|
-
const listed = Array.isArray(run.finishedRed) ? run.finishedRed : [];
|
|
154
|
-
const summaryRed = run.status === 'completed' && run.conclusion !== 'success' && run.conclusion !== 'cancelled' && run.conclusion !== 'skipped';
|
|
155
|
-
if (!listed.length && !summaryRed) return null;
|
|
156
|
-
const at = `${a.branch}@${String(a.headSha).slice(0, 7)} (GitHub Actions)`;
|
|
157
|
-
const failing = listed.length
|
|
158
|
-
? listed.map((x) => `${x.workflowName || 'run'} (${x.conclusion || 'none'})`).join(', ')
|
|
159
|
-
: `conclusion=${run.conclusion || 'none'}`;
|
|
160
|
-
return { ok: false, verdict: 'red', selfClearing: false,
|
|
161
|
-
detail: `${at} finished red — failing: ${failing}. A branch lands only on its own green (C7.contract.03): ` +
|
|
162
|
-
'red:infra → re-run once; red:finding → send it back (code-ship B1a)' };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
module.exports = { staleBaseVerdict, branchHeadCiVerdict, githubBranchHeadRedVerdict };
|
|
126
|
+
module.exports = { staleBaseVerdict, branchHeadCiVerdict };
|