@tablation/crew 0.166.0 → 0.167.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3586,6 +3586,18 @@ function worktreeNameProblem(template) {
3586
3586
  return null;
3587
3587
  }
3588
3588
  var RELEASE_KEYS = /* @__PURE__ */ new Set([
3589
+ "mode",
3590
+ "ship",
3591
+ "ci",
3592
+ "verify",
3593
+ "isolateFailures",
3594
+ "rightOfWayMinutes",
3595
+ "parallelGates",
3596
+ "versioning",
3597
+ "versionFiles",
3598
+ "changelog",
3599
+ "tag",
3600
+ "tagPattern",
3589
3601
  "mode",
3590
3602
  "ship",
3591
3603
  "ci",
@@ -3841,6 +3853,10 @@ function parseRepoConfig(text2, file) {
3841
3853
  (m) => new RepoConfigError(`${file}: ${m}`)
3842
3854
  );
3843
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
+ }
3844
3860
  const rebuildPrimary = parseRebuildPrimary(raw.release?.rebuildPrimary, (m) => new RepoConfigError(`${file}: ${m}`));
3845
3861
  const versioning = String(raw.release?.versioning ?? "auto");
3846
3862
  if (!VERSIONINGS.includes(versioning)) {
@@ -3920,6 +3936,7 @@ function parseRepoConfig(text2, file) {
3920
3936
  verify,
3921
3937
  isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
3922
3938
  rightOfWayMinutes: rightOfWay,
3939
+ ...parallelGatesRaw ? { parallelGates: true } : {},
3923
3940
  rebuildPrimary,
3924
3941
  versioning,
3925
3942
  versionFiles,
@@ -4132,6 +4149,7 @@ function resolveRepoConfig(repo, ship, dir) {
4132
4149
  )
4133
4150
  },
4134
4151
  rightOfWayMinutes: repo?.release.rightOfWayMinutes ?? ship?.release?.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES,
4152
+ ...repo?.release.parallelGates ? { parallelGates: true } : {},
4135
4153
  rebuildPrimary: repo?.release.rebuildPrimary ?? false,
4136
4154
  versioning: pick(
4137
4155
  "release.versioning",
@@ -23512,81 +23530,113 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23512
23530
  }
23513
23531
  }
23514
23532
  }
23515
- if (!(o.isDeployCommand && nothingToDeploy) && !o.skipTests && o.repo.hooks.test) {
23516
- if (o.dryRun) o.emit.emit(`would run the test gate: ${hookLabel(o.repo, "test")}`);
23517
- else {
23518
- let r = await hook(o, "test");
23519
- if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
23520
- if (r && r.code !== 0 && !isolated) {
23521
- const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
23522
- if (out && "tried" in out) isolation = out.tried;
23523
- else if (out) return out;
23524
- }
23525
- if (r && r.code !== 0) {
23526
- 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"));
23527
- const sha = headSha(o.cwd);
23528
- const count = o.state?.noteTestGateFailed?.(sha) ?? 1;
23529
- const gateRed = count >= GATE_RED_AFTER && !o.state?.testGateReported?.(sha) ? { sha, count, hook: hookLabel(o.repo, "test"), tail: lastLines(r.output, 15) } : void 0;
23530
- const composition = {
23531
- head: sha,
23532
- base: preMerge,
23533
- branches: merged.filter((c) => c.branch).map((c) => ({
23534
- key: c.ticket.issue_tag ?? c.ticket.issue_id,
23535
- branch: c.branch,
23536
- tip: resolve3(o.cwd, c.branch) ?? ""
23537
- }))
23538
- };
23539
- const hookFailure2 = {
23540
- hook: "test",
23541
- label: hookLabel(o.repo, "test"),
23542
- tail: failureSummary(r.output, HOOK_FAILURE_TAIL_LINES)
23543
- };
23544
- return { merged, conflicts, unbuildable, deployed: false, stopped: "tests failed", decision, gateRed, hookFailure: hookFailure2, composition, ...isolation ? { isolation } : {} };
23545
- }
23546
- o.state?.clearTestGateFailed?.();
23547
- }
23548
- }
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;
23549
23536
  const size = merged.some((m) => m.bump === "minor") ? "minor" : "patch";
23550
23537
  const majorRequested = merged.some((m) => m.majorRequested);
