@kitman-sh/software-engineering 0.18.0 → 0.19.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/bundle.js +123 -33
- package/dist/declarations.json +1074 -765
- package/package.json +3 -3
- package/src/shepherd.ts +183 -28
package/dist/bundle.js
CHANGED
|
@@ -26459,6 +26459,8 @@ var landingStatus = (code) => code === "epic_landing" ? "landing" : code === "ta
|
|
|
26459
26459
|
var stepBudget = "45 minutes";
|
|
26460
26460
|
var pipelineRun = "10 minutes";
|
|
26461
26461
|
var targetLooks = 6;
|
|
26462
|
+
var targetRechecks = [2, 3, 5];
|
|
26463
|
+
var steered = { event: "run.steered" };
|
|
26462
26464
|
var watchLook = "6 hours";
|
|
26463
26465
|
var watchLooks = 28;
|
|
26464
26466
|
var roundLimits = { "ci-fix": 1, "head-fix": 2 };
|
|
@@ -26524,7 +26526,53 @@ var failedJobs = (pipeline) => pipeline.jobs.flatMap((job) => job.status === "fa
|
|
|
26524
26526
|
|
|
26525
26527
|
${job.logTail ?? "No log was served."}`] : []);
|
|
26526
26528
|
var failingJobs = (pipeline) => pipeline.jobs.flatMap((job) => job.status === "failed" ? [job.name] : []);
|
|
26527
|
-
var OnTarget = Struct({
|
|
26529
|
+
var OnTarget = Struct({
|
|
26530
|
+
failed: ArraySchema(String5),
|
|
26531
|
+
passed: ArraySchema(String5),
|
|
26532
|
+
timedOut: optional2(ArraySchema(String5))
|
|
26533
|
+
});
|
|
26534
|
+
var timedOutLine = /\b(?:Test|Hook) timed out in \d+ ?ms\b/u;
|
|
26535
|
+
var failLine = /^\s*FAIL\s+(.+?)\s*$/u;
|
|
26536
|
+
var parallelPrefix = /^\S(?:(?! +\| ).)* +\| ?/u;
|
|
26537
|
+
var parallelHeader = /^Failed in parallel: (.*)$/u;
|
|
26538
|
+
var failureBlocks = (lines) => {
|
|
26539
|
+
const blocks = [];
|
|
26540
|
+
let current;
|
|
26541
|
+
for (const line of lines) {
|
|
26542
|
+
const failed = failLine.exec(line);
|
|
26543
|
+
if (failed !== null) {
|
|
26544
|
+
if (current === undefined || current.timedOut !== undefined) {
|
|
26545
|
+
current = { names: [], timedOut: undefined };
|
|
26546
|
+
blocks.push(current);
|
|
26547
|
+
}
|
|
26548
|
+
current.names.push(failed[1] ?? "");
|
|
26549
|
+
} else if (current !== undefined && current.timedOut === undefined && line.trim() !== "")
|
|
26550
|
+
current.timedOut = timedOutLine.test(line);
|
|
26551
|
+
}
|
|
26552
|
+
return blocks;
|
|
26553
|
+
};
|
|
26554
|
+
var namedBy = (test, name) => test === name || test.startsWith(`${name} > `) || name.endsWith(` > ${test}`);
|
|
26555
|
+
var onlyTimedOut = (check) => {
|
|
26556
|
+
const failedTests = check.failedTests ?? [];
|
|
26557
|
+
const lines = (check.outputTail ?? "").split(`
|
|
26558
|
+
`);
|
|
26559
|
+
const header = parallelHeader.exec(lines[0] ?? "");
|
|
26560
|
+
if (failedTests.length === 0 || header !== null && header[1]?.includes("; ") === true)
|
|
26561
|
+
return false;
|
|
26562
|
+
const blocks = failureBlocks(header === null ? lines : lines.map((line) => line.replace(parallelPrefix, "")));
|
|
26563
|
+
const timedOut = blocks.filter((block) => block.timedOut === true).flatMap((block) => block.names);
|
|
26564
|
+
return blocks.every((block) => block.timedOut === true) && failedTests.every((test) => timedOut.some((name) => namedBy(test, name)));
|
|
26565
|
+
};
|
|
26566
|
+
var listed = (names) => names.join(", ");
|
|
26567
|
+
var redTargetWhy = (target, head, failing, onTarget) => {
|
|
26568
|
+
const failed = failing.filter((name) => onTarget.failed.includes(name));
|
|
26569
|
+
const timedOut = failing.filter((name) => (onTarget.timedOut ?? []).includes(name));
|
|
26570
|
+
const rerun = `Shepherd runs ${listed(timedOut)} there again after a wait rather than fixing ${head}`;
|
|
26571
|
+
if (failed.length === 0)
|
|
26572
|
+
return `${target} only timed out on ${listed(timedOut)} at its own head, which reads as a loaded Runner rather than a failure it shares: ${rerun}`;
|
|
26573
|
+
const shared = `${target} fails ${listed(failed)} at its own head too, so no fix here can mend it`;
|
|
26574
|
+
return timedOut.length === 0 ? shared : `${shared}; ${listed(timedOut)} only timed out there, which is not a failure it is known to share: ${rerun}`;
|
|
26575
|
+
};
|
|
26528
26576
|
var ciFixPrompt = (pipeline, target, onTarget) => {
|
|
26529
26577
|
const unknown = failingJobs(pipeline).filter((name) => !onTarget.failed.includes(name) && !onTarget.passed.includes(name));
|
|
26530
26578
|
return [
|
|
@@ -26537,6 +26585,9 @@ var ciFixPrompt = (pipeline, target, onTarget) => {
|
|
|
26537
26585
|
...onTarget.failed.length === 0 ? [] : [
|
|
26538
26586
|
`${onTarget.failed.join(", ")} fail at the head of \`origin/${target}\` too: they are the target's to fix, so leave them as they are.`
|
|
26539
26587
|
],
|
|
26588
|
+
...onTarget.timedOut === undefined || onTarget.timedOut.length === 0 ? [] : [
|
|
26589
|
+
`${onTarget.timedOut.join(", ")} only timed out at the head of \`origin/${target}\`, so whether they fail there is not known.`
|
|
26590
|
+
],
|
|
26540
26591
|
...unknown.length === 0 ? [] : [
|
|
26541
26592
|
`Run ${unknown.join(", ")} on the target branch (a worktree of \`origin/${target}\`, which Kitman fetched just before this Step; do not fetch). If every failing job fails there too, the branch did not cause it: change nothing and answer pre_existing.`
|
|
26542
26593
|
],
|
|
@@ -26740,10 +26791,10 @@ class TargetPassed extends TaggedClass2()("TargetPassed", { at: Shepherding }) {
|
|
|
26740
26791
|
class TargetMoved extends TaggedClass2()("TargetMoved", {}) {
|
|
26741
26792
|
}
|
|
26742
26793
|
|
|
26743
|
-
class Waited extends TaggedClass2()("Waited", {
|
|
26744
|
-
|
|
26745
|
-
|
|
26746
|
-
}) {
|
|
26794
|
+
class Waited extends TaggedClass2()("Waited", { woke: optional2(LoopEvent) }) {
|
|
26795
|
+
}
|
|
26796
|
+
|
|
26797
|
+
class Rechecked extends TaggedClass2()("Rechecked", { passing: ArraySchema(String5) }) {
|
|
26747
26798
|
}
|
|
26748
26799
|
var withAdded = (list, item) => list.includes(item) ? list : [...list, item];
|
|
26749
26800
|
var approvalAt = (at, head) => at.approvalOf.find((entry) => entry.head === head)?.approval;
|
|
@@ -26804,6 +26855,10 @@ var mergedInto = (charge, repository, since) => ({
|
|
|
26804
26855
|
or: [{ event: "change_request.closed", filter: { changeRequestId: charge.changeRequestId } }],
|
|
26805
26856
|
...since === undefined ? undefined : { since }
|
|
26806
26857
|
});
|
|
26858
|
+
var redTargetWait = (charge, repository, since) => {
|
|
26859
|
+
const merged = mergedInto(charge, repository, since);
|
|
26860
|
+
return { ...merged, or: [...merged.or, { ...steered, ...since === undefined ? undefined : { since } }] };
|
|
26861
|
+
};
|
|
26807
26862
|
var closedBy = (charge, at, woke, mergedBy) => woke?.payload.changeRequestId !== charge.changeRequestId ? undefined : woke.payload.merged === true ? new MergedElsewhere({ at, reason: `${mergedBy} merged the ChangeRequest` }) : new NeedsYou({ at, reason: "The ChangeRequest was closed" });
|
|
26808
26863
|
var handedBack = step2("handedBack", {
|
|
26809
26864
|
payload: { charge: Charge, at: Shepherding, ...Standing.fields },
|
|
@@ -27026,23 +27081,46 @@ var targetChecked = step2("targetChecked", {
|
|
|
27026
27081
|
const onRunner = failing.filter((name) => !failed.includes(name) && !passed.includes(name) && (pipeline.runnerChecks ?? []).includes(name));
|
|
27027
27082
|
if (onRunner.length === 0)
|
|
27028
27083
|
return { failed, passed };
|
|
27029
|
-
const atTarget = yield* verify("target-check", {
|
|
27084
|
+
const atTarget = yield* verify("target-check", {
|
|
27085
|
+
revision: `origin/${charge.target}`,
|
|
27086
|
+
checks: onRunner,
|
|
27087
|
+
rerunFailed: true
|
|
27088
|
+
}).pipe(catchTag2("StepFailed", () => undefined_2));
|
|
27030
27089
|
const ran = atTarget?.checks.filter((check) => onRunner.includes(check.name)) ?? [];
|
|
27090
|
+
const timedOut = ran.flatMap((check) => check.status === "failed" && onlyTimedOut(check) ? [check.name] : []);
|
|
27031
27091
|
return {
|
|
27032
|
-
failed: [
|
|
27033
|
-
|
|
27092
|
+
failed: [
|
|
27093
|
+
...failed,
|
|
27094
|
+
...ran.flatMap((check) => check.status === "failed" && !timedOut.includes(check.name) ? [check.name] : [])
|
|
27095
|
+
],
|
|
27096
|
+
passed: [...passed, ...ran.flatMap((check) => check.status === "passed" ? [check.name] : [])],
|
|
27097
|
+
...timedOut.length === 0 ? undefined : { timedOut }
|
|
27034
27098
|
};
|
|
27035
27099
|
})
|
|
27036
27100
|
});
|
|
27037
27101
|
var targetReread = step2("targetReread", {
|
|
27038
|
-
payload: {
|
|
27039
|
-
|
|
27040
|
-
|
|
27102
|
+
payload: {
|
|
27103
|
+
charge: Charge,
|
|
27104
|
+
repository: optional2(String5),
|
|
27105
|
+
pipeline: PipelineStatus,
|
|
27106
|
+
recheck: optional2(Boolean3)
|
|
27107
|
+
},
|
|
27108
|
+
success: Union2([TargetMoved, Rechecked, Waited]),
|
|
27109
|
+
run: ({ charge, repository, pipeline, recheck }) => gen2(function* () {
|
|
27041
27110
|
const again = yield* pipelineStatus("target-read", { changeRequestId: charge.changeRequestId });
|
|
27042
27111
|
if (again.head !== pipeline.head || again.target?.head !== pipeline.target?.head)
|
|
27043
27112
|
return new TargetMoved;
|
|
27113
|
+
if (recheck === true) {
|
|
27114
|
+
const onTarget = yield* targetChecked({
|
|
27115
|
+
charge,
|
|
27116
|
+
pipeline: again.target === undefined ? pipeline : { ...pipeline, target: again.target }
|
|
27117
|
+
});
|
|
27118
|
+
const passing = failingJobs(pipeline).filter((name) => onTarget.passed.includes(name));
|
|
27119
|
+
if (passing.length > 0)
|
|
27120
|
+
return new Rechecked({ passing });
|
|
27121
|
+
}
|
|
27044
27122
|
const woke = yield* waitFor("target-moved", {
|
|
27045
|
-
...
|
|
27123
|
+
...redTargetWait(charge, repository, pipeline.readAt),
|
|
27046
27124
|
timeout: pipelineRun
|
|
27047
27125
|
}).pipe(catchTag2("WaitTimedOut", () => undefined_2));
|
|
27048
27126
|
return new Waited({ woke });
|
|
@@ -27058,18 +27136,34 @@ var waitedOut = step2("waitedOut", {
|
|
|
27058
27136
|
}).pipe(catchTag2("StepFailed", () => void_3));
|
|
27059
27137
|
const targetHead = pipeline.target?.head;
|
|
27060
27138
|
const first = yield* waitFor("target-moved", {
|
|
27061
|
-
...
|
|
27062
|
-
timeout:
|
|
27139
|
+
...redTargetWait(charge, at.repository, pipeline.readAt),
|
|
27140
|
+
timeout: pipelineRun
|
|
27063
27141
|
}).pipe(catchTag2("WaitTimedOut", () => undefined_2));
|
|
27142
|
+
const failing = failingJobs(pipeline);
|
|
27064
27143
|
const wokeBy = (woke) => closedBy(charge, at, woke, "Someone else") ?? new Again({ at: { ...at, redTarget: { head: pipeline.head, targetHead, moved: woke !== undefined } } });
|
|
27065
|
-
|
|
27066
|
-
|
|
27144
|
+
const steerRead = as2(note("steer-read", {
|
|
27145
|
+
text: `Shepherd read a steer while it waited for ${charge.target}: it weighs the failure at ${pipeline.head} again now, merging in ${charge.target} if it moved, else running ${listed(failing)} there once more. An agent Step reads the steer's words when one runs; while ${charge.target} still fails as ${pipeline.head} does, none does.`
|
|
27146
|
+
}).pipe(catchTag2("StepFailed", () => void_3)), wokeBy(undefined));
|
|
27147
|
+
const ended = (woke) => woke?.type === steered.event ? steerRead : succeed7(wokeBy(woke));
|
|
27148
|
+
if (first !== undefined)
|
|
27149
|
+
return yield* ended(first);
|
|
27067
27150
|
for (let look = 2;look <= targetLooks; look++) {
|
|
27068
|
-
const again = yield* targetReread({
|
|
27151
|
+
const again = yield* targetReread({
|
|
27152
|
+
charge,
|
|
27153
|
+
repository: at.repository,
|
|
27154
|
+
pipeline,
|
|
27155
|
+
recheck: targetRechecks.includes(look)
|
|
27156
|
+
});
|
|
27069
27157
|
if (again._tag === "TargetMoved")
|
|
27070
27158
|
return wokeBy(undefined);
|
|
27159
|
+
if (again._tag === "Rechecked") {
|
|
27160
|
+
yield* note("target-rechecked", {
|
|
27161
|
+
text: `${charge.target} passes ${listed(again.passing)} now, run again at the same head: Shepherd stops waiting and weighs the failure at ${pipeline.head} again`
|
|
27162
|
+
}).pipe(catchTag2("StepFailed", () => void_3));
|
|
27163
|
+
return new Again({ at: { ...at, redTarget: undefined } });
|
|
27164
|
+
}
|
|
27071
27165
|
if (again.woke !== undefined)
|
|
27072
|
-
return
|
|
27166
|
+
return yield* ended(again.woke);
|
|
27073
27167
|
}
|
|
27074
27168
|
return wokeBy(undefined);
|
|
27075
27169
|
})
|
|
@@ -27557,13 +27651,9 @@ var failureWeighed = (charge, at, pipeline) => gen2(function* () {
|
|
|
27557
27651
|
return yield* caughtUp({ charge, at: { ...at, redTarget: undefined }, head, targetHead });
|
|
27558
27652
|
const onTarget = yield* targetChecked({ charge, pipeline });
|
|
27559
27653
|
const failing = failingJobs(pipeline);
|
|
27560
|
-
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
at,
|
|
27564
|
-
pipeline,
|
|
27565
|
-
why: `${target} fails ${failing.join(", ")} at its own head too, so no fix here can mend it`
|
|
27566
|
-
});
|
|
27654
|
+
const redAtTarget = [...onTarget.failed, ...onTarget.timedOut ?? []];
|
|
27655
|
+
if (failing.length > 0 && failing.every((name) => redAtTarget.includes(name)))
|
|
27656
|
+
return yield* waitedOut({ charge, at, pipeline, why: redTargetWhy(target, head, failing, onTarget) });
|
|
27567
27657
|
if (onTarget.passed.length > 0 && redTarget?.head === head)
|
|
27568
27658
|
return yield* caughtUp({ charge, at: { ...at, redTarget: undefined }, head, targetHead });
|
|
27569
27659
|
if (redTarget?.head === head)
|
|
@@ -32308,12 +32398,12 @@ var untagged2 = (repository, status, reason) => ({
|
|
|
32308
32398
|
tagged: false,
|
|
32309
32399
|
deployed: false
|
|
32310
32400
|
});
|
|
32311
|
-
var
|
|
32401
|
+
var listed2 = (results, keep) => results.flatMap((result) => keep(result) ? [`${result.repository ?? result.repoBindingId}${result.tag === undefined ? "" : ` ${result.tag}`}`] : []);
|
|
32312
32402
|
var settledWords = (results) => {
|
|
32313
|
-
const deployed =
|
|
32314
|
-
const taggedOnly =
|
|
32315
|
-
const mayHaveTagged =
|
|
32316
|
-
const notTagged =
|
|
32403
|
+
const deployed = listed2(results, (result) => result.deployed);
|
|
32404
|
+
const taggedOnly = listed2(results, (result) => result.tagged === true && !result.deployed);
|
|
32405
|
+
const mayHaveTagged = listed2(results, (result) => result.tagged === "unknown");
|
|
32406
|
+
const notTagged = listed2(results, (result) => result.tagged === false);
|
|
32317
32407
|
return [
|
|
32318
32408
|
...deployed.length === 0 ? [] : [`tagged and deployed: ${deployed.join(", ")}`],
|
|
32319
32409
|
...taggedOnly.length === 0 ? [] : [`tagged, not deployed: ${taggedOnly.join(", ")}`],
|
|
@@ -33164,7 +33254,7 @@ class LeftOpen extends TaggedClass2()("LeftOpen", {
|
|
|
33164
33254
|
notRun: ArraySchema(String5)
|
|
33165
33255
|
}) {
|
|
33166
33256
|
}
|
|
33167
|
-
var
|
|
33257
|
+
var listed3 = step2("listed", {
|
|
33168
33258
|
payload: { authors: NonEmptyArray(String5) },
|
|
33169
33259
|
success: Union2([Listed, NothingToSweep, LeftOpen]),
|
|
33170
33260
|
run: ({ authors }) => gen2(function* () {
|
|
@@ -33386,7 +33476,7 @@ var sweep_default = defineLoop({
|
|
|
33386
33476
|
calls: () => [shepherd_default],
|
|
33387
33477
|
run: (input) => gen2(function* () {
|
|
33388
33478
|
const authors = input.authors ?? defaultAuthors;
|
|
33389
|
-
const found = yield*
|
|
33479
|
+
const found = yield* listed3({ authors });
|
|
33390
33480
|
if (found._tag === "NothingToSweep")
|
|
33391
33481
|
return {
|
|
33392
33482
|
status: "nothing_to_sweep",
|
|
@@ -39631,4 +39721,4 @@ var runKit = (config, identity, packages) => {
|
|
|
39631
39721
|
runMain2(program.pipe(flatMap3((code) => sync2(() => process.exit(code)))));
|
|
39632
39722
|
};
|
|
39633
39723
|
// .kitman-build-entry.ts
|
|
39634
|
-
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.
|
|
39724
|
+
runKit(kitman_config_default, { name: "@kitman-sh/software-engineering", version: "0.19.0" }, []);
|