@futurelastic/colab-handbook 1.13.0-rc.30 → 1.13.0-rc.32
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 +51 -9
- package/tools/lib/git.js +7 -2
- package/tools/lib/release-finalize.js +64 -3
- package/tools/lib/verify-runs.js +117 -4
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -1882,11 +1882,14 @@ under CONVENTIONS.md §6's release rung, re-checking everything at the moment it
|
|
|
1882
1882
|
|
|
1883
1883
|
Conditions (--json checks[].condition; required:false means reported, not blocking, on this row):
|
|
1884
1884
|
release-policy candidate tracking-issue release-hold regressions test-period trunk-green
|
|
1885
|
-
ci-green full-suite schema-additive switch-dependencies final-grant migration-grant human
|
|
1885
|
+
ci-green full-suite cut-run schema-additive switch-dependencies final-grant migration-grant human
|
|
1886
1886
|
|
|
1887
1887
|
regressions blocked_by edges on the tracking issue: open -> refused; closed after the period
|
|
1888
1888
|
began -> needs-new-candidate. Record one with: colab blocked <tracking> --by <issue>
|
|
1889
1889
|
test-period from max(candidate tag date, tracking issue creation), release: test-period long
|
|
1890
|
+
cut-run the run that cut the candidate (in progress at the tag's date) concluded success — a
|
|
1891
|
+
cancelled publish refuses; an earlier green run at the commit that cut nothing never
|
|
1892
|
+
vouches for it (#566)
|
|
1890
1893
|
trunk-green every run since the period began on main — and on project.yml's trunk: when that is
|
|
1891
1894
|
another branch (trunk: dev, #437) — of the workflows that ran at the candidate,
|
|
1892
1895
|
none red — required only where the final is automatic, or for an older --tag (#548)
|
|
@@ -2035,14 +2038,20 @@ function cmdReleaseFinalize(argv) {
|
|
|
2035
2038
|
if (!trackings.has(cand.version)) trackings.set(cand.version, trackingFor(cand.version, { isCandidate: true }));
|
|
2036
2039
|
const tracking = trackings.get(cand.version);
|
|
2037
2040
|
const supersededHeld = records.filter((r) => r.state === 'OPEN' && r.held && r.version !== cand.version && !finals.has(r.version)).map((r) => r.number);
|
|
2038
|
-
let rows;
|
|
2041
|
+
let rows; let rawRows;
|
|
2039
2042
|
const conditions = measureCandidateConditions(repoAbs, {
|
|
2040
2043
|
sha: cand.sha,
|
|
2041
2044
|
lastFinal: releaseTag.latestReleaseTag(repoAbs, { ref: cand.sha }),
|
|
2042
2045
|
at: `${cand.tag}@${shortSha(cand.sha)}`,
|
|
2043
|
-
readRuns: () => {
|
|
2046
|
+
readRuns: () => { rawRows = git.ghRunsAtCommit(repoAbs, cand.sha); rows = releaseCut.withoutOwnWorkflow(rawRows); return rows; }, // #425
|
|
2044
2047
|
issues,
|
|
2045
2048
|
});
|
|
2049
|
+
// #566: only the run that CUT the candidate vouches for what it published — read from the rows
|
|
2050
|
+
// BEFORE the #425 own-workflow filter (the release workflow is the cutter), minus this run itself.
|
|
2051
|
+
const cutRun = releaseFinalize.cutRunVerdict(rawRows, {
|
|
2052
|
+
tag: cand.tag, cutAt: cand.cutAt, ownRunId: process.env.GITHUB_ACTIONS === 'true' ? process.env.GITHUB_RUN_ID || null : null,
|
|
2053
|
+
jobCount: (id) => git.ghRunJobCount(repoAbs, id),
|
|
2054
|
+
});
|
|
2046
2055
|
const suiteWorkflows = [...new Set((rows || []).map((r) => r.workflowName || '(unnamed workflow)'))];
|
|
2047
2056
|
const period = releaseFinalize.periodVerdict({ cutAt: cand.cutAt, trackingCreatedAt: tracking && tracking.createdAt, testPeriodDays: policy.effective.testPeriodDays, now });
|
|
2048
2057
|
// #437: the window is main plus project.yml's trunk: when that is another branch (trunk: dev).
|
|
@@ -2066,7 +2075,7 @@ function cmdReleaseFinalize(argv) {
|
|
|
2066
2075
|
}
|
|
2067
2076
|
const verdict = releaseFinalize.decide({
|
|
2068
2077
|
policy, selection: sel, tracking, supersededHeld, period, trunk, regressions,
|
|
2069
|
-
ci: conditions.ci, suite: conditions.suite, schema: conditions.schema, switches: conditions.switches,
|
|
2078
|
+
ci: conditions.ci, suite: conditions.suite, cutRun, schema: conditions.schema, switches: conditions.switches,
|
|
2070
2079
|
manifests, ancestry, tags: tagNames, finalGrant, migrations,
|
|
2071
2080
|
human: { bar: humanBar, answeredBy: opts.answeredBy || null },
|
|
2072
2081
|
});
|
|
@@ -10951,6 +10960,37 @@ function noWorkflowTrunkDoor(repoAbs, r, target, trunk, branch) {
|
|
|
10951
10960
|
detail: `none — ${at} has no repo-owned workflow (#482), so the branch's own run decides, and ${ownAt} ${why}${excludedRunsNote(r.run)}` };
|
|
10952
10961
|
}
|
|
10953
10962
|
|
|
10963
|
+
/**
|
|
10964
|
+
* The verifying-runs policy every CI read uses (#503), plus the lost-push rescue's resolver (#567):
|
|
10965
|
+
* the names of the workflows whose definition AT THAT SHA is triggered by a branch push or a pull
|
|
10966
|
+
* request. Lazy — called only when a `workflow_dispatch` run has no push sibling — and fail-closed:
|
|
10967
|
+
* a sha that is not local, or a tree that cannot be read, yields null and the run stays set aside.
|
|
10968
|
+
*/
|
|
10969
|
+
function verifyingPolicy(repoAbs) {
|
|
10970
|
+
return { ...verifyRuns.parsePolicy(projectDoc(repoAbs)), dispatchVerifies: (sha) => pushVerifiedWorkflowsAt(repoAbs, sha) };
|
|
10971
|
+
}
|
|
10972
|
+
|
|
10973
|
+
function pushVerifiedWorkflowsAt(repoAbs, sha) {
|
|
10974
|
+
if (!sha) return null;
|
|
10975
|
+
if (!git.git(['cat-file', '-e', `${sha}^{commit}`], repoAbs).ok) {
|
|
10976
|
+
// Not local yet (another machine landed it): one fetch of that commit, then fail closed.
|
|
10977
|
+
git.git(['fetch', '--quiet', git.remoteFor(repoAbs) || 'origin', sha], repoAbs);
|
|
10978
|
+
if (!git.git(['cat-file', '-e', `${sha}^{commit}`], repoAbs).ok) return null;
|
|
10979
|
+
}
|
|
10980
|
+
const ls = git.git(['ls-tree', '--name-only', `${sha}:.github/workflows`], repoAbs);
|
|
10981
|
+
if (!ls.ok) return null;
|
|
10982
|
+
const names = [];
|
|
10983
|
+
for (const f of ls.stdout.split('\n').map((x) => x.trim()).filter((x) => /\.ya?ml$/.test(x))) {
|
|
10984
|
+
const rel = `.github/workflows/${f}`;
|
|
10985
|
+
const show = git.git(['show', `${sha}:${rel}`], repoAbs);
|
|
10986
|
+
if (!show.ok) continue;
|
|
10987
|
+
const t = verifyRuns.workflowTriggers(show.stdout);
|
|
10988
|
+
// GitHub names a workflow with no `name:` by its file path.
|
|
10989
|
+
if (t && t.verifiesBranches) names.push(t.name || rel);
|
|
10990
|
+
}
|
|
10991
|
+
return names;
|
|
10992
|
+
}
|
|
10993
|
+
|
|
10954
10994
|
/** Number of workflow files in `.github/workflows` at `sha`, or null when the tree cannot be read. */
|
|
10955
10995
|
function trunkWorkflowFiles(repoAbs, sha) {
|
|
10956
10996
|
if (!git.git(['cat-file', '-e', `${sha}^{commit}`], repoAbs).ok) return null;
|
|
@@ -10981,7 +11021,7 @@ function readCiVerdict(repoAbs, gh, target, trunk) {
|
|
|
10981
11021
|
if (!gh) return { run: null, final: true, verdict: { ok: false, class: SELF_CLEARING, detail: `gh not usable (${ghUnusableWhy(repoAbs)}) — cannot confirm CI` } };
|
|
10982
11022
|
// #503: only runs that VERIFY the code count — a post-CI release/deploy run at the same sha is set
|
|
10983
11023
|
// aside and named, never a red and never a reason to wait (tools/lib/verify-runs.js).
|
|
10984
|
-
const readOpts = { verifying:
|
|
11024
|
+
const readOpts = { verifying: verifyingPolicy(repoAbs) };
|
|
10985
11025
|
let run = git.ghRunForSha(repoAbs, target, undefined, undefined, readOpts);
|
|
10986
11026
|
let via = target;
|
|
10987
11027
|
if (run && run.status === 'none' && target !== trunk) {
|
|
@@ -11082,7 +11122,7 @@ function treeGreenVerdict(repoAbs, run, verdict) {
|
|
|
11082
11122
|
*/
|
|
11083
11123
|
function classifyCiRun(repoAbs, run, at) {
|
|
11084
11124
|
const v = classifyCiRunRaw(repoAbs, run, at);
|
|
11085
|
-
return { ...v, detail: v.detail + excludedRunsNote(run) + supersededRunsNote(run) + verifyRuns.setAsideNote(run && run.setAside) };
|
|
11125
|
+
return { ...v, detail: v.detail + excludedRunsNote(run) + supersededRunsNote(run) + verifyRuns.setAsideNote(run && run.setAside) + verifyRuns.dispatchCountedNote(run && run.dispatchCounted) };
|
|
11086
11126
|
}
|
|
11087
11127
|
|
|
11088
11128
|
/**
|
|
@@ -14585,7 +14625,8 @@ function cmdTrunkCi(argv) {
|
|
|
14585
14625
|
if (verdict === 'UNREADABLE' && gh && !git.ghState().ok) detail += ` (${ghUnusableWhy(repoAbs)})`;
|
|
14586
14626
|
out = { verdict, trunk, sha, ok: r.verdict.ok, class: r.verdict.class || null, detail,
|
|
14587
14627
|
...(r.verdict.treeGreen ? { cited: r.verdict.treeGreen } : {}),
|
|
14588
|
-
...(r.run && Array.isArray(r.run.setAside) && r.run.setAside.length ? { setAside: r.run.setAside } : {})
|
|
14628
|
+
...(r.run && Array.isArray(r.run.setAside) && r.run.setAside.length ? { setAside: r.run.setAside } : {}),
|
|
14629
|
+
...(r.run && Array.isArray(r.run.dispatchCounted) && r.run.dispatchCounted.length ? { dispatchCounted: r.run.dispatchCounted } : {}) };
|
|
14589
14630
|
if (key && verdict !== 'UNREADABLE' && sha === headSha) cache.put(key, out);
|
|
14590
14631
|
}
|
|
14591
14632
|
if (opts.json) {
|
|
@@ -14840,7 +14881,7 @@ function cmdCiWait(argv) {
|
|
|
14840
14881
|
if (!opts.json) for (const n of cp.notes) process.stderr.write(`ci-wait: ${n}\n`);
|
|
14841
14882
|
}
|
|
14842
14883
|
|
|
14843
|
-
const verifyPolicy =
|
|
14884
|
+
const verifyPolicy = verifyingPolicy(repoAbs);
|
|
14844
14885
|
const poll = (etag) => {
|
|
14845
14886
|
const r = git.ghApiConditional(repoAbs, apiPath, etag);
|
|
14846
14887
|
if (r.kind !== 'ok') return r;
|
|
@@ -14876,11 +14917,12 @@ function cmdCiWait(argv) {
|
|
|
14876
14917
|
waitedSec: Math.round(res.waitedMs / 1000), deadlineSec, deadlineBasis, detail: res.detail || null,
|
|
14877
14918
|
status: s.status || null, conclusion: s.conclusion || null, url: s.url || null,
|
|
14878
14919
|
...(Array.isArray(s.setAside) && s.setAside.length ? { setAside: s.setAside } : {}),
|
|
14920
|
+
...(Array.isArray(s.dispatchCounted) && s.dispatchCounted.length ? { dispatchCounted: s.dispatchCounted } : {}),
|
|
14879
14921
|
};
|
|
14880
14922
|
if (opts.json) print(JSON.stringify(out, null, 2));
|
|
14881
14923
|
else {
|
|
14882
14924
|
print(`${res.outcome} ${target} — waited ${ciWait.fmtDuration(res.waitedMs)}, ${res.polls} poll(s), ${res.notModified} of them 304` +
|
|
14883
|
-
`${s.status ? ` · ${s.status}${s.conclusion ? `/${s.conclusion}` : ''}` : ''}${s.url ? ` · ${s.url}` : ''}${res.detail ? ` — ${res.detail}` : ''}${verifyRuns.setAsideNote(s.setAside)}`);
|
|
14925
|
+
`${s.status ? ` · ${s.status}${s.conclusion ? `/${s.conclusion}` : ''}` : ''}${s.url ? ` · ${s.url}` : ''}${res.detail ? ` — ${res.detail}` : ''}${verifyRuns.setAsideNote(s.setAside)}${verifyRuns.dispatchCountedNote(s.dispatchCounted)}`);
|
|
14884
14926
|
}
|
|
14885
14927
|
return code;
|
|
14886
14928
|
}
|
package/tools/lib/git.js
CHANGED
|
@@ -1061,8 +1061,9 @@ function ghRunForCommit(repo, branch, sha, limit = 10, opts = {}) {
|
|
|
1061
1061
|
*/
|
|
1062
1062
|
function ghRunsAtCommit(repo, sha, limit = 100) {
|
|
1063
1063
|
if (!sha) return null;
|
|
1064
|
+
// updatedAt is additive (#566): release finalize places a run around the candidate's cut instant.
|
|
1064
1065
|
const r = gh(['run', 'list', '--commit', sha, '-L', String(limit),
|
|
1065
|
-
'--json', 'headSha,status,conclusion,createdAt,databaseId,workflowName,event'], { cwd: repo });
|
|
1066
|
+
'--json', 'headSha,status,conclusion,createdAt,updatedAt,databaseId,workflowName,event'], { cwd: repo });
|
|
1066
1067
|
if (!r.ok) return null;
|
|
1067
1068
|
let runs;
|
|
1068
1069
|
try { runs = JSON.parse(r.stdout); } catch (_) { return null; }
|
|
@@ -1143,7 +1144,8 @@ function excludedRunSummary(rows) {
|
|
|
1143
1144
|
* #503: `opts.verifying` (a tools/lib/verify-runs.js policy, `{gate, ignore}`) narrows the owned rows
|
|
1144
1145
|
* to the runs that VERIFY the code — push / pull-request triggered, or the declared set — BEFORE the
|
|
1145
1146
|
* per-workflow reduction; the rest (a `workflow_run` release, a scheduled finalize, a deploy) ride
|
|
1146
|
-
* along as `setAside`, each with its reason.
|
|
1147
|
+
* along as `setAside`, each with its reason. #567: a `workflow_dispatch` run the policy's
|
|
1148
|
+
* `dispatchVerifies` resolver rescues (lost push event) is counted and named in `dispatchCounted`. Opt-in: without `opts.verifying` nothing changes, so
|
|
1147
1149
|
* readers that never asked (release finalize, the base-ci advisory, ci-grant) read exactly as before.
|
|
1148
1150
|
*/
|
|
1149
1151
|
function summarizeRunsForCommit(allForSha, sha, opts = {}) {
|
|
@@ -1151,16 +1153,19 @@ function summarizeRunsForCommit(allForSha, sha, opts = {}) {
|
|
|
1151
1153
|
const dropped = allForSha.filter((x) => !isRepoOwnedRun(x));
|
|
1152
1154
|
let owned = dropped.length ? allForSha.filter(isRepoOwnedRun) : allForSha;
|
|
1153
1155
|
let setAside = [];
|
|
1156
|
+
let dispatchCounted = [];
|
|
1154
1157
|
if (opts && opts.verifying) {
|
|
1155
1158
|
const split = require('./verify-runs').splitVerifying(owned, opts.verifying);
|
|
1156
1159
|
owned = split.counted;
|
|
1157
1160
|
setAside = split.setAside;
|
|
1161
|
+
dispatchCounted = split.dispatchCounted || [];
|
|
1158
1162
|
}
|
|
1159
1163
|
const { heads, superseded } = newestRunPerWorkflow(owned);
|
|
1160
1164
|
const extra = {
|
|
1161
1165
|
...(dropped.length ? { excluded: excludedRunSummary(dropped) } : {}),
|
|
1162
1166
|
...(superseded.length ? { superseded: excludedRunSummary(superseded) } : {}),
|
|
1163
1167
|
...(setAside.length ? { setAside: excludedRunSummary(setAside) } : {}),
|
|
1168
|
+
...(dispatchCounted.length ? { dispatchCounted: excludedRunSummary(dispatchCounted) } : {}),
|
|
1164
1169
|
};
|
|
1165
1170
|
const r = summarizeRepoOwnedRuns(heads, sha);
|
|
1166
1171
|
return { ...r, ...extra };
|
|
@@ -77,7 +77,7 @@ const STATES = Object.freeze([
|
|
|
77
77
|
|
|
78
78
|
const CONDITIONS = Object.freeze([
|
|
79
79
|
'release-policy', 'candidate', 'tracking-issue', 'release-hold', 'regressions', 'test-period', 'trunk-green',
|
|
80
|
-
'ci-green', 'full-suite', 'schema-additive', 'switch-dependencies',
|
|
80
|
+
'ci-green', 'full-suite', 'cut-run', 'schema-additive', 'switch-dependencies',
|
|
81
81
|
...releaseTag.PRE_TAG_CONDITIONS, 'final-grant', 'migration-grant', 'human',
|
|
82
82
|
]);
|
|
83
83
|
|
|
@@ -319,6 +319,66 @@ function whyNoFinal({ state, candidate, checks, period, skipped, now } = {}) {
|
|
|
319
319
|
return { line, next };
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
// ---- the run that cut the candidate (#566) ------------------------------------------------------
|
|
323
|
+
|
|
324
|
+
// Slack around the tag's cut instant: the tagger date is the runner's clock, a run's createdAt /
|
|
325
|
+
// updatedAt are GitHub's, both to the second.
|
|
326
|
+
const CUT_RUN_SLACK_MS = 120000;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Did the run that CUT this candidate finish what it does after the cut? `rows` are the workflow
|
|
330
|
+
* runs at the candidate's commit (`git.ghRunsAtCommit`, null = unread), WITHOUT the #425 own-workflow
|
|
331
|
+
* filter — the release workflow is exactly the one this reads; only the calling run itself is dropped
|
|
332
|
+
* (`ownRunId`), since a run cannot vouch for or against itself while it is still running.
|
|
333
|
+
*
|
|
334
|
+
* The cutter is every run that was in progress at `cutAt` (the annotated tag's date): created no later
|
|
335
|
+
* than the cut, and either not finished or finished no earlier than it. Each one must have concluded
|
|
336
|
+
* `success`. Measured (#566): the run that cut a candidate had its image-publish job CANCELLED; ci-green
|
|
337
|
+
* and full-suite set that run aside as superseded (#461 — a cancelled run never stands for its workflow
|
|
338
|
+
* while that workflow has any other run at the sha) and counted an EARLIER run of the same workflow at
|
|
339
|
+
* the same commit that concluded success having cut nothing. finalize said candidate-ready for a
|
|
340
|
+
* candidate whose image did not exist. Here only the cutter vouches, and cancelled is a failure: a run
|
|
341
|
+
* cancelled after its cut may have stopped before its publish.
|
|
342
|
+
*
|
|
343
|
+
* A CANCELLED row whose job count `jobCount(databaseId)` reads 0 never ran — the measured shape of a
|
|
344
|
+
* pending run GitHub cancelled out of the release workflow's concurrency group when a newer one queued —
|
|
345
|
+
* so it cut nothing and is dropped. Asked lazily, only for a cancelled row; null (unread) keeps it.
|
|
346
|
+
*
|
|
347
|
+
* No run in progress at the cut → ok: the candidate was cut by hand (`colab release cut` outside a
|
|
348
|
+
* workflow), and no run owes it anything. A completed row with no `updatedAt` (an older read) cannot
|
|
349
|
+
* be placed around the cut and is not counted — absence of the field never refuses.
|
|
350
|
+
*
|
|
351
|
+
* Returns { ok, detail, runs } — `runs` the cutter rows' ids, for the report.
|
|
352
|
+
*/
|
|
353
|
+
function cutRunVerdict(rows, { tag, cutAt, ownRunId = null, jobCount = null } = {}) {
|
|
354
|
+
if (rows === null || rows === undefined) return { ok: false, detail: `the workflow runs at ${tag} could not be read — the run that cut it cannot be checked`, runs: [] };
|
|
355
|
+
const cut = Date.parse(cutAt);
|
|
356
|
+
if (Number.isNaN(cut)) return { ok: false, detail: `${tag} carries no readable cut time — the run that cut it cannot be found`, runs: [] };
|
|
357
|
+
const own = ownRunId === null || ownRunId === undefined || ownRunId === '' ? null : String(ownRunId);
|
|
358
|
+
const cutters = rows.filter((r) => {
|
|
359
|
+
if (!r || (own && String(r.databaseId) === own)) return false;
|
|
360
|
+
const created = Date.parse(r.createdAt);
|
|
361
|
+
if (Number.isNaN(created) || created > cut + CUT_RUN_SLACK_MS) return false;
|
|
362
|
+
if (r.status !== 'completed') return true;
|
|
363
|
+
const ended = Date.parse(r.updatedAt);
|
|
364
|
+
if (Number.isNaN(ended) || ended < cut - CUT_RUN_SLACK_MS) return false;
|
|
365
|
+
if (r.conclusion === 'cancelled' && typeof jobCount === 'function' && r.databaseId != null && jobCount(r.databaseId) === 0) return false;
|
|
366
|
+
return true;
|
|
367
|
+
});
|
|
368
|
+
const ids = cutters.map((r) => r.databaseId).filter((x) => x !== null && x !== undefined);
|
|
369
|
+
const name = (r) => `${r.workflowName || '(unnamed workflow)'} run ${r.databaseId != null ? r.databaseId : '(id unread)'}`;
|
|
370
|
+
if (!cutters.length) return { ok: true, detail: `no workflow run at ${tag} was in progress when it was cut (${cutAt}) — cut by hand, no run's publish to wait for`, runs: [] };
|
|
371
|
+
const bad = cutters.filter((r) => !(r.status === 'completed' && r.conclusion === 'success'));
|
|
372
|
+
if (!bad.length) return { ok: true, detail: `the run that cut ${tag} (${cutters.map(name).join(', ')}) concluded success`, runs: ids };
|
|
373
|
+
const how = (r) => (r.status === 'completed' ? `concluded ${r.conclusion || 'with no conclusion'}` : `is still ${r.status || 'running'}`);
|
|
374
|
+
const rerun = bad.filter((r) => r.status === 'completed' && r.databaseId != null).map((r) => `gh run rerun ${r.databaseId} --failed`);
|
|
375
|
+
return {
|
|
376
|
+
ok: false,
|
|
377
|
+
detail: `the run that cut ${tag} — ${bad.map((r) => `${name(r)} ${how(r)}`).join('; ')} — did not finish what it publishes after the cut (an image, a package, a Release): ${tag}'s artifacts may not exist. An earlier green run at the same commit that cut nothing cannot vouch for it (#566). ${rerun.length ? `Re-run it (${rerun.join('; ')}) and finalize again, or cut a new candidate.` : 'Wait for it to finish, then finalize again.'}`,
|
|
378
|
+
runs: ids,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
322
382
|
// ---- the test period ----------------------------------------------------------------------------
|
|
323
383
|
|
|
324
384
|
/**
|
|
@@ -480,6 +540,7 @@ function handoffCommand(tag) {
|
|
|
480
540
|
* trunk trunkGreenVerdict(...)
|
|
481
541
|
* regressions regressionVerdict(...)
|
|
482
542
|
* ci, suite, schema, switches { ok, detail }
|
|
543
|
+
* cutRun #566 — cutRunVerdict(): the run that cut the candidate concluded success
|
|
483
544
|
* finalGrant #441 — release-policy.js finalGrantVerdict() of policy.effective.finalGrant (only
|
|
484
545
|
* read when the policy carries one; absent = unresolved, never a grant)
|
|
485
546
|
* migrations #441 — migrationGrantVerdict() (only read when the policy carries a grant)
|
|
@@ -555,7 +616,7 @@ function decide(facts) {
|
|
|
555
616
|
add('test-period', per.elapsed, s.older && !auto ? `${per.detail} — required: an older candidate is finalized only once its own period elapsed clean (#548)` : per.detail, ownClock);
|
|
556
617
|
const tr = f.trunk || { ok: false, permanent: false, pending: false, detail: 'not measured' };
|
|
557
618
|
add('trunk-green', tr.ok, tr.detail, ownClock);
|
|
558
|
-
for (const [condition, v] of [['ci-green', f.ci], ['full-suite', f.suite], ['schema-additive', f.schema], ['switch-dependencies', f.switches]]) {
|
|
619
|
+
for (const [condition, v] of [['ci-green', f.ci], ['full-suite', f.suite], ['cut-run', f.cutRun], ['schema-additive', f.schema], ['switch-dependencies', f.switches]]) {
|
|
559
620
|
add(condition, v && v.ok, v ? v.detail : 'not measured');
|
|
560
621
|
}
|
|
561
622
|
// #424: before any final — the tag equals the manifests, the commit is on trunk, the version outranks the latest final.
|
|
@@ -637,7 +698,7 @@ module.exports = {
|
|
|
637
698
|
STATES, CONDITIONS, HOLD_LABEL, CUT_SUBJECT_SUFFIX,
|
|
638
699
|
parseVersion, compareVersions, parseCandidate,
|
|
639
700
|
parseReleaseMarker, releaseMarker, eventMarker, hasEvent, trackingTitle, trackingBody,
|
|
640
|
-
selectCandidate, openCandidates, pickNewestClean, stateDetail, windowHasRed, whyNoFinal, periodVerdict, trunkGreenVerdict, windowBranches, mergeWindowRuns, regressionVerdict,
|
|
701
|
+
selectCandidate, openCandidates, pickNewestClean, stateDetail, windowHasRed, whyNoFinal, periodVerdict, cutRunVerdict, trunkGreenVerdict, windowBranches, mergeWindowRuns, regressionVerdict,
|
|
641
702
|
handoffCommand, decide, tagMessage, migrationGrantVerdict,
|
|
642
703
|
carriedIssues, previousFinal, releasedEvent, releasedComment,
|
|
643
704
|
};
|
package/tools/lib/verify-runs.js
CHANGED
|
@@ -26,6 +26,19 @@
|
|
|
26
26
|
* ship-ignore-workflows: [Deploy] set these aside too, even when push-triggered (a deploy
|
|
27
27
|
* workflow that fires on a push to trunk). Wins over the gate
|
|
28
28
|
* list for a name in both.
|
|
29
|
+
*
|
|
30
|
+
* A LOST PUSH (#567). The forge can drop a trunk commit's `push` event (measured: a ship's push landed
|
|
31
|
+
* during a window of HTTP 500s and CI never started for that sha). Re-running is impossible (there is
|
|
32
|
+
* no run), and dispatching the same CI workflow at that sha produced a `workflow_dispatch` run the
|
|
33
|
+
* rule above set aside — so trunk stayed unmeasured until a human wrote an empty commit. Now: a
|
|
34
|
+
* `workflow_dispatch` run COUNTS when (a) its workflow's own definition at that sha is triggered by a
|
|
35
|
+
* branch push or a pull request — i.e. it is the workflow that verifies the code, not a release lane
|
|
36
|
+
* that merely accepts a manual trigger — and (b) no push / pull-request run of that same workflow is
|
|
37
|
+
* at the sha. (b) keeps the rescue narrow: where the push run exists, it is the verdict, as before.
|
|
38
|
+
* The caller supplies (a) as `policy.dispatchVerifies(sha) → string[] | null` (the workflow names, read
|
|
39
|
+
* from the tree at that sha — this module does no I/O); null / absent / unreadable → nothing is
|
|
40
|
+
* rescued, the run stays set aside (fail closed). With `ship-gate-workflows` declared this rescue is
|
|
41
|
+
* moot: the gate list already counts its workflows whatever their trigger.
|
|
29
42
|
*/
|
|
30
43
|
|
|
31
44
|
const VERIFYING_EVENTS = Object.freeze(['push', 'pull_request', 'pull_request_target', 'merge_group']);
|
|
@@ -77,17 +90,117 @@ function setAsideReason(row, policy) {
|
|
|
77
90
|
return VERIFYING_EVENTS.includes(ev) ? null : `event: ${ev}`;
|
|
78
91
|
}
|
|
79
92
|
|
|
80
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Split rows into `{ counted, setAside, dispatchCounted }`; each set-aside row carries `setAsideWhy`,
|
|
95
|
+
* and `dispatchCounted` lists the `workflow_dispatch` rows the lost-push rescue (#567) moved into
|
|
96
|
+
* `counted`. Null in → null out.
|
|
97
|
+
*/
|
|
81
98
|
function splitVerifying(rows, policy) {
|
|
82
99
|
if (!Array.isArray(rows)) return null;
|
|
83
100
|
const counted = [];
|
|
84
|
-
|
|
101
|
+
let setAside = [];
|
|
85
102
|
for (const r of rows) {
|
|
86
103
|
const why = setAsideReason(r, policy);
|
|
87
104
|
if (why) setAside.push({ ...r, setAsideWhy: why });
|
|
88
105
|
else counted.push(r);
|
|
89
106
|
}
|
|
90
|
-
|
|
107
|
+
const dispatchCounted = [];
|
|
108
|
+
const resolver = policy && typeof policy.dispatchVerifies === 'function' ? policy.dispatchVerifies : null;
|
|
109
|
+
const candidates = setAside.filter((x) => x.setAsideWhy === 'event: workflow_dispatch' && x.workflowName
|
|
110
|
+
&& !counted.some((c) => c.workflowName === x.workflowName));
|
|
111
|
+
if (resolver && candidates.length) {
|
|
112
|
+
const byShas = new Map();
|
|
113
|
+
const namesAt = (sha) => {
|
|
114
|
+
if (!byShas.has(sha)) {
|
|
115
|
+
let v = null;
|
|
116
|
+
try { v = resolver(sha); } catch (_) { v = null; }
|
|
117
|
+
byShas.set(sha, Array.isArray(v) ? v : null);
|
|
118
|
+
}
|
|
119
|
+
return byShas.get(sha);
|
|
120
|
+
};
|
|
121
|
+
const keep = [];
|
|
122
|
+
for (const x of setAside) {
|
|
123
|
+
const names = candidates.includes(x) && x.headSha ? namesAt(x.headSha) : null;
|
|
124
|
+
if (names && names.includes(x.workflowName)) {
|
|
125
|
+
const { setAsideWhy, ...row } = x;
|
|
126
|
+
counted.push(row);
|
|
127
|
+
dispatchCounted.push(row);
|
|
128
|
+
} else keep.push(x);
|
|
129
|
+
}
|
|
130
|
+
setAside = keep;
|
|
131
|
+
}
|
|
132
|
+
return { counted, setAside, dispatchCounted };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Strip a trailing ` # comment` and matching quotes from a one-line YAML scalar. */
|
|
136
|
+
function yamlScalar(raw) {
|
|
137
|
+
let v = String(raw).replace(/\s+#.*$/, '').trim();
|
|
138
|
+
if (v.length > 1 && ((v[0] === '"' && v.endsWith('"')) || (v[0] === "'" && v.endsWith("'")))) v = v.slice(1, -1);
|
|
139
|
+
return v;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const BRANCH_TRIGGERS = Object.freeze(['push', 'pull_request', 'pull_request_target', 'merge_group']);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* What one workflow file says about itself (#567): `{ name, verifiesBranches }`, or null when the text
|
|
146
|
+
* has no top-level `on:` at all. `name` is the top-level `name:` (null when absent — GitHub then names
|
|
147
|
+
* the workflow by its path, which the caller knows). `verifiesBranches` is true when the triggers
|
|
148
|
+
* include a pull request, or a push that is not tags-only (`push: { tags: [...] }` with no
|
|
149
|
+
* `branches`/`branches-ignore` is a release lane, never a code verifier). A deliberately small reader
|
|
150
|
+
* of the three `on:` shapes (scalar, flow list, block map / block list) — not a YAML parser.
|
|
151
|
+
*/
|
|
152
|
+
function workflowTriggers(text) {
|
|
153
|
+
const lines = String(text || '').split(/\r?\n/);
|
|
154
|
+
let name = null;
|
|
155
|
+
let onIdx = -1;
|
|
156
|
+
let onInline = null;
|
|
157
|
+
for (let i = 0; i < lines.length; i++) {
|
|
158
|
+
const l = lines[i];
|
|
159
|
+
let m = /^name:\s*(.*)$/.exec(l);
|
|
160
|
+
if (m && name === null) { name = yamlScalar(m[1]) || null; continue; }
|
|
161
|
+
m = /^(?:on|"on"|'on'|true):\s*(.*)$/.exec(l);
|
|
162
|
+
if (m && onIdx < 0) { onIdx = i; onInline = yamlScalar(m[1]); }
|
|
163
|
+
}
|
|
164
|
+
if (onIdx < 0) return null;
|
|
165
|
+
const events = new Map(); // event -> its child lines (block map form only)
|
|
166
|
+
if (onInline) {
|
|
167
|
+
const list = onInline.startsWith('[') ? onInline.replace(/^\[|\]$/g, '').split(',') : [onInline];
|
|
168
|
+
for (const e of list) { const v = yamlScalar(e); if (v) events.set(v, []); }
|
|
169
|
+
} else {
|
|
170
|
+
let evIndent = null;
|
|
171
|
+
let cur = null;
|
|
172
|
+
for (let i = onIdx + 1; i < lines.length; i++) {
|
|
173
|
+
const l = lines[i];
|
|
174
|
+
if (!l.trim() || /^\s*#/.test(l)) continue;
|
|
175
|
+
const indent = l.length - l.trimStart().length;
|
|
176
|
+
if (indent === 0) break;
|
|
177
|
+
if (evIndent === null) evIndent = indent;
|
|
178
|
+
if (indent < evIndent) break;
|
|
179
|
+
if (indent === evIndent) {
|
|
180
|
+
const t = l.trim();
|
|
181
|
+
const m = /^-\s*(.+)$/.exec(t) || /^([A-Za-z_]+)\s*:/.exec(t);
|
|
182
|
+
cur = m ? yamlScalar(m[1].replace(/:.*$/, '')) : null;
|
|
183
|
+
if (cur) events.set(cur, []);
|
|
184
|
+
} else if (cur) events.get(cur).push(l.trim());
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
let verifies = false;
|
|
188
|
+
for (const [ev, body] of events) {
|
|
189
|
+
if (!BRANCH_TRIGGERS.includes(ev)) continue;
|
|
190
|
+
if (ev !== 'push') { verifies = true; break; }
|
|
191
|
+
const keys = body.map((t) => (/^([A-Za-z_-]+)\s*:/.exec(t) || [])[1]).filter(Boolean);
|
|
192
|
+
const tagsOnly = (keys.includes('tags') || keys.includes('tags-ignore')) && !keys.includes('branches') && !keys.includes('branches-ignore');
|
|
193
|
+
if (!tagsOnly) { verifies = true; break; }
|
|
194
|
+
}
|
|
195
|
+
return { name, verifiesBranches: verifies };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** The compact verdict-detail note for rows the lost-push rescue counted — '' when none. */
|
|
199
|
+
function dispatchCountedNote(rows) {
|
|
200
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
201
|
+
if (!list.length) return '';
|
|
202
|
+
const names = list.map((x) => `${x.workflowName || 'unnamed'}${x.databaseId ? ` (run ${x.databaseId})` : ''}`);
|
|
203
|
+
return ` — counted ${list.length} workflow_dispatch run${list.length === 1 ? '' : 's'} of a push-verifying workflow with no push run at this sha (lost push event, #567): ${names.join(', ')}`;
|
|
91
204
|
}
|
|
92
205
|
|
|
93
206
|
/**
|
|
@@ -101,4 +214,4 @@ function setAsideNote(rows) {
|
|
|
101
214
|
return ` — set aside ${list.length} run${list.length === 1 ? '' : 's'} that do${list.length === 1 ? 'es' : ''} not verify the code (post-CI release/deploy lane, #503): ${names.join(', ')}`;
|
|
102
215
|
}
|
|
103
216
|
|
|
104
|
-
module.exports = { VERIFYING_EVENTS, GATE_KEY, IGNORE_KEY, parsePolicy, setAsideReason, splitVerifying, setAsideNote };
|
|
217
|
+
module.exports = { VERIFYING_EVENTS, GATE_KEY, IGNORE_KEY, parsePolicy, setAsideReason, splitVerifying, setAsideNote, workflowTriggers, dispatchCountedNote };
|