@tablation/crew 0.165.2 → 0.167.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/dist/cli.js +279 -92
- package/dist/sandbox-intel-bridge.cjs +25 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3592,6 +3592,19 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
3592
3592
|
"verify",
|
|
3593
3593
|
"isolateFailures",
|
|
3594
3594
|
"rightOfWayMinutes",
|
|
3595
|
+
"parallelGates",
|
|
3596
|
+
"versioning",
|
|
3597
|
+
"versionFiles",
|
|
3598
|
+
"changelog",
|
|
3599
|
+
"tag",
|
|
3600
|
+
"tagPattern",
|
|
3601
|
+
"mode",
|
|
3602
|
+
"ship",
|
|
3603
|
+
"ci",
|
|
3604
|
+
"verify",
|
|
3605
|
+
"isolateFailures",
|
|
3606
|
+
"rightOfWayMinutes",
|
|
3607
|
+
"rebuildPrimary",
|
|
3595
3608
|
"versioning",
|
|
3596
3609
|
"versionFiles",
|
|
3597
3610
|
"changelog",
|
|
@@ -3604,6 +3617,11 @@ var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalS
|
|
|
3604
3617
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
3605
3618
|
var DEFAULT_ISOLATE_MAX_CANDIDATES = 4;
|
|
3606
3619
|
var DEFAULT_RIGHT_OF_WAY_MINUTES = 60;
|
|
3620
|
+
function parseRebuildPrimary(raw, fail2) {
|
|
3621
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
3622
|
+
if (typeof raw !== "boolean") throw fail2(`release.rebuildPrimary must be true or false (got "${raw}")`);
|
|
3623
|
+
return raw;
|
|
3624
|
+
}
|
|
3607
3625
|
function parseRightOfWayMinutes(raw, fail2) {
|
|
3608
3626
|
if (raw === void 0 || raw === null) return void 0;
|
|
3609
3627
|
const n = Number(raw);
|
|
@@ -3835,6 +3853,11 @@ function parseRepoConfig(text2, file) {
|
|
|
3835
3853
|
(m) => new RepoConfigError(`${file}: ${m}`)
|
|
3836
3854
|
);
|
|
3837
3855
|
const rightOfWay = parseRightOfWayMinutes(raw.release?.rightOfWayMinutes, (m) => new RepoConfigError(`${file}: ${m}`));
|
|
3856
|
+
const parallelGatesRaw = raw.release?.parallelGates;
|
|
3857
|
+
if (parallelGatesRaw !== void 0 && typeof parallelGatesRaw !== "boolean") {
|
|
3858
|
+
throw new RepoConfigError(`${file}: release.parallelGates must be true or false (got "${String(parallelGatesRaw)}")`);
|
|
3859
|
+
}
|
|
3860
|
+
const rebuildPrimary = parseRebuildPrimary(raw.release?.rebuildPrimary, (m) => new RepoConfigError(`${file}: ${m}`));
|
|
3838
3861
|
const versioning = String(raw.release?.versioning ?? "auto");
|
|
3839
3862
|
if (!VERSIONINGS.includes(versioning)) {
|
|
3840
3863
|
throw new RepoConfigError(`${file}: release.versioning must be auto|none (got "${versioning}")`);
|
|
@@ -3913,6 +3936,8 @@ function parseRepoConfig(text2, file) {
|
|
|
3913
3936
|
verify,
|
|
3914
3937
|
isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
|
|
3915
3938
|
rightOfWayMinutes: rightOfWay,
|
|
3939
|
+
...parallelGatesRaw ? { parallelGates: true } : {},
|
|
3940
|
+
rebuildPrimary,
|
|
3916
3941
|
versioning,
|
|
3917
3942
|
versionFiles,
|
|
3918
3943
|
tag,
|
|
@@ -4124,6 +4149,8 @@ function resolveRepoConfig(repo, ship, dir) {
|
|
|
4124
4149
|
)
|
|
4125
4150
|
},
|
|
4126
4151
|
rightOfWayMinutes: repo?.release.rightOfWayMinutes ?? ship?.release?.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES,
|
|
4152
|
+
...repo?.release.parallelGates ? { parallelGates: true } : {},
|
|
4153
|
+
rebuildPrimary: repo?.release.rebuildPrimary ?? false,
|
|
4127
4154
|
versioning: pick(
|
|
4128
4155
|
"release.versioning",
|
|
4129
4156
|
repo?.release.versioning === "auto" ? void 0 : repo?.release.versioning,
|
|
@@ -9568,8 +9595,9 @@ import { StaleWriteError } from "@tablation/client";
|
|
|
9568
9595
|
function releaseLockScope(route2, repo) {
|
|
9569
9596
|
return `${route2}/${repo}`;
|
|
9570
9597
|
}
|
|
9571
|
-
async function acquireBoardLock(client2, modelId, scope, holderLabel, ttlMs, log = {}) {
|
|
9598
|
+
async function acquireBoardLock(client2, modelId, scope, holderLabel, ttlMs, log = {}, renewEveryMs = DEFAULT_RENEW_EVERY_MS) {
|
|
9572
9599
|
if (!modelId) return { ok: true, release: async () => {
|
|
9600
|
+
}, stillHeld: async () => true, renew: async () => {
|
|
9573
9601
|
}, exclusion: "off" };
|
|
9574
9602
|
const filters = JSON.stringify([{ columnName: "scope", operator: "EQ", value: scope }]);
|
|
9575
9603
|
const rows = await client2.list(modelId, { filters, limit: 1 });
|
|
@@ -9587,13 +9615,58 @@ async function acquireBoardLock(client2, modelId, scope, holderLabel, ttlMs, log
|
|
|
9587
9615
|
if (e instanceof StaleWriteError) return { ok: false, reason: "contended" };
|
|
9588
9616
|
throw e;
|
|
9589
9617
|
}
|
|
9618
|
+
let current = claimed.updated_at;
|
|
9619
|
+
let lost = false;
|
|
9620
|
+
let stopped = false;
|
|
9621
|
+
let renewing = false;
|
|
9622
|
+
const renew = async () => {
|
|
9623
|
+
if (stopped || lost || renewing) return;
|
|
9624
|
+
renewing = true;
|
|
9625
|
+
try {
|
|
9626
|
+
try {
|
|
9627
|
+
current = (await client2.update(modelId, row.id, { holder: holderLabel }, current)).updated_at;
|
|
9628
|
+
} catch (e) {
|
|
9629
|
+
if (!(e instanceof StaleWriteError)) throw e;
|
|
9630
|
+
const [now] = await client2.list(modelId, { filters: scopeFilter(scope), limit: 1 });
|
|
9631
|
+
if (now?.holder !== holderLabel) {
|
|
9632
|
+
lost = true;
|
|
9633
|
+
log.warn?.(`board lock ${scope} was taken by ${now?.holder || "another ship"} while this release was running`);
|
|
9634
|
+
return;
|
|
9635
|
+
}
|
|
9636
|
+
current = (await client2.update(modelId, row.id, { holder: holderLabel }, now.updated_at)).updated_at;
|
|
9637
|
+
}
|
|
9638
|
+
} catch (e) {
|
|
9639
|
+
log.warn?.(`lock renewal failed for ${scope}: ${e.message}; will retry`);
|
|
9640
|
+
} finally {
|
|
9641
|
+
renewing = false;
|
|
9642
|
+
}
|
|
9643
|
+
};
|
|
9644
|
+
const timer = setInterval(() => {
|
|
9645
|
+
void renew();
|
|
9646
|
+
}, renewEveryMs);
|
|
9647
|
+
timer.unref();
|
|
9590
9648
|
return {
|
|
9591
9649
|
ok: true,
|
|
9592
9650
|
exclusion: "taken",
|
|
9651
|
+
renew,
|
|
9652
|
+
stillHeld: async () => {
|
|
9653
|
+
if (lost) return false;
|
|
9654
|
+
try {
|
|
9655
|
+
const [now] = await client2.list(modelId, { filters: scopeFilter(scope), limit: 1 });
|
|
9656
|
+
if (now?.holder === holderLabel) return true;
|
|
9657
|
+
lost = true;
|
|
9658
|
+
return false;
|
|
9659
|
+
} catch (e) {
|
|
9660
|
+
log.warn?.(`could not confirm board lock ${scope} is still held: ${e.message}`);
|
|
9661
|
+
return true;
|
|
9662
|
+
}
|
|
9663
|
+
},
|
|
9593
9664
|
release: async () => {
|
|
9665
|
+
stopped = true;
|
|
9666
|
+
clearInterval(timer);
|
|
9594
9667
|
try {
|
|
9595
9668
|
try {
|
|
9596
|
-
await client2.update(modelId, row.id, { holder: "" },
|
|
9669
|
+
await client2.update(modelId, row.id, { holder: "" }, current);
|
|
9597
9670
|
} catch (e) {
|
|
9598
9671
|
if (!(e instanceof StaleWriteError)) throw e;
|
|
9599
9672
|
const [now] = await client2.list(modelId, { filters: scopeFilter(scope), limit: 1 });
|
|
@@ -9606,6 +9679,7 @@ async function acquireBoardLock(client2, modelId, scope, holderLabel, ttlMs, log
|
|
|
9606
9679
|
}
|
|
9607
9680
|
};
|
|
9608
9681
|
}
|
|
9682
|
+
var DEFAULT_RENEW_EVERY_MS = 3 * 60 * 1e3;
|
|
9609
9683
|
function isDeadOwnClaim(holder, mine) {
|
|
9610
9684
|
const split = (l) => {
|
|
9611
9685
|
const i = l.lastIndexOf(":");
|
|
@@ -10331,8 +10405,8 @@ var Tracker = class _Tracker {
|
|
|
10331
10405
|
* Locks table with no row for `scope` is `{ ok: false, reason: 'missing' }`
|
|
10332
10406
|
* (CREW-1384): `crew connect` provisions the row.
|
|
10333
10407
|
*/
|
|
10334
|
-
acquireBoardLock(scope, holderLabel, ttlMs, log) {
|
|
10335
|
-
return acquireBoardLock(this.client.records, this.route.resolved?.locksModelId, scope, holderLabel, ttlMs, log);
|
|
10408
|
+
acquireBoardLock(scope, holderLabel, ttlMs, log, renewEveryMs) {
|
|
10409
|
+
return acquireBoardLock(this.client.records, this.route.resolved?.locksModelId, scope, holderLabel, ttlMs, log, renewEveryMs);
|
|
10336
10410
|
}
|
|
10337
10411
|
/** The Locks row for `scope` — present? held by whom? Undefined when this workspace has no Locks table. */
|
|
10338
10412
|
async lockState(scope) {
|
|
@@ -22478,7 +22552,12 @@ function looksLikeTransientResolveFailure(output) {
|
|
|
22478
22552
|
const realBuildError = /(TS\d{4}:|SyntaxError|error TS|Cannot find module '\.)/;
|
|
22479
22553
|
return resolveFailure.test(output) && !realBuildError.test(output);
|
|
22480
22554
|
}
|
|
22555
|
+
var HOOK_NO_RETRY_EXIT_CODE = 86;
|
|
22481
22556
|
async function rerunOnce(o, name, first) {
|
|
22557
|
+
if (first.code === HOOK_NO_RETRY_EXIT_CODE) {
|
|
22558
|
+
o.emit.warn(`${name} gate reported a failure that a rerun cannot fix (exit ${HOOK_NO_RETRY_EXIT_CODE}) \u2014 not rerunning`);
|
|
22559
|
+
return first;
|
|
22560
|
+
}
|
|
22482
22561
|
o.emit.warn(`${name} gate failed \u2014 rerunning once on the same composition before blaming a branch`);
|
|
22483
22562
|
const again = await hook(o, name);
|
|
22484
22563
|
if (!again || again.code !== 0) return again ?? first;
|
|
@@ -23120,18 +23199,23 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
|
23120
23199
|
o.emit.error(scoped(`could not cut a release checkout from ${remote}/${base} \u2014 ${e.message}`));
|
|
23121
23200
|
return { merged: [], deployed: false, stopped: "release checkout failed", decision };
|
|
23122
23201
|
}
|
|
23202
|
+
let outcome;
|
|
23203
|
+
let rebuild;
|
|
23123
23204
|
try {
|
|
23124
|
-
|
|
23205
|
+
outcome = await mergeAndRelease({ ...o, cwd: checkout.dir }, decision, fresh, checkout.branch);
|
|
23125
23206
|
} finally {
|
|
23126
23207
|
checkout.close();
|
|
23127
23208
|
const refreshed = refreshBaseBranch(o.cwd, remote, base);
|
|
23128
|
-
if (refreshed.action === "fast-forwarded" && o.repo.hooks.build) {
|
|
23129
|
-
|
|
23130
|
-
|
|
23131
|
-
|
|
23132
|
-
|
|
23209
|
+
if (refreshed.action === "fast-forwarded" && o.repo.hooks.build && o.repo.release.rebuildPrimary) {
|
|
23210
|
+
rebuild = async () => {
|
|
23211
|
+
const r = await hook(o, "build");
|
|
23212
|
+
if (r && r.code !== 0) {
|
|
23213
|
+
o.emit.warn(scoped(`rebuilding the primary checkout after the release failed (exit ${r.code}) \u2014 its dist/ is stale until \`${o.repo.hooks.build}\` is run there`));
|
|
23214
|
+
}
|
|
23215
|
+
};
|
|
23133
23216
|
}
|
|
23134
23217
|
}
|
|
23218
|
+
return rebuild ? { ...outcome, primaryRebuild: rebuild } : outcome;
|
|
23135
23219
|
}
|
|
23136
23220
|
var MAX_ISOLATE_PAIRS = 10;
|
|
23137
23221
|
function pairOrder(n, max = MAX_ISOLATE_PAIRS) {
|
|
@@ -23446,81 +23530,113 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23446
23530
|
}
|
|
23447
23531
|
}
|
|
23448
23532
|
}
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23452
|
-
let r = await hook(o, "test");
|
|
23453
|
-
if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
|
|
23454
|
-
if (r && r.code !== 0 && !isolated) {
|
|
23455
|
-
const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
23456
|
-
if (out && "tried" in out) isolation = out.tried;
|
|
23457
|
-
else if (out) return out;
|
|
23458
|
-
}
|
|
23459
|
-
if (r && r.code !== 0) {
|
|
23460
|
-
o.emit.error(withFix("test gate FAILED \u2014 not deploying; the target stays on the previous release", "`crew doctor`, then fix the failing tests on the branch"));
|
|
23461
|
-
const sha = headSha(o.cwd);
|
|
23462
|
-
const count = o.state?.noteTestGateFailed?.(sha) ?? 1;
|
|
23463
|
-
const gateRed = count >= GATE_RED_AFTER && !o.state?.testGateReported?.(sha) ? { sha, count, hook: hookLabel(o.repo, "test"), tail: lastLines(r.output, 15) } : void 0;
|
|
23464
|
-
const composition = {
|
|
23465
|
-
head: sha,
|
|
23466
|
-
base: preMerge,
|
|
23467
|
-
branches: merged.filter((c) => c.branch).map((c) => ({
|
|
23468
|
-
key: c.ticket.issue_tag ?? c.ticket.issue_id,
|
|
23469
|
-
branch: c.branch,
|
|
23470
|
-
tip: resolve3(o.cwd, c.branch) ?? ""
|
|
23471
|
-
}))
|
|
23472
|
-
};
|
|
23473
|
-
const hookFailure2 = {
|
|
23474
|
-
hook: "test",
|
|
23475
|
-
label: hookLabel(o.repo, "test"),
|
|
23476
|
-
tail: failureSummary(r.output, HOOK_FAILURE_TAIL_LINES)
|
|
23477
|
-
};
|
|
23478
|
-
return { merged, conflicts, unbuildable, deployed: false, stopped: "tests failed", decision, gateRed, hookFailure: hookFailure2, composition, ...isolation ? { isolation } : {} };
|
|
23479
|
-
}
|
|
23480
|
-
o.state?.clearTestGateFailed?.();
|
|
23481
|
-
}
|
|
23482
|
-
}
|
|
23533
|
+
const testGateRuns = !(o.isDeployCommand && nothingToDeploy) && !o.skipTests && !!o.repo.hooks.test;
|
|
23534
|
+
const buildGateRuns = !!o.repo.hooks.build;
|
|
23535
|
+
const parallelGates = !!o.repo.release.parallelGates && testGateRuns && buildGateRuns && !o.dryRun;
|
|
23483
23536
|
const size = merged.some((m) => m.bump === "minor") ? "minor" : "patch";
|
|
23484
23537
|
const majorRequested = merged.some((m) => m.majorRequested);
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23489
|
-
|
|
23490
|
-
|
|
23491
|
-
o.
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23502
|
-
if (o.dryRun) {
|
|
23503
|
-
o.emit.emit(`would run: ${hookLabel(o.repo, "build")}`);
|
|
23504
|
-
if (applied >= 1) {
|
|
23505
|
-
o.emit.emit(
|
|
23506
|
-
`if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by building each alone, up to ${isolateCap(o)}), hand that back to the dev lane and ship the rest`
|
|
23507
|
-
);
|
|
23538
|
+
let preBump = "";
|
|
23539
|
+
let version;
|
|
23540
|
+
const cutVersion = async () => {
|
|
23541
|
+
if (majorRequested) {
|
|
23542
|
+
o.emit.warn("a branch asked for a MAJOR bump \u2014 honoured as minor; major is the operator's call");
|
|
23543
|
+
}
|
|
23544
|
+
preBump = headSha(o.cwd);
|
|
23545
|
+
version = await bump(o, size) ?? void 0;
|
|
23546
|
+
if (!version && o.dryRun && o.repo.hooks.bump) {
|
|
23547
|
+
o.emit.emit("would then commit the version bump and changelog");
|
|
23548
|
+
} else if (version) {
|
|
23549
|
+
writeChangelog(o, version, merged.flatMap((m) => m.entries));
|
|
23550
|
+
if (!o.dryRun) {
|
|
23551
|
+
git(o.cwd, ["add", "-A"]);
|
|
23552
|
+
git(o.cwd, ["commit", "-m", `Release ${o.repo.release.tag ? renderTag(o.repo.release.tag, version) : version}`]);
|
|
23553
|
+
} else {
|
|
23554
|
+
o.emit.emit(`would commit the version bump and changelog`);
|
|
23508
23555
|
}
|
|
23509
|
-
}
|
|
23510
|
-
|
|
23511
|
-
|
|
23512
|
-
|
|
23513
|
-
|
|
23514
|
-
|
|
23515
|
-
|
|
23556
|
+
}
|
|
23557
|
+
};
|
|
23558
|
+
const dropVersionCommit = () => {
|
|
23559
|
+
if (version && !o.dryRun && headSha(o.cwd) !== preBump) {
|
|
23560
|
+
git(o.cwd, ["reset", "--hard", preBump]);
|
|
23561
|
+
o.emit.warn(`dropped the unreleased version commit for ${version} (reset ${o.repo.branch.base} to ${preBump.slice(0, 8)}) so a retry starts clean`);
|
|
23562
|
+
}
|
|
23563
|
+
};
|
|
23564
|
+
const settleTest = async (first) => {
|
|
23565
|
+
let r = first;
|
|
23566
|
+
if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
|
|
23567
|
+
if (r && r.code !== 0 && !isolated) {
|
|
23568
|
+
const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
23569
|
+
if (out && "tried" in out) isolation = out.tried;
|
|
23570
|
+
else if (out) return out;
|
|
23571
|
+
}
|
|
23572
|
+
if (r && r.code !== 0) {
|
|
23573
|
+
o.emit.error(withFix("test gate FAILED \u2014 not deploying; the target stays on the previous release", "`crew doctor`, then fix the failing tests on the branch"));
|
|
23574
|
+
if (parallelGates) dropVersionCommit();
|
|
23575
|
+
const sha = headSha(o.cwd);
|
|
23576
|
+
const count = o.state?.noteTestGateFailed?.(sha) ?? 1;
|
|
23577
|
+
const gateRed = count >= GATE_RED_AFTER && !o.state?.testGateReported?.(sha) ? { sha, count, hook: hookLabel(o.repo, "test"), tail: lastLines(r.output, 15) } : void 0;
|
|
23578
|
+
const composition = {
|
|
23579
|
+
head: sha,
|
|
23580
|
+
base: preMerge,
|
|
23581
|
+
branches: merged.filter((c) => c.branch).map((c) => ({
|
|
23582
|
+
key: c.ticket.issue_tag ?? c.ticket.issue_id,
|
|
23583
|
+
branch: c.branch,
|
|
23584
|
+
tip: resolve3(o.cwd, c.branch) ?? ""
|
|
23585
|
+
}))
|
|
23586
|
+
};
|
|
23587
|
+
const hookFailure2 = {
|
|
23588
|
+
hook: "test",
|
|
23589
|
+
label: hookLabel(o.repo, "test"),
|
|
23590
|
+
tail: failureSummary(r.output, HOOK_FAILURE_TAIL_LINES)
|
|
23591
|
+
};
|
|
23592
|
+
return { merged, conflicts, unbuildable, deployed: false, stopped: "tests failed", decision, gateRed, hookFailure: hookFailure2, composition, ...isolation ? { isolation } : {} };
|
|
23593
|
+
}
|
|
23594
|
+
o.state?.clearTestGateFailed?.();
|
|
23595
|
+
return void 0;
|
|
23596
|
+
};
|
|
23597
|
+
const settleBuild = async (first) => {
|
|
23598
|
+
let r = first;
|
|
23599
|
+
if (r && r.code !== 0) r = await rerunOnce(o, "build", r);
|
|
23600
|
+
if (r && r.code !== 0 && !isolated) {
|
|
23601
|
+
const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
23602
|
+
if (out && "tried" in out) isolation = out.tried;
|
|
23603
|
+
else if (out) return out;
|
|
23604
|
+
}
|
|
23605
|
+
if (r && r.code !== 0) {
|
|
23606
|
+
o.emit.error(withFix("build failed \u2014 not deploying", "`crew doctor`, then run the repo's build hook in the release checkout"));
|
|
23607
|
+
dropVersionCommit();
|
|
23608
|
+
return { merged, conflicts, unbuildable, version, deployed: false, stopped: "build failed", decision, hookFailure: hookFailure(o, "build", r.output), ...isolation ? { isolation } : {} };
|
|
23609
|
+
}
|
|
23610
|
+
return void 0;
|
|
23611
|
+
};
|
|
23612
|
+
if (parallelGates) {
|
|
23613
|
+
o.emit.emit(`release.parallelGates: cutting the version, then running the ${hookLabel(o.repo, "test")} and ${hookLabel(o.repo, "build")} gates together`);
|
|
23614
|
+
await cutVersion();
|
|
23615
|
+
const [testRun, buildRun] = await Promise.all([hook(o, "test"), hook(o, "build")]);
|
|
23616
|
+
const testOut = await settleTest(testRun);
|
|
23617
|
+
if (testOut) return testOut;
|
|
23618
|
+
const buildOut = await settleBuild(buildRun);
|
|
23619
|
+
if (buildOut) return buildOut;
|
|
23620
|
+
} else {
|
|
23621
|
+
if (testGateRuns) {
|
|
23622
|
+
if (o.dryRun) o.emit.emit(`would run the test gate: ${hookLabel(o.repo, "test")}`);
|
|
23623
|
+
else {
|
|
23624
|
+
const testOut = await settleTest(await hook(o, "test"));
|
|
23625
|
+
if (testOut) return testOut;
|
|
23516
23626
|
}
|
|
23517
|
-
|
|
23518
|
-
|
|
23519
|
-
|
|
23520
|
-
|
|
23521
|
-
|
|
23627
|
+
}
|
|
23628
|
+
await cutVersion();
|
|
23629
|
+
if (buildGateRuns) {
|
|
23630
|
+
if (o.dryRun) {
|
|
23631
|
+
o.emit.emit(`would run: ${hookLabel(o.repo, "build")}`);
|
|
23632
|
+
if (applied >= 1) {
|
|
23633
|
+
o.emit.emit(
|
|
23634
|
+
`if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by building each alone, up to ${isolateCap(o)}), hand that back to the dev lane and ship the rest`
|
|
23635
|
+
);
|
|
23522
23636
|
}
|
|
23523
|
-
|
|
23637
|
+
} else {
|
|
23638
|
+
const buildOut = await settleBuild(await hook(o, "build"));
|
|
23639
|
+
if (buildOut) return buildOut;
|
|
23524
23640
|
}
|
|
23525
23641
|
}
|
|
23526
23642
|
}
|
|
@@ -23534,6 +23650,10 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23534
23650
|
}
|
|
23535
23651
|
}
|
|
23536
23652
|
}
|
|
23653
|
+
if (!o.dryRun && o.stillHoldsLock && !await o.stillHoldsLock()) {
|
|
23654
|
+
o.emit.error("the board lock is no longer held by this release \u2014 not pushing or deploying; the tickets stay verified");
|
|
23655
|
+
return { merged, conflicts, unbuildable, version, deployed: false, decision, stopped: "release lock lost" };
|
|
23656
|
+
}
|
|
23537
23657
|
if (remoteConfigured(o.cwd, o.repo.branch.remote)) {
|
|
23538
23658
|
if (o.dryRun) {
|
|
23539
23659
|
o.emit.emit(`would push ${o.repo.branch.base} to ${o.repo.branch.remote}`);
|
|
@@ -23572,7 +23692,10 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23572
23692
|
integrated = true;
|
|
23573
23693
|
} else if (o.repo.release.mode === "local" && o.repo.hooks.deploy) {
|
|
23574
23694
|
if (o.dryRun) o.emit.emit(`would run: ${hookLabel(o.repo, "deploy")}`);
|
|
23575
|
-
else {
|
|
23695
|
+
else if (o.stillHoldsLock && !await o.stillHoldsLock()) {
|
|
23696
|
+
o.emit.error("the board lock is no longer held by this release \u2014 not deploying; run `crew deploy` once the other release has finished");
|
|
23697
|
+
return { merged, conflicts, unbuildable, version, deployed: false, decision, stopped: "release lock lost" };
|
|
23698
|
+
} else {
|
|
23576
23699
|
let r = await hook(o, "deploy");
|
|
23577
23700
|
if (r && r.code !== 0 && looksLikeTransientResolveFailure(r.output)) {
|
|
23578
23701
|
o.emit.warn("deploy failed with what looks like a transient dependency-resolution glitch, not a real failure \u2014 retrying once");
|
|
@@ -23631,6 +23754,33 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23631
23754
|
);
|
|
23632
23755
|
return { merged, conflicts, unbuildable, version, tag, deployed, integrated, confirmed, decision, ...ciOutcome(o, watch2, confirmed) };
|
|
23633
23756
|
}
|
|
23757
|
+
var MAX_CONSECUTIVE_RELEASE_PASSES = 5;
|
|
23758
|
+
var RELEASED_OUTCOMES = /* @__PURE__ */ new Set(["deployed", "merged", "integrated"]);
|
|
23759
|
+
async function runFleetPasses(deps) {
|
|
23760
|
+
const cap = deps.cap ?? MAX_CONSECUTIVE_RELEASE_PASSES;
|
|
23761
|
+
let passes = 0;
|
|
23762
|
+
let only;
|
|
23763
|
+
for (; ; ) {
|
|
23764
|
+
const results = await deps.pass(only);
|
|
23765
|
+
passes++;
|
|
23766
|
+
const released = results.filter((r) => RELEASED_OUTCOMES.has(r.summary.outcome));
|
|
23767
|
+
if (released.length === 0 || deps.refused()) return passes;
|
|
23768
|
+
const next = [];
|
|
23769
|
+
for (const r of released) {
|
|
23770
|
+
const count = await deps.waiting(r.key);
|
|
23771
|
+
if (count > 0) next.push({ key: r.key, count });
|
|
23772
|
+
}
|
|
23773
|
+
if (next.length === 0) return passes;
|
|
23774
|
+
if (passes >= cap) {
|
|
23775
|
+
deps.emit(`release: ${cap} consecutive passes run with verified tickets still waiting \u2014 leaving the rest to the timer`);
|
|
23776
|
+
return passes;
|
|
23777
|
+
}
|
|
23778
|
+
for (const n of next) {
|
|
23779
|
+
deps.emit(`release: repeating ${deps.describe(n.key)} \u2014 ${n.count} verified ticket${n.count === 1 ? "" : "s"} waiting`);
|
|
23780
|
+
}
|
|
23781
|
+
only = next.map((n) => n.key);
|
|
23782
|
+
}
|
|
23783
|
+
}
|
|
23634
23784
|
|
|
23635
23785
|
// src/failure-alert.ts
|
|
23636
23786
|
var FAILURE_ALERT_MARKER = calloutHeader("CAUTION", "Failure Alert");
|
|
@@ -29587,7 +29737,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
29587
29737
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
29588
29738
|
import { join as join61 } from "path";
|
|
29589
29739
|
function builtVersion() {
|
|
29590
|
-
return true ? "0.
|
|
29740
|
+
return true ? "0.167.0" : null;
|
|
29591
29741
|
}
|
|
29592
29742
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
29593
29743
|
function newestMtime(path) {
|
|
@@ -32646,16 +32796,43 @@ if (command === "passenger-sync-daemon") {
|
|
|
32646
32796
|
}
|
|
32647
32797
|
async function releaseFleet(opts = {}) {
|
|
32648
32798
|
sweepStateDir();
|
|
32649
|
-
|
|
32650
|
-
|
|
32651
|
-
|
|
32652
|
-
|
|
32653
|
-
|
|
32654
|
-
|
|
32655
|
-
|
|
32656
|
-
|
|
32657
|
-
|
|
32658
|
-
|
|
32799
|
+
const keyOf = (k) => `${k.c.route}\0${k.r.name}`;
|
|
32800
|
+
await runFleetPasses({
|
|
32801
|
+
pass: async (only) => {
|
|
32802
|
+
if (!only && releaseRefused()) return [];
|
|
32803
|
+
precheckTickets.clear();
|
|
32804
|
+
const wanted = only ? new Set(only.map(keyOf)) : void 0;
|
|
32805
|
+
const summaries = [];
|
|
32806
|
+
const results = [];
|
|
32807
|
+
if (!dryRun) state.releaseHeartbeat().touch();
|
|
32808
|
+
for (const c of cfg.routes) {
|
|
32809
|
+
if (!dryRun && !c.enabled) continue;
|
|
32810
|
+
for (const r of reposOf(c)) {
|
|
32811
|
+
if (wanted && !wanted.has(keyOf({ c, r }))) continue;
|
|
32812
|
+
const summary = await releasePhase(c, r, opts);
|
|
32813
|
+
summaries.push({ ...summary, route: c.route });
|
|
32814
|
+
results.push({ key: { c, r }, summary });
|
|
32815
|
+
}
|
|
32816
|
+
}
|
|
32817
|
+
emitReleaseSummary(emit, summaries);
|
|
32818
|
+
if (!dryRun) state.releaseHeartbeat().touch();
|
|
32819
|
+
return results;
|
|
32820
|
+
},
|
|
32821
|
+
waiting: async ({ c, r }) => {
|
|
32822
|
+
try {
|
|
32823
|
+
const identity = await resolveReleaseKey(c);
|
|
32824
|
+
const tracker = new Tracker(c, cfg.ship, { apiKey: identity.apiKey });
|
|
32825
|
+
const { byRepo } = ticketsByRepo(c, await tracker.openTickets());
|
|
32826
|
+
const modes = { modes: await tracker.projectWorkModes(), agentAssignees: /* @__PURE__ */ new Set() };
|
|
32827
|
+
return withoutManualVerified(byRepo.get(r.name) ?? [], tracker.contract.statuses.verified, modes).filter((t) => t.status === tracker.contract.statuses.verified).length;
|
|
32828
|
+
} catch {
|
|
32829
|
+
return 0;
|
|
32830
|
+
}
|
|
32831
|
+
},
|
|
32832
|
+
refused: () => !dryRun && releaseRefused(),
|
|
32833
|
+
describe: ({ c, r }) => releaseLockScope(c.route, r.name),
|
|
32834
|
+
emit: (line) => emit.emit(line, { step: "release" })
|
|
32835
|
+
});
|
|
32659
32836
|
}
|
|
32660
32837
|
async function releaseTargets(opts = {}) {
|
|
32661
32838
|
if (releaseRefused()) return;
|
|
@@ -33162,6 +33339,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33162
33339
|
return { scope, tests: "skipped", outcome: "skipped", detail: "a previous release is still running" };
|
|
33163
33340
|
}
|
|
33164
33341
|
let boardLock;
|
|
33342
|
+
let primaryRebuild;
|
|
33165
33343
|
try {
|
|
33166
33344
|
let contractRefusal = null;
|
|
33167
33345
|
const repoFile = loadRepoConfigTolerant(target.dir, (e) => {
|
|
@@ -33438,12 +33616,14 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33438
33616
|
// genuinely unreleased.
|
|
33439
33617
|
force: command === "deploy" || flag("force"),
|
|
33440
33618
|
isDeployCommand: opts.isDeployCommand,
|
|
33619
|
+
stillHoldsLock: boardLock?.ok ? boardLock.stillHeld : void 0,
|
|
33441
33620
|
attention: {
|
|
33442
33621
|
raise: (item) => raiseShipAttention({ state, emit: remit, route: c, ship: cfg.ship }, item),
|
|
33443
33622
|
clear: (key) => clearShipAttention(state, key),
|
|
33444
33623
|
clearKind: (kind, keyPrefix) => clearShipAttentionKind(state, kind, keyPrefix)
|
|
33445
33624
|
}
|
|
33446
33625
|
});
|
|
33626
|
+
primaryRebuild = outcome.primaryRebuild;
|
|
33447
33627
|
const summary = summarizeOutcome(outcome, scope, !!repo.hooks.test && !flag("skip-tests"));
|
|
33448
33628
|
if (outcome.deployed || outcome.confirmed || outcome.alreadyLive || outcome.integrated) {
|
|
33449
33629
|
remit.enter("reconcile");
|
|
@@ -33782,6 +33962,13 @@ ${f2.tail.trimEnd()}
|
|
|
33782
33962
|
} finally {
|
|
33783
33963
|
if (boardLock && boardLock.ok) await boardLock.release();
|
|
33784
33964
|
if (relLock && relLock.ok) relLock.release();
|
|
33965
|
+
if (primaryRebuild) {
|
|
33966
|
+
try {
|
|
33967
|
+
await primaryRebuild();
|
|
33968
|
+
} catch (e) {
|
|
33969
|
+
remit.warn(`rebuilding the primary checkout failed: ${e.message}`, { step: "release" });
|
|
33970
|
+
}
|
|
33971
|
+
}
|
|
33785
33972
|
}
|
|
33786
33973
|
}
|
|
33787
33974
|
let lock;
|
|
@@ -24800,6 +24800,19 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
24800
24800
|
"verify",
|
|
24801
24801
|
"isolateFailures",
|
|
24802
24802
|
"rightOfWayMinutes",
|
|
24803
|
+
"parallelGates",
|
|
24804
|
+
"versioning",
|
|
24805
|
+
"versionFiles",
|
|
24806
|
+
"changelog",
|
|
24807
|
+
"tag",
|
|
24808
|
+
"tagPattern",
|
|
24809
|
+
"mode",
|
|
24810
|
+
"ship",
|
|
24811
|
+
"ci",
|
|
24812
|
+
"verify",
|
|
24813
|
+
"isolateFailures",
|
|
24814
|
+
"rightOfWayMinutes",
|
|
24815
|
+
"rebuildPrimary",
|
|
24803
24816
|
"versioning",
|
|
24804
24817
|
"versionFiles",
|
|
24805
24818
|
"changelog",
|
|
@@ -24810,6 +24823,11 @@ var VERSIONINGS = ["auto", "none"];
|
|
|
24810
24823
|
var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
|
|
24811
24824
|
var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
|
|
24812
24825
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
24826
|
+
function parseRebuildPrimary(raw, fail2) {
|
|
24827
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
24828
|
+
if (typeof raw !== "boolean") throw fail2(`release.rebuildPrimary must be true or false (got "${raw}")`);
|
|
24829
|
+
return raw;
|
|
24830
|
+
}
|
|
24813
24831
|
function parseRightOfWayMinutes(raw, fail2) {
|
|
24814
24832
|
if (raw === void 0 || raw === null) return void 0;
|
|
24815
24833
|
const n = Number(raw);
|
|
@@ -25041,6 +25059,11 @@ function parseRepoConfig(text, file) {
|
|
|
25041
25059
|
(m) => new RepoConfigError(`${file}: ${m}`)
|
|
25042
25060
|
);
|
|
25043
25061
|
const rightOfWay = parseRightOfWayMinutes(raw.release?.rightOfWayMinutes, (m) => new RepoConfigError(`${file}: ${m}`));
|
|
25062
|
+
const parallelGatesRaw = raw.release?.parallelGates;
|
|
25063
|
+
if (parallelGatesRaw !== void 0 && typeof parallelGatesRaw !== "boolean") {
|
|
25064
|
+
throw new RepoConfigError(`${file}: release.parallelGates must be true or false (got "${String(parallelGatesRaw)}")`);
|
|
25065
|
+
}
|
|
25066
|
+
const rebuildPrimary = parseRebuildPrimary(raw.release?.rebuildPrimary, (m) => new RepoConfigError(`${file}: ${m}`));
|
|
25044
25067
|
const versioning = String(raw.release?.versioning ?? "auto");
|
|
25045
25068
|
if (!VERSIONINGS.includes(versioning)) {
|
|
25046
25069
|
throw new RepoConfigError(`${file}: release.versioning must be auto|none (got "${versioning}")`);
|
|
@@ -25119,6 +25142,8 @@ function parseRepoConfig(text, file) {
|
|
|
25119
25142
|
verify,
|
|
25120
25143
|
isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
|
|
25121
25144
|
rightOfWayMinutes: rightOfWay,
|
|
25145
|
+
...parallelGatesRaw ? { parallelGates: true } : {},
|
|
25146
|
+
rebuildPrimary,
|
|
25122
25147
|
versioning,
|
|
25123
25148
|
versionFiles,
|
|
25124
25149
|
tag,
|
package/package.json
CHANGED