forgedock 1.57.0 → 1.59.0
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/bin/engine/outcome-codes.mjs +1 -1
- package/bin/engine-cli.mjs +2 -2
- package/bin/help-text.mjs +1 -1
- package/bin/lean/conformance.mjs +37 -5
- package/bin/lean/conformance.test.mjs +93 -0
- package/bin/lean/decisions.mjs +12 -0
- package/bin/lean/decisions.test.mjs +9 -0
- package/bin/lean/issuewatch-parity.mjs +4 -1
- package/bin/lean/issuewatch-parity.test.mjs +6 -0
- package/bin/lean/lean.mjs +44 -8
- package/bin/lean/lean.test.mjs +37 -4
- package/bin/lean/prompts.mjs +1 -1
- package/bin/lean/recovery.test.mjs +3 -3
- package/bin/lean/release-config.mjs +19 -8
- package/bin/lean/release-config.test.mjs +31 -0
- package/bin/lean/release-control.mjs +26 -3
- package/bin/lean/release-control.test.mjs +24 -0
- package/bin/lean/release-deploy.mjs +209 -0
- package/bin/lean/release-deploy.test.mjs +217 -0
- package/bin/lean/release-fixloop.mjs +108 -0
- package/bin/lean/release-fixloop.test.mjs +80 -0
- package/bin/lean/release-gates.mjs +230 -0
- package/bin/lean/release-gates.test.mjs +146 -0
- package/bin/lean/release-ledger.mjs +16 -0
- package/bin/lean/release-ledger.test.mjs +3 -3
- package/bin/lean/release-minutes.mjs +12 -2
- package/bin/lean/release-minutes.test.mjs +8 -0
- package/bin/lean/release-preflight.mjs +22 -0
- package/bin/lean/release-preflight.test.mjs +18 -2
- package/bin/lean/release-review.e2e.test.mjs +3 -2
- package/bin/lean/release-review.mjs +114 -31
- package/bin/lean/release-review.test.mjs +107 -20
- package/bin/lean/release-snapshot.mjs +32 -1
- package/bin/lean/release-snapshot.test.mjs +18 -1
- package/bin/lean/release-status.mjs +300 -0
- package/bin/lean/release-status.test.mjs +220 -0
- package/bin/lean/release-verify.mjs +221 -0
- package/bin/lean/release-verify.test.mjs +176 -0
- package/bin/lean/release.mjs +77 -7
- package/bin/lean/release.test.mjs +5 -1
- package/docs/CONFIG.md +20 -1
- package/package.json +1 -1
- package/scripts/ci-local/scoping.mjs +19 -0
- package/scripts/ci-local.test.sh +13 -0
|
@@ -40,13 +40,23 @@ export async function releaseMinutes({ gh, repo, sinceMs, branch = null }) {
|
|
|
40
40
|
return { runs: runs.length, minutes };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/** Records `{lane, minutes}` of the finished releases kept under `root` (the local cache of the ledger states). */
|
|
43
|
+
/** Records `{lane, minutes}` of the finished releases kept under `root` (the local cache of the ledger states); the array's non-enumerable `gates` property carries the #5583 gate records (see gateHistoryFromRoot). */
|
|
44
44
|
export function historyFromRoot(root) {
|
|
45
|
-
if (!existsSync(root)) return [];
|
|
45
|
+
if (!existsSync(root)) return Object.defineProperty([], "gates", { value: [], enumerable: false });
|
|
46
46
|
const out = [];
|
|
47
47
|
for (const id of readdirSync(root)) {
|
|
48
48
|
try { const s = JSON.parse(readFileSync(join(root, id, "state.json"), "utf8")); if (s?.minutes?.total > 0) out.push({ lane: s.lane ?? "release", minutes: s.minutes.total }); } catch { /* skip */ }
|
|
49
49
|
}
|
|
50
|
+
return Object.defineProperty(out, "gates", { value: gateHistoryFromRoot(root), enumerable: false });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Gate telemetry records (#5583) of the releases kept under `root`, oldest release first, each with `release` and `at`; [] when none. */
|
|
54
|
+
export function gateHistoryFromRoot(root) {
|
|
55
|
+
if (!existsSync(root)) return [];
|
|
56
|
+
const out = [];
|
|
57
|
+
for (const id of readdirSync(root).sort()) {
|
|
58
|
+
try { const s = JSON.parse(readFileSync(join(root, id, "state.json"), "utf8")); for (const g of Array.isArray(s?.gates) ? s.gates : []) out.push({ ...g, release: id, at: s.startedAt }); } catch { /* skip */ }
|
|
59
|
+
}
|
|
50
60
|
return out;
|
|
51
61
|
}
|
|
52
62
|
|
|
@@ -50,6 +50,14 @@ describe("release minutes (#5569)", () => {
|
|
|
50
50
|
assert.deepEqual(historyFromRoot(root), [{ lane: "release", minutes: 480 }]);
|
|
51
51
|
assert.deepEqual(historyFromRoot(join(root, "none")), []);
|
|
52
52
|
});
|
|
53
|
+
it("historyFromRoot carries the gate records on a non-enumerable gates property (#5583)", () => {
|
|
54
|
+
const root = tmpDir("rm");
|
|
55
|
+
mkdirSync(join(root, "a")); writeFileSync(join(root, "a", "state.json"), JSON.stringify({ minutes: { total: 5 }, startedAt: "t", gates: [{ gate: "g", outcome: "fail", class: "FB", minutes: 2 }] }));
|
|
56
|
+
const h = historyFromRoot(root);
|
|
57
|
+
assert.deepEqual(h, [{ lane: "release", minutes: 5 }]);
|
|
58
|
+
assert.deepEqual(h.gates.map((g) => [g.gate, g.release]), [["g", "a"]]);
|
|
59
|
+
assert.deepEqual(historyFromRoot(join(root, "none")).gates, []);
|
|
60
|
+
});
|
|
53
61
|
});
|
|
54
62
|
|
|
55
63
|
describe("release report (#5569)", () => {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* retries. With no command set every function here is a no-op. No model call. Effects go through `ctx.io`.
|
|
8
8
|
*/
|
|
9
9
|
import { fileBlocker, tail } from "./release-rehearsal.mjs";
|
|
10
|
+
import { fenced } from "./release-fence.mjs";
|
|
10
11
|
|
|
11
12
|
export const PREFLIGHT_TIMEOUT_MS = 20 * 60_000;
|
|
12
13
|
const json = (s) => JSON.parse(String(s || "null"));
|
|
@@ -56,3 +57,24 @@ export async function markReadyStep(ctx) {
|
|
|
56
57
|
if (view?.isDraft) await io.gh(["pr", "ready", String(pr), "--repo", repo]);
|
|
57
58
|
return { ...r, ready: true, wasDraft: !!view?.isDraft };
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* #5567: CI and the review panel start together on the same head. When `ci.fix` is configured (`co_start` or `full_run_workflow`),
|
|
63
|
+
* the draft release PR is marked ready before the review (the host preflight already passed on this head), and the repo's uncached
|
|
64
|
+
* full run is requested in that same pass through the configured workflow, fenced like any dispatch. Unconfigured: nothing happens.
|
|
65
|
+
* @returns {{skipped: true}|{ready: boolean, fullRun: boolean}|{refused: string}}
|
|
66
|
+
*/
|
|
67
|
+
export async function coStartCi(ctx, { pr }) {
|
|
68
|
+
const fix = ctx.config?.fix;
|
|
69
|
+
if (!fix?.coStart) return { skipped: true };
|
|
70
|
+
const { io, repo } = ctx;
|
|
71
|
+
const view = json(await io.gh(["pr", "view", String(pr), "--repo", repo, "--json", "headRefOid,headRefName,isDraft"]));
|
|
72
|
+
if (view?.isDraft) await io.gh(["pr", "ready", String(pr), "--repo", repo]);
|
|
73
|
+
let fullRun = false;
|
|
74
|
+
if (fix.fullRunWorkflow) {
|
|
75
|
+
const f = await fenced(ctx.fence, { action: "dispatch", key: `fullrun:${pr}:${view?.headRefOid}` }, (epoch) => io.gh(["workflow", "run", fix.fullRunWorkflow, "--repo", repo, "--ref", view?.headRefName, ...(epoch != null ? ["-f", `forge_epoch=${epoch}`] : [])]));
|
|
76
|
+
if (f.refused) return { refused: f.refused };
|
|
77
|
+
fullRun = true;
|
|
78
|
+
}
|
|
79
|
+
return { ready: true, wasDraft: !!view?.isDraft, fullRun };
|
|
80
|
+
}
|
|
@@ -4,7 +4,7 @@ import { describe, it } from "node:test";
|
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
6
6
|
import { runRelease, withStubs, readReleaseConfig, newReleaseId } from "./release.mjs";
|
|
7
|
-
import { parsePreflightConfig, markReadyStep } from "./release-preflight.mjs";
|
|
7
|
+
import { parsePreflightConfig, markReadyStep, coStartCi } from "./release-preflight.mjs";
|
|
8
8
|
import { fixStep } from "./release-review.mjs";
|
|
9
9
|
|
|
10
10
|
const DISK = [{ mount: "/", type: "ext4" }];
|
|
@@ -100,7 +100,7 @@ describe("release host preflight (#5277)", () => {
|
|
|
100
100
|
const mk = (pfOk) => {
|
|
101
101
|
const io = fakeIo({ preflightOk: () => pfOk });
|
|
102
102
|
const seam = {
|
|
103
|
-
headOf: async () => HEAD, runLane: async () => ({ terminalReason: "merged" }),
|
|
103
|
+
headOf: async () => HEAD, runLane: async () => ({ terminalReason: "merged" }), fileFixIssue: async () => 3, failedJobs: async () => [],
|
|
104
104
|
calls: [],
|
|
105
105
|
};
|
|
106
106
|
return { io, seam, ctx: { io: Object.assign(io, { review: seam }), repo: REPO, def: "main", staging: "staging", config: CFG, save() {}, state: { steps: { review: { result: { pr: 9, marker: "FORGE:GATE_FAILURE", verdict: "X", head: "b".repeat(40), blocking: [11], ciFailing: 0 } } } } } };
|
|
@@ -112,3 +112,19 @@ describe("release host preflight (#5277)", () => {
|
|
|
112
112
|
assert.equal(red.io.ran.length, 1);
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
|
+
|
|
116
|
+
describe("co-start CI (#5567)", () => {
|
|
117
|
+
it("unconfigured: zero writes (no gh call at all)", async () => {
|
|
118
|
+
const calls = [];
|
|
119
|
+
const r = await coStartCi({ io: { gh: async (a) => { calls.push(a); return "{}"; } }, repo: REPO, config: {} }, { pr: 9 });
|
|
120
|
+
assert.deepEqual(r, { skipped: true });
|
|
121
|
+
assert.deepEqual(calls, []);
|
|
122
|
+
});
|
|
123
|
+
it("configured: marks the draft ready and requests the full run on the same head", async () => {
|
|
124
|
+
const calls = [];
|
|
125
|
+
const gh = async (a) => { calls.push(a.join(" ")); return a[1] === "view" ? JSON.stringify({ headRefOid: HEAD, headRefName: "release/x", isDraft: true }) : ""; };
|
|
126
|
+
const r = await coStartCi({ io: { gh }, repo: REPO, config: { fix: { coStart: true, fullRunWorkflow: "full.yml" } } }, { pr: 9 });
|
|
127
|
+
assert.deepEqual(r, { ready: true, wasDraft: true, fullRun: true });
|
|
128
|
+
assert.ok(calls.some((c) => c.startsWith("pr ready")) && calls.some((c) => c.startsWith("workflow run full.yml")));
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -39,7 +39,8 @@ function world() {
|
|
|
39
39
|
runAgent: async ({ role }) => { w.agents.push(role); return { text: "FORGE:TEST_GATE:RESULT=PASS" }; },
|
|
40
40
|
finalize: async () => ({ code: 0, lines: [], data: { head: sha(w.head), notes: ["- nit"], toFile: w.fixed ? [] : [{ title: "leak", severity: "HIGH" }] } }),
|
|
41
41
|
fileIssue: async ({ item }) => { w.issues.push(item.title); return 100 + w.issues.length; },
|
|
42
|
-
|
|
42
|
+
failedJobs: async () => [],
|
|
43
|
+
fileFixIssue: async () => 999,
|
|
43
44
|
addNotes: async () => {},
|
|
44
45
|
summary: async ({ filed }) => {
|
|
45
46
|
const pass = w.fixed;
|
|
@@ -59,7 +60,7 @@ describe("forgedock release, review to gate (e2e on in-memory GitHub)", () => {
|
|
|
59
60
|
assert.equal(out.step, "promotion");
|
|
60
61
|
assert.match(out.reason, /GATE_PASS/);
|
|
61
62
|
assert.deepEqual(w.issues, ["leak"], "the finding was filed");
|
|
62
|
-
assert.deepEqual(w.lanes, [[
|
|
63
|
+
assert.deepEqual(w.lanes, [[999, "staging"]], "one fix lane, on the consolidated fix issue, on the staging branch");
|
|
63
64
|
assert.deepEqual(w.comments, ["<!-- FORGE:GATE_FAILURE -->", "<!-- FORGE:GATE_PASS -->"], "failure at the first head, pass after the delta review");
|
|
64
65
|
assert.ok(w.agents.includes("release-review-security") && w.agents.includes("release-review-regression-risk") && w.agents.includes("release-test-gate"), "the full panel ran");
|
|
65
66
|
assert.ok(w.printed.some((l) => l.includes(`--match-head-commit ${sha(2)}`)), "merge command at the fixed head");
|
|
@@ -15,11 +15,12 @@ import { delimiter, join } from "node:path";
|
|
|
15
15
|
import { fileURLToPath } from "node:url";
|
|
16
16
|
import { runHostPreflight } from "./release-preflight.mjs";
|
|
17
17
|
import { reviewStagingJson, reviewStagingIo, CI_EXCLUDED_CHECKS } from "../review-staging.mjs";
|
|
18
|
-
import { pickFixes, recut } from "./release-snapshot.mjs";
|
|
18
|
+
import { pickFixes, recut, revertLast } from "./release-snapshot.mjs";
|
|
19
|
+
import { parseFixConfig, collectFindings, blockingOf, compileBrief, roundsAt, recordRound, secondPush, secondPushOf, holdForOwner, jobsToRerun, inputHash, deferredOf } from "./release-fixloop.mjs";
|
|
20
|
+
import { coStartCi } from "./release-preflight.mjs";
|
|
19
21
|
|
|
20
|
-
/** Delta passes after a head move
|
|
22
|
+
/** Delta passes after a head move: past it the job blocks for the manual path. Fix rounds are `ci.fix.max_rounds` (release-fixloop.mjs, default 1, #5567). */
|
|
21
23
|
export const MAX_DELTA_PASSES = 2;
|
|
22
|
-
export const MAX_FIX_ROUNDS = 2;
|
|
23
24
|
const REVIEW_MS = 45 * 60_000, LANE_MS = 3 * 60 * 60_000;
|
|
24
25
|
const ROOT = fileURLToPath(new URL("../..", import.meta.url));
|
|
25
26
|
const SEVERE = new Set(["CRITICAL", "HIGH"]);
|
|
@@ -142,7 +143,9 @@ async function reviewRound({ seam, pr, def, delta }) {
|
|
|
142
143
|
return { fail: `reviewer findings block still missing after one re-ask (${missing.join(", ")}): degraded panel${failureNote(failures)}` };
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
|
-
|
|
146
|
+
// #5567: guard failures of this round (a failed test gate), collected into the fix record next to jobs and findings
|
|
147
|
+
const guards = /FORGE:TEST_GATE:RESULT=FAIL/.test(gate?.text ?? "") ? [{ name: "test-gate", why: "the release test gate reported FAIL" }] : [];
|
|
148
|
+
return { ok: { ...fin.data, guards: [...(fin.data.guards ?? []), ...guards] } };
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
/** The whole review of PR `pr`: rounds until one finalizes at its own head. @returns the step result or `{blocked}`. */
|
|
@@ -165,62 +168,126 @@ async function runReview({ seam, pr, def, delta = null }) {
|
|
|
165
168
|
if ((st.notes ?? []).length) await seam.addNotes(pr, st.notes);
|
|
166
169
|
const sum = await seam.summary({ pr, filed });
|
|
167
170
|
if (!sum.data) return blocked(`the gate summary was not posted (exit ${sum.code}): ${(sum.lines ?? []).slice(-1).join("").slice(0, 200)}`);
|
|
168
|
-
return { pr, head: st.head, verdict: sum.data.verdict, marker: sum.data.marker, ciFailing: sum.data.ciFailing, ciCancelOnly: Boolean(sum.data.ciCancelOnly), ciPendingOnly: Boolean(sum.data.ciPendingOnly), filed, blocking, delta: st.delta?.from ?? null };
|
|
171
|
+
return { pr, head: st.head, verdict: sum.data.verdict, marker: sum.data.marker, ciFailing: sum.data.ciFailing, ciCancelOnly: Boolean(sum.data.ciCancelOnly), ciPendingOnly: Boolean(sum.data.ciPendingOnly), filed, blocking, items: st.toFile ?? [], guards: st.guards ?? [], delta: st.delta?.from ?? null };
|
|
169
172
|
}
|
|
170
173
|
|
|
171
174
|
/** Review step. @returns {{pr, head, verdict, marker, filed, blocking}|{blocked: true, reason: string}} */
|
|
172
175
|
export async function reviewStep(ctx) {
|
|
173
176
|
const pr = ctx.state?.steps?.["release-pr"]?.result?.pr;
|
|
174
177
|
if (!pr) return blocked("no release PR recorded by the release-pr step");
|
|
178
|
+
const started = await coStartCi(ctx, { pr }); // #5567: CI and the panel start on the same head (off unless ci.fix is configured)
|
|
179
|
+
if (started?.refused) return { refused: started.refused };
|
|
175
180
|
return runReview({ seam: seamOf(ctx), pr, def: ctx.def });
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
/**
|
|
183
|
+
/** Re-read the gate summary into the review result (after a rerun or a re-summarise). */
|
|
184
|
+
async function resummarise(ctx, seam, r) {
|
|
185
|
+
const sum = await seam.summary({ pr: r.pr, filed: r.filed ?? [] });
|
|
186
|
+
if (!sum.data) return { err: `the gate summary was not posted (exit ${sum.code}) after rerunning the checks of #${r.pr}` };
|
|
187
|
+
const next = { ...r, verdict: sum.data.verdict, marker: sum.data.marker, ciFailing: sum.data.ciFailing, ciCancelOnly: Boolean(sum.data.ciCancelOnly), ciPendingOnly: Boolean(sum.data.ciPendingOnly) };
|
|
188
|
+
ctx.state.steps.review = { ...ctx.state.steps.review, result: next };
|
|
189
|
+
ctx.save();
|
|
190
|
+
return { r: next };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The round budget (`ci.fix.max_rounds`) is spent and the head is still not GATE_PASS. The only second push is a mechanical revert of
|
|
195
|
+
* the fix commit or an infra-flake rerun, once; anything else is HELD with an owner ask (#5567, no LLM adjudication).
|
|
196
|
+
* @returns {{r}|{blocked}}
|
|
197
|
+
*/
|
|
198
|
+
async function secondRound(ctx, seam, r, cfg) {
|
|
199
|
+
const rec = collectFindings({ head: r.head, jobs: await seam.failedJobs({ pr: r.pr, head: r.head }), findings: r.items ?? [], guards: r.guards ?? [] });
|
|
200
|
+
const rounds = roundsAt(ctx.state, r.head);
|
|
201
|
+
const failedBefore = ctx.state.fixloop?.heads?.[r.head]?.failedBefore ?? null;
|
|
202
|
+
const d = secondPush({ rec, failedBefore, lastPush: secondPushOf(ctx.state, r.head), maxRounds: cfg.maxRounds, rounds });
|
|
203
|
+
if (d.action === "hold") return holdForOwner(ctx, `${d.ask}`);
|
|
204
|
+
if (d.action === "rerun") {
|
|
205
|
+
const out = await ctx.rerunInfra?.({ head: r.head });
|
|
206
|
+
if (!out?.reran?.length) return holdForOwner(ctx, `Owner: only infra flakes remain on #${r.pr} but no rerun was possible (${(out?.skipped ?? []).map((x) => x.why).join("; ") || "no rerun seam"}).`);
|
|
207
|
+
recordRound(ctx.state, { from: r.head, to: r.head, kind: "rerun" });
|
|
208
|
+
ctx.save();
|
|
209
|
+
const s = await resummarise(ctx, seam, r);
|
|
210
|
+
return s.err ? blocked(s.err) : { r: s.r };
|
|
211
|
+
}
|
|
212
|
+
if (ctx.config?.mode !== "snapshot") return holdForOwner(ctx, `Owner: the fix regressed ${rec.ci.map((j) => j.name).join(", ")} on #${r.pr}; a mechanical revert needs release.mode: snapshot.`);
|
|
213
|
+
const rev = await revertLast(ctx);
|
|
214
|
+
if (rev.err) return holdForOwner(ctx, `Owner: the mechanical revert of the fix on #${r.pr} failed: ${rev.err}`);
|
|
215
|
+
const head = await seam.headOf(r.pr);
|
|
216
|
+
recordRound(ctx.state, { from: r.head, to: head, kind: "revert", failedBefore: rec.ci.map((j) => j.name) });
|
|
217
|
+
ctx.save();
|
|
218
|
+
const next = await runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head });
|
|
219
|
+
if (next.blocked) return next;
|
|
220
|
+
ctx.state.steps.review = { ...ctx.state.steps.review, result: next };
|
|
221
|
+
ctx.save();
|
|
222
|
+
return { r: next };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Fix step: nothing to do on GATE_PASS; else ONE round (`ci.fix.max_rounds`, counted per head sha): collect every failed job, finding
|
|
227
|
+
* and guard on the head, compile one invariant-grouped brief, file one fix issue, run one lane, push once, delta-review the fix commits.
|
|
228
|
+
* A still-failing head after the budget gets only a mechanical revert or an infra-flake rerun, once; else HELD with an owner ask.
|
|
229
|
+
*/
|
|
179
230
|
export async function fixStep(ctx) {
|
|
180
231
|
let r = ctx.state?.steps?.review?.result;
|
|
181
232
|
if (!r?.pr) return blocked("no review result recorded by the review step");
|
|
182
233
|
const seam = seamOf(ctx);
|
|
183
|
-
|
|
184
|
-
|
|
234
|
+
const cfg = parseFixConfig(ctx.config?.fix);
|
|
235
|
+
while (r.marker !== "FORGE:GATE_PASS") {
|
|
185
236
|
// Only cancelled duplicate runs are red (#5502): nothing to fix. The summary reruns them once; re-summarise without spending the round.
|
|
186
237
|
if (!r.blocking?.length && r.ciFailing > 0 && r.ciCancelOnly) {
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
189
|
-
r =
|
|
190
|
-
ctx.state.steps.review = { ...ctx.state.steps.review, result: r };
|
|
191
|
-
ctx.save();
|
|
238
|
+
const s = await resummarise(ctx, seam, r);
|
|
239
|
+
if (s.err) return blocked(s.err);
|
|
240
|
+
r = s.r;
|
|
192
241
|
if (r.marker === "FORGE:GATE_PASS") break;
|
|
193
242
|
if (r.ciCancelOnly) return blocked(`required checks of #${r.pr} still cancelled after a rerun, with no failure to fix`);
|
|
194
|
-
|
|
243
|
+
continue;
|
|
195
244
|
}
|
|
196
245
|
// Required checks that are only still pending (#5519) have not failed: no CI issue or lane, the release re-runs once CI finishes.
|
|
197
246
|
if (!r.blocking?.length && r.ciFailing > 0 && r.ciPendingOnly) return blocked(`required checks of #${r.pr} still pending, with no failure to fix; re-run the release once CI finishes`);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
247
|
+
if (roundsAt(ctx.state, r.head) >= cfg.maxRounds) {
|
|
248
|
+
const s = await secondRound(ctx, seam, r, cfg);
|
|
249
|
+
if (s.blocked) return s;
|
|
250
|
+
r = s.r;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const rec = collectFindings({ head: r.head, jobs: r.ciFailing > 0 ? await seam.failedJobs({ pr: r.pr, head: r.head }) : [], findings: r.items ?? [], guards: r.guards ?? [] });
|
|
254
|
+
const b = blockingOf(rec);
|
|
255
|
+
if (!b.ci.length && !b.review.length && !b.guards.length && !r.blocking?.length && !(r.ciFailing > 0)) return blocked(`${r.verdict} with neither a blocking finding nor red CI to fix`);
|
|
256
|
+
const hashesNow = Object.fromEntries(rec.ci.map((j) => [j.name, j.inputHash ?? inputHash(j.name, r.head)]));
|
|
257
|
+
const brief = compileBrief(rec, { commands: ctx.config?.preflight ? [ctx.config.preflight.command] : [], rerunChecks: jobsToRerun(hashesNow, ctx.state.fixloop?.hashes ?? {}) });
|
|
258
|
+
// Non-blocking and out-of-wave findings become next-plan issues, once per head; they are never part of the fix and never merged after READY (I16).
|
|
259
|
+
const fl = (ctx.state.fixloop ??= { heads: {} });
|
|
260
|
+
fl.hashes = hashesNow;
|
|
261
|
+
if (!fl.deferred?.includes(r.head)) {
|
|
262
|
+
const later = deferredOf(rec);
|
|
263
|
+
if (later.length) await seam.fileDeferred?.({ pr: r.pr, head: r.head, items: later });
|
|
264
|
+
fl.deferred = [...(fl.deferred ?? []), r.head];
|
|
265
|
+
ctx.save();
|
|
204
266
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
267
|
+
// One issue carries the whole brief (blocking findings stay filed as their own issues and are referenced); its lane is the one fix lane.
|
|
268
|
+
const issue = await seam.fileFixIssue({ pr: r.pr, head: r.head, brief, blocking: r.blocking ?? [] });
|
|
269
|
+
if (!issue) return blocked(`could not file the fix issue for #${r.pr}`);
|
|
270
|
+
// A resume after the fix already merged (by this job or by an intake lane): its lane would end invalid on a closed issue.
|
|
271
|
+
if (!(await seam.issueMerged?.(issue))) {
|
|
209
272
|
const lane = await seam.runLane({ issue, lane: ctx.staging });
|
|
210
273
|
if (lane?.terminalReason !== "merged") return blocked(`fix lane for #${issue} ended ${lane?.terminalReason ?? "without a result"}`);
|
|
211
274
|
}
|
|
212
275
|
// Snapshot mode (#5276): the fixes are merged on staging; bring exactly those onto release/<id> (or recut it) before the delta review.
|
|
213
276
|
if (ctx.config?.mode === "snapshot") {
|
|
214
|
-
const moved = ctx.config.fixMode === "recut" ? await recut(ctx) : await pickFixes(ctx, { issues });
|
|
277
|
+
const moved = ctx.config.fixMode === "recut" ? await recut(ctx) : await pickFixes(ctx, { issues: [issue, ...(r.blocking ?? [])] });
|
|
215
278
|
if (moved.err) return blocked(moved.err);
|
|
216
279
|
}
|
|
217
280
|
// The host preflight re-runs on the head the fixes produced, before the delta review (the draft PR has no Actions CI yet, #5277).
|
|
281
|
+
const head = await seam.headOf(r.pr);
|
|
218
282
|
if (ctx.config?.preflight) {
|
|
219
|
-
const pf = await runHostPreflight(ctx, { head
|
|
283
|
+
const pf = await runHostPreflight(ctx, { head, pr: r.pr });
|
|
220
284
|
if (!pf.ok && pf.blocking) return blocked(`host preflight failed at ${pf.head} after the fix round (release-blocker #${pf.issue})`);
|
|
221
285
|
}
|
|
286
|
+
recordRound(ctx.state, { from: r.head, to: head, failedBefore: rec.ci.map((j) => j.name) });
|
|
287
|
+
ctx.save();
|
|
222
288
|
const next = await runReview({ seam, pr: r.pr, def: ctx.def, delta: r.head });
|
|
223
289
|
if (next.blocked) return next;
|
|
290
|
+
if (next.head && next.head !== head) { recordRound(ctx.state, { from: r.head, to: next.head, failedBefore: rec.ci.map((j) => j.name) }); ctx.save(); } // the reviewed head is the one the budget is keyed on
|
|
224
291
|
r = next;
|
|
225
292
|
ctx.state.steps.review = { ...ctx.state.steps.review, result: r };
|
|
226
293
|
ctx.save();
|
|
@@ -270,16 +337,32 @@ export function realSeam({ repo, def, env = process.env, cwd = process.cwd(), ma
|
|
|
270
337
|
return v.state === "CLOSED" && (v.labels ?? []).some((l) => l.name === "workflow:merged");
|
|
271
338
|
} catch { return false; }
|
|
272
339
|
},
|
|
273
|
-
|
|
340
|
+
// fail-late (#5567): wait until every CI run on `head` finished, then read the log of each failed one
|
|
341
|
+
failedJobs: async ({ head }) => {
|
|
342
|
+
const list = () => JSON.parse(gh(["run", "list", "-R", repo, "--commit", head, "--json", "databaseId,name,status,conclusion", "--limit", "50"]));
|
|
343
|
+
let runs = list();
|
|
344
|
+
for (let i = 0; i < 60 && runs.some((x) => x.status !== "completed"); i++) { await new Promise((res) => setTimeout(res, 60_000)); runs = list(); }
|
|
345
|
+
return runs.filter((x) => x.status === "completed").map((x) => {
|
|
346
|
+
let log = "";
|
|
347
|
+
if (x.conclusion === "failure") { try { log = gh(["run", "view", String(x.databaseId), "-R", repo, "--log-failed"]).slice(-20_000); } catch { /* no log: unknown class */ } }
|
|
348
|
+
return { name: x.name, conclusion: x.conclusion, log };
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
// #5567: findings that do not block (or lie outside the wave) are filed for the next plan, labelled so the release never picks them up
|
|
352
|
+
async fileDeferred({ pr, items }) {
|
|
353
|
+
const out = [];
|
|
354
|
+
for (const f of items) { const n = await this.fileIssue({ item: { title: `Next plan: ${f.title}`, severity: f.severity ?? "LOW", body: `Not blocking release PR #${pr} (non-blocking or outside the wave); deferred to the next plan.` }, pr }); if (n) out.push(n); }
|
|
355
|
+
return out;
|
|
356
|
+
},
|
|
357
|
+
async fileFixIssue({ pr, head, brief, blocking = [] }) {
|
|
274
358
|
// one issue per release head: a resume reuses the issue filed for the same head instead of filing a duplicate
|
|
275
|
-
const title = `Release PR #${pr}:
|
|
359
|
+
const title = `Release PR #${pr}: one-round fix at ${head.slice(0, 7)}`;
|
|
276
360
|
try {
|
|
277
361
|
const hit = JSON.parse(gh(["issue", "list", "-R", repo, "--state", "all", "--search", `"${title}" in:title`, "--json", "number,title"])).find((i) => i.title === title);
|
|
278
362
|
if (hit) return hit.number;
|
|
279
363
|
} catch { /* no lookup: file a new one */ }
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
return this.fileIssue({ item: { title: `Release PR #${pr}: CI red at ${head.slice(0, 7)}`, severity: "HIGH", body: `Failing required checks on the release PR #${pr} at ${head}:\n${names.map((n) => `- ${n}`).join("\n")}\n\nFix them on the staging branch.` }, pr });
|
|
364
|
+
const refs = blocking.length ? `\n\nBlocking findings filed separately: ${blocking.map((n) => `#${n}`).join(", ")}.` : "";
|
|
365
|
+
return this.fileIssue({ item: { title, severity: "HIGH", body: `${brief}${refs}\n\nFix them on the staging branch.` }, pr });
|
|
283
366
|
},
|
|
284
367
|
fileIssue: async ({ item, pr }) => {
|
|
285
368
|
const dir = mkdtempSync(join(tmpdir(), "release-finding-"));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { reviewStep, fixStep, missingReviewers, SPEC_PANEL, MAX_DELTA_PASSES,
|
|
5
|
+
import { reviewStep, fixStep, missingReviewers, SPEC_PANEL, MAX_DELTA_PASSES, realSeam, withIntegrityMarker, TEST_GATE_SKIP_NO_TESTS, testGatePrompt, integrationTestCount, resolveSkillName } from "./release-review.mjs";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { reviewStagingJson } from "../review-staging.mjs";
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ const manifest = (head, delta = null) => ({ pr: 7, headSha: head, bundle: [1, 2]
|
|
|
11
11
|
const fin = (extra = {}) => ({ code: 0, data: { head: H1, toFile: [], notes: [], ...extra }, lines: [] });
|
|
12
12
|
|
|
13
13
|
/** Seam fake: `heads` is what headOf answers in turn; `fins` what finalize answers in turn. */
|
|
14
|
-
function fakeSeam({ heads = [H1], fins = [fin()], summary, lanes = [], gatePlan = { clusters: 1, skill: "forgedock:test-gate" } } = {}) {
|
|
14
|
+
function fakeSeam({ heads = [H1], fins = [fin()], summary, lanes = [], jobs = [], gatePlan = { clusters: 1, skill: "forgedock:test-gate" } } = {}) {
|
|
15
15
|
const log = [], agents = [], gateSaved = [], agentCalls = [];
|
|
16
16
|
let h = 0, f = 0, l = 0, n = 100;
|
|
17
17
|
return {
|
|
@@ -26,7 +26,9 @@ function fakeSeam({ heads = [H1], fins = [fin()], summary, lanes = [], gatePlan
|
|
|
26
26
|
testGatePlan: async () => gatePlan,
|
|
27
27
|
runAgent: async (a) => { agentCalls.push(a); agents.push(a.role + (a.prompt.includes("findings block required") ? ":reask" : "")); return { text: "ok" }; },
|
|
28
28
|
fileIssue: async ({ item }) => { log.push(["file", item.title]); return n++; },
|
|
29
|
-
|
|
29
|
+
failedJobs: async () => jobs,
|
|
30
|
+
fileDeferred: async ({ items }) => { log.push(["deferred", items.map((i) => i.title)]); return []; },
|
|
31
|
+
fileFixIssue: async () => { log.push(["fix-issue"]); return n++; },
|
|
30
32
|
issueMerged: async () => false,
|
|
31
33
|
addNotes: async (pr, notes) => log.push(["notes", notes]),
|
|
32
34
|
runLane: async (a) => { log.push(["lane", a.issue, a.lane]); return lanes[l++] ?? { terminalReason: "merged" }; },
|
|
@@ -141,21 +143,23 @@ describe("fixStep", () => {
|
|
|
141
143
|
assert.equal(s.log.length, 0);
|
|
142
144
|
});
|
|
143
145
|
|
|
144
|
-
it("runs
|
|
146
|
+
it("runs ONE lane on the consolidated fix issue on the staging branch, then a delta review from the reviewed head", async () => {
|
|
145
147
|
const s = fakeSeam({ heads: [H2] });
|
|
146
148
|
const c = ctx(s, { review: { result: failed } });
|
|
147
149
|
const r = await fixStep(c);
|
|
148
|
-
assert.deepEqual(s.log[
|
|
149
|
-
assert.deepEqual(s.log[1], ["pre", H1]);
|
|
150
|
+
assert.deepEqual(s.log.slice(0, 3), [["fix-issue"], ["lane", 100, "staging"], ["pre", H1]]);
|
|
150
151
|
assert.equal(r.verdict, "APPROVE FOR DEPLOY");
|
|
152
|
+
assert.equal(c.state.fixloop.heads[H2].rounds, 1, "the round is counted per head sha");
|
|
151
153
|
});
|
|
152
154
|
|
|
153
|
-
it("is bounded:
|
|
155
|
+
it("is bounded: one round (ci.fix.max_rounds default 1), then HELD with an owner ask for a non-flake, non-regression failure", async () => {
|
|
154
156
|
const bad = { code: 0, data: { verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", ciFailing: 0 }, lines: [] };
|
|
155
157
|
const s = fakeSeam({ heads: [H2], summary: bad, fins: [fin({ toFile: [{ title: "x", severity: "CRITICAL" }] })] });
|
|
156
158
|
const r = await fixStep(ctx(s, { review: { result: failed } }));
|
|
157
159
|
assert.equal(r.blocked, true);
|
|
158
|
-
assert.equal(
|
|
160
|
+
assert.equal(r.held, true);
|
|
161
|
+
assert.match(r.reason, /^Owner: .*ci\.fix\.max_rounds=1/);
|
|
162
|
+
assert.equal(s.log.filter((e) => e[0] === "lane").length, 1);
|
|
159
163
|
});
|
|
160
164
|
|
|
161
165
|
it("blocks when a lane does not merge", async () => {
|
|
@@ -166,31 +170,31 @@ describe("fixStep", () => {
|
|
|
166
170
|
it("red CI with no finding files one CI issue and runs a lane on it, then reviews the delta", async () => {
|
|
167
171
|
const s = fakeSeam({ heads: [H2] });
|
|
168
172
|
const r = await fixStep(ctx(s, { review: { result: { ...failed, blocking: [], ciFailing: 2 } } }));
|
|
169
|
-
assert.deepEqual(s.log.slice(0, 3), [["
|
|
173
|
+
assert.deepEqual(s.log.slice(0, 3), [["fix-issue"], ["lane", 100, "staging"], ["pre", H1]]);
|
|
170
174
|
assert.equal(r.blocked, undefined);
|
|
171
175
|
});
|
|
172
176
|
|
|
173
177
|
it("a resume skips fix issues already closed as merged and goes on to the delta review", async () => {
|
|
174
178
|
const s = fakeSeam({ heads: [H2] });
|
|
175
|
-
s.issueMerged = async (n) => n ===
|
|
179
|
+
s.issueMerged = async (n) => n === 100;
|
|
176
180
|
const r = await fixStep(ctx(s, { review: { result: failed } }));
|
|
177
181
|
assert.equal(s.log.filter((e) => e[0] === "lane").length, 0);
|
|
178
|
-
assert.deepEqual(s.log[
|
|
182
|
+
assert.deepEqual(s.log.slice(0, 2), [["fix-issue"], ["pre", H1]]);
|
|
179
183
|
assert.equal(r.blocked, undefined);
|
|
180
184
|
});
|
|
181
185
|
|
|
182
|
-
it("realSeam.
|
|
186
|
+
it("realSeam.fileFixIssue reuses the issue already filed for the same release head", async () => {
|
|
183
187
|
const calls = [];
|
|
184
|
-
const gh = (args) => { calls.push(args); if (args[0] === "issue" && args[1] === "list") return JSON.stringify([{ number: 5396, title: "Release PR #7:
|
|
188
|
+
const gh = (args) => { calls.push(args); if (args[0] === "issue" && args[1] === "list") return JSON.stringify([{ number: 5396, title: "Release PR #7: one-round fix at b48bae6" }]); throw new Error("unexpected"); };
|
|
185
189
|
const seam = realSeam({ repo: "o/r", def: "main", env: {}, cwd: "/tmp", gh });
|
|
186
|
-
assert.equal(await seam.
|
|
190
|
+
assert.equal(await seam.fileFixIssue({ pr: 7, head: "b48bae6628432906aa96f509eddfe6d49608e725", brief: "b" }), 5396);
|
|
187
191
|
assert.equal(calls.length, 1);
|
|
188
192
|
});
|
|
189
193
|
|
|
190
|
-
it("a blocking finding and red CI together get
|
|
194
|
+
it("a blocking finding and red CI together get ONE lane on one consolidated issue", async () => {
|
|
191
195
|
const s = fakeSeam({ heads: [H2] });
|
|
192
196
|
await fixStep(ctx(s, { review: { result: { ...failed, ciFailing: 1 } } }));
|
|
193
|
-
assert.deepEqual(s.log.filter((e) => e[0] === "lane").map((e) => e[1]), [
|
|
197
|
+
assert.deepEqual(s.log.filter((e) => e[0] === "lane").map((e) => e[1]), [100]);
|
|
194
198
|
});
|
|
195
199
|
|
|
196
200
|
it("only cancelled CI: no CI issue, no lane, no round spent; re-summarises and goes on", async () => {
|
|
@@ -204,7 +208,7 @@ describe("fixStep", () => {
|
|
|
204
208
|
const s2 = fakeSeam({ summary: still });
|
|
205
209
|
const r2 = await fixStep(ctx(s2, { review: { result: { ...failed, blocking: [], filed: [], ciFailing: 1, ciCancelOnly: true } } }));
|
|
206
210
|
assert.match(r2.reason, /still cancelled/);
|
|
207
|
-
assert.ok(!s2.log.some((e) => e[0] === "
|
|
211
|
+
assert.ok(!s2.log.some((e) => e[0] === "fix-issue" || e[0] === "lane"));
|
|
208
212
|
});
|
|
209
213
|
|
|
210
214
|
it("only pending CI (#5519): blocks without a CI issue or lane; a real failure alongside still files", async () => {
|
|
@@ -214,7 +218,7 @@ describe("fixStep", () => {
|
|
|
214
218
|
assert.deepEqual(s.log, []);
|
|
215
219
|
const s2 = fakeSeam();
|
|
216
220
|
await fixStep(ctx(s2, { review: { result: { ...failed, blocking: [], filed: [], ciFailing: 2, ciPendingOnly: false } } }));
|
|
217
|
-
assert.ok(s2.log.some((e) => e[0] === "
|
|
221
|
+
assert.ok(s2.log.some((e) => e[0] === "fix-issue"));
|
|
218
222
|
});
|
|
219
223
|
|
|
220
224
|
it("blocks when the verdict is not a pass but there is nothing to fix", async () => {
|
|
@@ -240,6 +244,89 @@ describe("reviewStagingJson (library entry)", () => {
|
|
|
240
244
|
});
|
|
241
245
|
});
|
|
242
246
|
|
|
247
|
+
describe("fixStep one-round loop (#5567)", () => {
|
|
248
|
+
const failed = { pr: 7, head: H1, verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", blocking: [], filed: [], ciFailing: 1, items: [] };
|
|
249
|
+
const bad = { code: 0, data: { verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", ciFailing: 1 }, lines: [] };
|
|
250
|
+
it("the brief the lane gets is one compiled record of every failed job (fail-late)", async () => {
|
|
251
|
+
const s = fakeSeam({ heads: [H2], jobs: [{ name: "unit", conclusion: "failure", log: "AssertionError" }, { name: "lint", conclusion: "success" }] });
|
|
252
|
+
let brief = null;
|
|
253
|
+
s.fileFixIssue = async (a) => { brief = a.brief; return 100; };
|
|
254
|
+
await fixStep(ctx(s, { review: { result: failed } }));
|
|
255
|
+
assert.match(brief, /## Invariant: ci:unit/);
|
|
256
|
+
assert.match(brief, /## Sibling sweep/);
|
|
257
|
+
assert.ok(!brief.includes("lint"), "a passing job is not in the brief");
|
|
258
|
+
});
|
|
259
|
+
it("ci.fix.max_rounds raises the round budget", async () => {
|
|
260
|
+
const s = fakeSeam({ heads: [H2], summary: bad, jobs: [{ name: "unit", conclusion: "failure", log: "AssertionError" }] });
|
|
261
|
+
const c = ctx(s, { review: { result: failed } });
|
|
262
|
+
c.config = { fix: { maxRounds: 2 } };
|
|
263
|
+
await fixStep(c);
|
|
264
|
+
assert.equal(s.log.filter((e) => e[0] === "lane").length, 2);
|
|
265
|
+
});
|
|
266
|
+
it("a remaining infra flake gets one rerun, no code change, then GATE_PASS", async () => {
|
|
267
|
+
const s = fakeSeam({ heads: [H2], summary: bad, jobs: [{ name: "unit", conclusion: "failure", log: "ECONNRESET" }] });
|
|
268
|
+
const c = ctx(s, { review: { result: failed } });
|
|
269
|
+
let reran = 0;
|
|
270
|
+
c.rerunInfra = async () => { reran++; s.summary = async () => ({ code: 0, data: { verdict: "APPROVE FOR DEPLOY", marker: "FORGE:GATE_PASS", ciFailing: 0 }, lines: [] }); return { reran: ["unit"], skipped: [] }; };
|
|
271
|
+
const r = await fixStep(c);
|
|
272
|
+
assert.equal(r.verdict, "APPROVE FOR DEPLOY");
|
|
273
|
+
assert.equal(reran, 1);
|
|
274
|
+
assert.equal(s.log.filter((e) => e[0] === "lane").length, 1, "the rerun is not a fix lane");
|
|
275
|
+
});
|
|
276
|
+
it("an infra flake that still fails after its one rerun is HELD, never rerun again", async () => {
|
|
277
|
+
const s = fakeSeam({ heads: [H2], summary: bad, jobs: [{ name: "unit", conclusion: "failure", log: "ECONNRESET" }] });
|
|
278
|
+
const c = ctx(s, { review: { result: failed } });
|
|
279
|
+
let reran = 0, held = null;
|
|
280
|
+
c.rerunInfra = async () => { reran++; return { reran: ["unit"], skipped: [] }; };
|
|
281
|
+
c.hold = async (ask) => { held = ask; };
|
|
282
|
+
const r = await fixStep(c);
|
|
283
|
+
assert.equal(reran, 1);
|
|
284
|
+
assert.equal(r.held, true);
|
|
285
|
+
assert.match(held, /already used/);
|
|
286
|
+
});
|
|
287
|
+
it("a fix that regressed a check is reverted mechanically once (snapshot mode), then HELD if still red", async () => {
|
|
288
|
+
const SNAP = "1".repeat(40), PK = "4".repeat(40), RV = "5".repeat(40);
|
|
289
|
+
const git = [];
|
|
290
|
+
const s = fakeSeam({ heads: [H2, H2], summary: bad });
|
|
291
|
+
let call = 0;
|
|
292
|
+
s.failedJobs = async () => (call++ === 0 ? [{ name: "unit", conclusion: "failure", log: "x" }] : [{ name: "unit", conclusion: "failure", log: "x" }, { name: "e2e", conclusion: "failure", log: "y" }]);
|
|
293
|
+
const c = ctx(s, { review: { result: failed } });
|
|
294
|
+
c.config = { mode: "snapshot" };
|
|
295
|
+
c.git = (a) => { git.push(a); if (a[0] === "commit-tree") return `${RV}\n`; return `${"6".repeat(40)}\n`; };
|
|
296
|
+
c.io = { ...c.io, git: c.git, gh: async (a) => (a[1] === "list" ? "[]" : JSON.stringify({ body: "" })) };
|
|
297
|
+
c.state.release = { branch: "release/x", snapshot: SNAP, range: {}, picks: [{ sha: PK, orig: "3".repeat(40), kind: "fix" }] };
|
|
298
|
+
c.hold = async () => {};
|
|
299
|
+
const r = await fixStep(c);
|
|
300
|
+
assert.ok(git.some((a) => a[0] === "push" && a.includes(`${RV}:refs/heads/release/x`)), "the revert is pushed");
|
|
301
|
+
assert.deepEqual(c.state.release.picks.at(-1), { sha: RV, orig: PK, kind: "revert" });
|
|
302
|
+
assert.equal(r.held, true);
|
|
303
|
+
assert.equal(s.log.filter((e) => e[0] === "lane").length, 1, "the revert is not a lane");
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe("fixStep deferred findings and guards (#5567)", () => {
|
|
308
|
+
const failed = { pr: 7, head: H1, verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", blocking: [], filed: [], ciFailing: 1, items: [{ title: "nit", severity: "LOW" }, { title: "far", severity: "HIGH", wave: false }, { title: "real", severity: "HIGH" }], guards: [{ name: "test-gate", why: "FAIL" }] };
|
|
309
|
+
it("non-blocking and out-of-wave findings are filed for the next plan, not into the fix brief; guard failures are in the brief", async () => {
|
|
310
|
+
const s = fakeSeam({ heads: [H2], jobs: [{ name: "unit", conclusion: "failure", log: "x" }] });
|
|
311
|
+
let brief = "";
|
|
312
|
+
s.fileFixIssue = async (a) => { brief = a.brief; return 100; };
|
|
313
|
+
await fixStep(ctx(s, { review: { result: failed } }));
|
|
314
|
+
assert.deepEqual(s.log.find((e) => e[0] === "deferred")[1].sort(), ["far", "nit"]);
|
|
315
|
+
assert.match(brief, /guard:test-gate/);
|
|
316
|
+
assert.match(brief, /real/);
|
|
317
|
+
assert.ok(!/far|nit\b/.test(brief.split("## Sibling")[0].replace(/ci:unit/g, "")), "deferred findings stay out of the brief");
|
|
318
|
+
});
|
|
319
|
+
it("the checks that will rerun are those whose input hash differs from the last run", async () => {
|
|
320
|
+
const s = fakeSeam({ heads: [H2], jobs: [{ name: "unit", conclusion: "failure", log: "x", inputHash: "h1" }, { name: "e2e", conclusion: "failure", log: "y", inputHash: "h2" }] });
|
|
321
|
+
let brief = "";
|
|
322
|
+
s.fileFixIssue = async (a) => { brief = a.brief; return 100; };
|
|
323
|
+
const c = ctx(s, { review: { result: failed } });
|
|
324
|
+
c.state.fixloop = { heads: {}, hashes: { unit: "h1", e2e: "old" } };
|
|
325
|
+
await fixStep(c);
|
|
326
|
+
assert.match(brief, /## Checks that will rerun\n- e2e\n\n?$/);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
243
330
|
describe("fixStep in snapshot mode (#5276)", () => {
|
|
244
331
|
const failed = { pr: 7, head: H1, verdict: "BLOCK DEPLOY", marker: "FORGE:GATE_FAILURE", blocking: [101], filed: [101], ciFailing: 0 };
|
|
245
332
|
const SNAP = "1".repeat(40), TIP = "2".repeat(40), ORIG = "3".repeat(40), PICK = "4".repeat(40);
|
|
@@ -281,10 +368,10 @@ describe("fixStep in snapshot mode (#5276)", () => {
|
|
|
281
368
|
const c = snapCtx(s, w);
|
|
282
369
|
const r = await fixStep(c);
|
|
283
370
|
assert.equal(r.blocked, undefined);
|
|
284
|
-
assert.deepEqual(c.state.release.picks, [{ sha: PICK, orig: ORIG, pr: 55 }]);
|
|
371
|
+
assert.deepEqual(c.state.release.picks, [{ sha: PICK, orig: ORIG, pr: 55, kind: "fix" }]);
|
|
285
372
|
assert.ok(w.git.some((a) => a[0] === "push" && a.includes(`${PICK}:refs/heads/release/x`)));
|
|
286
373
|
assert.ok(w.gh.some((a) => a[1] === "edit" && a[a.indexOf("--body") + 1].includes("FORGE:RELEASE")), "the record is written to the PR");
|
|
287
|
-
assert.deepEqual(s.log.slice(0,
|
|
374
|
+
assert.deepEqual(s.log.slice(0, 3), [["fix-issue"], ["lane", 100, "staging"], ["pre", H1]]);
|
|
288
375
|
});
|
|
289
376
|
|
|
290
377
|
it("a conflicting cherry-pick blocks the job instead of reviewing a head that lacks the fix", async () => {
|