23551
- if (majorRequested) {
23552
- o.emit.warn("a branch asked for a MAJOR bump \u2014 honoured as minor; major is the operator's call");
23553
- }
23554
- const preBump = headSha(o.cwd);
23555
- const version = await bump(o, size) ?? void 0;
23556
- if (!version && o.dryRun && o.repo.hooks.bump) {
23557
- o.emit.emit("would then commit the version bump and changelog");
23558
- } else if (version) {
23559
- writeChangelog(o, version, merged.flatMap((m) => m.entries));
23560
- if (!o.dryRun) {
23561
- git(o.cwd, ["add", "-A"]);
23562
- git(o.cwd, ["commit", "-m", `Release ${o.repo.release.tag ? renderTag(o.repo.release.tag, version) : version}`]);
23563
- } else {
23564
- o.emit.emit(`would commit the version bump and changelog`);
23565
- }
23566
- }
23567
- if (o.repo.hooks.build) {
23568
- if (o.dryRun) {
23569
- o.emit.emit(`would run: ${hookLabel(o.repo, "build")}`);
23570
- if (applied >= 1) {
23571
- o.emit.emit(
23572
- `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`
23573
- );
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`);
23574
23555
  }
23575
- } else {
23576
- let r = await hook(o, "build");
23577
- if (r && r.code !== 0) r = await rerunOnce(o, "build", r);
23578
- if (r && r.code !== 0 && !isolated) {
23579
- const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch);
23580
- if (out && "tried" in out) isolation = out.tried;
23581
- else if (out) return out;
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;
23582
23626
  }
23583
- if (r && r.code !== 0) {
23584
- o.emit.error(withFix("build failed \u2014 not deploying", "`crew doctor`, then run the repo's build hook in the release checkout"));
23585
- if (version && !o.dryRun && headSha(o.cwd) !== preBump) {
23586
- git(o.cwd, ["reset", "--hard", preBump]);
23587
- 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`);
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
+ );
23588
23636
  }
23589
- return { merged, conflicts, unbuildable, version, deployed: false, stopped: "build failed", decision, hookFailure: hookFailure(o, "build", r.output), ...isolation ? { isolation } : {} };
23637
+ } else {
23638
+ const buildOut = await settleBuild(await hook(o, "build"));
23639
+ if (buildOut) return buildOut;
23590
23640
  }
23591
23641
  }
23592
23642
  }
@@ -29687,7 +29737,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29687
29737
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29688
29738
  import { join as join61 } from "path";
29689
29739
  function builtVersion() {
29690
- return true ? "0.166.0" : null;
29740
+ return true ? "0.167.1" : null;
29691
29741
  }
29692
29742
  var REBUILD_HINT = "rebuild with npm run build";
29693
29743
  function newestMtime(path) {
@@ -24794,6 +24794,18 @@ function worktreeNameProblem(template) {
24794
24794
  return null;
24795
24795
  }
24796
24796
  var RELEASE_KEYS = /* @__PURE__ */ new Set([
24797
+ "mode",
24798
+ "ship",
24799
+ "ci",
24800
+ "verify",
24801
+ "isolateFailures",
24802
+ "rightOfWayMinutes",
24803
+ "parallelGates",
24804
+ "versioning",
24805
+ "versionFiles",
24806
+ "changelog",
24807
+ "tag",
24808
+ "tagPattern",
24797
24809
  "mode",
24798
24810
  "ship",
24799
24811
  "ci",
@@ -25047,6 +25059,10 @@ function parseRepoConfig(text, file) {
25047
25059
  (m) => new RepoConfigError(`${file}: ${m}`)
25048
25060
  );
25049
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
+ }
25050
25066
  const rebuildPrimary = parseRebuildPrimary(raw.release?.rebuildPrimary, (m) => new RepoConfigError(`${file}: ${m}`));
25051
25067
  const versioning = String(raw.release?.versioning ?? "auto");
25052
25068
  if (!VERSIONINGS.includes(versioning)) {
@@ -25126,6 +25142,7 @@ function parseRepoConfig(text, file) {
25126
25142
  verify,
25127
25143
  isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
25128
25144
  rightOfWayMinutes: rightOfWay,
25145
+ ...parallelGatesRaw ? { parallelGates: true } : {},
25129
25146
  rebuildPrimary,
25130
25147
  versioning,
25131
25148
  versionFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.166.0",
3
+ "version": "0.167.1",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",