@cbartens/bkit 5.5.0 → 5.5.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/.bkit/README.md +2 -2
- package/.bkit/core/.agents/rules.md +17 -1
- package/.bkit/core/.bkit/README.md +1 -1
- package/.bkit/core/.bkit/cloud.md +2 -2
- package/.bkit/core/.bkit/install.md +3 -4
- package/.bkit/core/.bkit/prompts.md +29 -14
- package/.bkit/core/.bkit/templates.md +34 -9
- package/.bkit/core/.bkit/trackers.md +10 -1
- package/.bkit/core/.bkit/workflows.md +10 -9
- package/.bkit/core/engine/checks/after/ci-yml.ts +0 -1
- package/.bkit/core/engine/checks/after/github.ts +24 -73
- package/.bkit/core/engine/checks/after/index.ts +0 -5
- package/.bkit/core/engine/checks/after/tools.ts +1 -1
- package/.bkit/core/engine/checks/tips/index.ts +5 -2
- package/.bkit/core/engine/commands/workflow/issues.ts +26 -47
- package/.bkit/core/engine/commands/workflow/repo.ts +2 -0
- package/.bkit/core/engine/commands/workflow/worktrees.ts +91 -14
- package/.bkit/core/engine/install/modules/core.ts +77 -6
- package/.bkit/core/engine/shared/settings.ts +46 -14
- package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -0
- package/.bkit/core/prompts/bkit-design-generate.md +2 -0
- package/.bkit/core/prompts/bkit-plan-generate.md +5 -3
- package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-documentation.md +1 -1
- package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
- package/.bkit/core/workflows/bkit-build.md +3 -3
- package/.bkit/core/workflows/bkit-debug.md +3 -3
- package/.bkit/core/workflows/bkit-design.md +3 -3
- package/.bkit/core/workflows/bkit-plan.md +3 -3
- package/.bkit/core/workflows/bkit-ship.md +3 -3
- package/.bkit/shared/docs/deployments.md +5 -17
- package/.bkit/shared/docs/testing.md +11 -3
- package/.bkit/templates/.github/workflows/bkit-ci.yml +21 -83
- package/.bkit/templates/.husky/pre-push +48 -9
- package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +194 -0
- package/.bkit/templates/scripts/ci/check-capstone.mjs +2 -4
- package/.bkit/templates/scripts/ci/check-capstone.test.mjs +4 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +104 -23
- package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +103 -6
- package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +3 -1
- package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +49 -29
- package/CHANGELOG.md +30 -0
- package/README.md +9 -0
- package/dist/checks/after/ci-yml.js +0 -1
- package/dist/checks/after/github.js +24 -71
- package/dist/checks/after/index.js +1 -6
- package/dist/checks/after/tools.js +1 -1
- package/dist/checks/tips/index.js +4 -2
- package/dist/commands/workflow/issues.js +25 -46
- package/dist/commands/workflow/repo.js +1 -0
- package/dist/commands/workflow/worktrees.js +74 -13
- package/dist/install/modules/core.js +81 -6
- package/dist/shared/settings.js +23 -10
- package/package.json +4 -2
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +0 -138
- package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +0 -181
package/dist/shared/settings.js
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
import { DEFAULT_CLOUD_AGENTS, DEFAULT_ISSUE_TRACKER, parseCloudAgents, parseIssueTracker, } from "../install/manifest.js";
|
|
6
6
|
import { isOpencodeProvider } from "../render/models.js";
|
|
7
7
|
import { readPackageJson } from "./package-json.js";
|
|
8
|
+
const BOARD_URL = /^https:\/\/github\.com\/(orgs|users)\/([^/?#\s]+)\/projects\/([1-9][0-9]*)(?:[/?#].*)?$/;
|
|
9
|
+
/** The board a `https://github.com/{orgs|users}/<login>/projects/<n>[/views/…]` URL names; null otherwise. */
|
|
10
|
+
export function parseGithubBoardUrl(url) {
|
|
11
|
+
const m = BOARD_URL.exec(url.trim());
|
|
12
|
+
if (!m)
|
|
13
|
+
return null;
|
|
14
|
+
return { ownerType: m[1] === "orgs" ? "org" : "user", owner: m[2], number: Number(m[3]) };
|
|
15
|
+
}
|
|
8
16
|
export const CONFIG_DEFAULTS = {
|
|
9
17
|
ciWorkflow: "bkit-ci.yml",
|
|
10
18
|
capstoneJob: "bkit-tests-check",
|
|
@@ -12,10 +20,11 @@ export const CONFIG_DEFAULTS = {
|
|
|
12
20
|
worktreeInstall: true,
|
|
13
21
|
diskMinFreeGb: 40,
|
|
14
22
|
issueTracker: DEFAULT_ISSUE_TRACKER,
|
|
23
|
+
// The Status options of GitHub's Kanban and Team planning board templates.
|
|
24
|
+
github: { project: null, projectUrl: null, progress: "In progress", review: "In review" },
|
|
15
25
|
// `started` is a state type every Linear team has; In Review is a name a default team lacks.
|
|
16
26
|
linear: { team: null, project: null, progress: "started", review: "In Review" },
|
|
17
27
|
jira: { site: null, project: null, progress: "In Progress", review: "In Review" },
|
|
18
|
-
githubProject: null,
|
|
19
28
|
shipGateRequiredLanes: [],
|
|
20
29
|
// What bkit's workflows write: plan / design / build logs and the ledgers. Never
|
|
21
30
|
// `docs/**`: a project doc can be a test's input, so a docs edit can red a test.
|
|
@@ -48,13 +57,14 @@ export function readBkitConfig(root) {
|
|
|
48
57
|
const worktree = (bkit.worktree ?? {});
|
|
49
58
|
const copy = worktree.copy;
|
|
50
59
|
const minFreeGb = (bkit.disk ?? {}).minFreeGb;
|
|
51
|
-
const project = bkit.githubProject;
|
|
52
60
|
const lanes = bkit.shipGateRequiredLanes;
|
|
53
61
|
const book = bkit.minPushPaths;
|
|
54
62
|
const provider = bkit.opencodeProvider;
|
|
55
63
|
const providers = bkit.opencodeProviders;
|
|
64
|
+
const github = record(bkit.github);
|
|
56
65
|
const linear = record(bkit.linear);
|
|
57
66
|
const jira = record(bkit.jira);
|
|
67
|
+
const projectUrl = optionalString(github.project);
|
|
58
68
|
return {
|
|
59
69
|
ciWorkflow: nonEmptyString(bkit.ciWorkflow) ? bkit.ciWorkflow : CONFIG_DEFAULTS.ciWorkflow,
|
|
60
70
|
capstoneJob: nonEmptyString(bkit.capstoneJob) ? bkit.capstoneJob : CONFIG_DEFAULTS.capstoneJob,
|
|
@@ -66,6 +76,11 @@ export function readBkitConfig(root) {
|
|
|
66
76
|
? minFreeGb
|
|
67
77
|
: CONFIG_DEFAULTS.diskMinFreeGb,
|
|
68
78
|
issueTracker: parseIssueTracker(bkit.issueTracker) ?? CONFIG_DEFAULTS.issueTracker,
|
|
79
|
+
github: {
|
|
80
|
+
project: github.project === false ? false : projectUrl ? parseGithubBoardUrl(projectUrl) : null,
|
|
81
|
+
projectUrl,
|
|
82
|
+
...trackerStates(github, CONFIG_DEFAULTS.github),
|
|
83
|
+
},
|
|
69
84
|
linear: {
|
|
70
85
|
team: optionalString(linear.team),
|
|
71
86
|
project: optionalString(linear.project),
|
|
@@ -76,11 +91,6 @@ export function readBkitConfig(root) {
|
|
|
76
91
|
project: optionalString(jira.project),
|
|
77
92
|
...trackerStates(jira, CONFIG_DEFAULTS.jira),
|
|
78
93
|
},
|
|
79
|
-
githubProject: project === false
|
|
80
|
-
? false
|
|
81
|
-
: project !== null && typeof project === "object" && !Array.isArray(project)
|
|
82
|
-
? project
|
|
83
|
-
: null,
|
|
84
94
|
shipGateRequiredLanes: Array.isArray(lanes) ? lanes.filter(nonEmptyString) : [],
|
|
85
95
|
// An explicit [] is kept: it switches the min push off.
|
|
86
96
|
minPushPaths: Array.isArray(book)
|
|
@@ -97,9 +107,12 @@ export function readBkitConfig(root) {
|
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
109
|
export function trackerScope(cfg) {
|
|
110
|
+
const none = { trackerTeam: null, trackerProject: null, trackerSite: null, trackerBoard: null };
|
|
111
|
+
if (cfg.issueTracker === "github")
|
|
112
|
+
return { ...none, trackerBoard: cfg.github.project || null };
|
|
100
113
|
if (cfg.issueTracker === "linear")
|
|
101
|
-
return { trackerTeam: cfg.linear.team, trackerProject: cfg.linear.project
|
|
114
|
+
return { ...none, trackerTeam: cfg.linear.team, trackerProject: cfg.linear.project };
|
|
102
115
|
if (cfg.issueTracker === "jira")
|
|
103
|
-
return {
|
|
104
|
-
return
|
|
116
|
+
return { ...none, trackerProject: cfg.jira.project, trackerSite: cfg.jira.site };
|
|
117
|
+
return none;
|
|
105
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cbartens/bkit",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "From vibe coding to production code. A senior engineering team's process, ready-made: AI agents design, plan, build, review, fix and ship your features on Claude Code, Cursor, Codex, Google Antigravity and opencode.",
|
|
6
6
|
"keywords": [
|
|
@@ -119,7 +119,9 @@
|
|
|
119
119
|
"bkit": {
|
|
120
120
|
"issueTracker": "github",
|
|
121
121
|
"cloudAgents": "claude",
|
|
122
|
-
"
|
|
122
|
+
"github": {
|
|
123
|
+
"project": "https://github.com/users/cbartens/projects/1"
|
|
124
|
+
},
|
|
123
125
|
"opencodeProvider": "openrouter",
|
|
124
126
|
"opencodeProviders": [
|
|
125
127
|
"opencode-go",
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Example. Copy into scripts/ci/lanes/ and own it. bkit install does not write this file
|
|
3
|
-
// and does not overwrite a copy.
|
|
4
|
-
/**
|
|
5
|
-
* check-tree-cache.mjs — whether a pull request lane may skip its suite.
|
|
6
|
-
*
|
|
7
|
-
* A pull request lane skips when the files it would test are exactly the files a push run
|
|
8
|
-
* already tested green. "The files" is the git tree of the checked-out commit (for a pull
|
|
9
|
-
* request, GitHub's merge preview). A push run tests its head commit's tree, so a green push
|
|
10
|
-
* run whose head has the same tree proved this lane — provided that run's job of the same name
|
|
11
|
-
* concluded `success` (a `[skip ci]` or `run_level=none` push concludes green with every lane
|
|
12
|
-
* skipped, which proves nothing).
|
|
13
|
-
*
|
|
14
|
-
* Push and dispatch runs never skip: the run on a push to dev or the default branch is the
|
|
15
|
-
* record of what that branch holds, so it always runs the suite. `[force build]` /
|
|
16
|
-
* `[force cache]` in the pull request title skip nothing either.
|
|
17
|
-
*
|
|
18
|
-
* Usage: node scripts/ci/lanes/check-tree-cache.mjs >> "$GITHUB_OUTPUT"
|
|
19
|
-
* (env: GH_TOKEN, REPO, EVENT_NAME, JOB, PR_TITLE; optional WORKFLOW_FILE)
|
|
20
|
-
* Output: `skip=true` or `skip=false` on stdout; the reason on stderr. Exit 0 always — every
|
|
21
|
-
* failure (gh, git, unparseable output) resolves to `skip=false`, which runs the suite.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { spawnSync } from "node:child_process";
|
|
25
|
-
import { pathToFileURL } from "node:url";
|
|
26
|
-
|
|
27
|
-
/** The workflow whose runs count. Set WORKFLOW_FILE if your CI file has another name. */
|
|
28
|
-
export const WORKFLOW_FILE = process.env.WORKFLOW_FILE || "bkit-ci.yml";
|
|
29
|
-
|
|
30
|
-
/** How far back the run lookup reaches. */
|
|
31
|
-
export const LOOKBACK_DAYS = 7;
|
|
32
|
-
|
|
33
|
-
/** At most this many tree-matching runs have their jobs read before giving up. */
|
|
34
|
-
export const MAX_JOB_LOOKUPS = 3;
|
|
35
|
-
|
|
36
|
-
const FORCE_MARKERS = ["[force build]", "[force cache]"];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Pure decision. `runs` are green push runs (`{ id, run_number, tree }`); `jobConclusion(id)`
|
|
40
|
-
* returns the conclusion of this lane's job in run `id` ("" when unknown).
|
|
41
|
-
*/
|
|
42
|
-
export function decideTreeSkip({ eventName, title, headTree, runs, jobConclusion }) {
|
|
43
|
-
if (eventName !== "pull_request") {
|
|
44
|
-
return { skip: false, reason: `${eventName || "unknown"} event — only a pull request skips` };
|
|
45
|
-
}
|
|
46
|
-
const marker = FORCE_MARKERS.find((m) => (title ?? "").includes(m));
|
|
47
|
-
if (marker) return { skip: false, reason: `${marker} in the title` };
|
|
48
|
-
if (!headTree) return { skip: false, reason: "no tree for HEAD" };
|
|
49
|
-
const matches = (runs ?? [])
|
|
50
|
-
.filter((r) => r?.tree === headTree && Number.isFinite(r?.id))
|
|
51
|
-
.sort((a, b) => (b.run_number ?? 0) - (a.run_number ?? 0))
|
|
52
|
-
.slice(0, MAX_JOB_LOOKUPS);
|
|
53
|
-
for (const run of matches) {
|
|
54
|
-
const conclusion = jobConclusion(run.id);
|
|
55
|
-
if (conclusion === "success") {
|
|
56
|
-
return { skip: true, reason: `tree ${headTree} passed in push run ${run.id}` };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
skip: false,
|
|
61
|
-
reason: matches.length
|
|
62
|
-
? `tree ${headTree} matched ${matches.length} push run(s), none with this job green`
|
|
63
|
-
: `no green push run in ${LOOKBACK_DAYS} days has tree ${headTree}`,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Runs `gh`; never throws. `ok` false carries the reason (spawn error or first stderr line). */
|
|
68
|
-
function gh(args) {
|
|
69
|
-
const { status, stdout, stderr, error } = spawnSync("gh", args, {
|
|
70
|
-
encoding: "utf8",
|
|
71
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
72
|
-
});
|
|
73
|
-
if (error || status !== 0) {
|
|
74
|
-
return { ok: false, out: "", reason: error ? error.message : String(stderr).split("\n")[0] };
|
|
75
|
-
}
|
|
76
|
-
return { ok: true, out: stdout, reason: "" };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function greenPushRuns(repo, now = new Date()) {
|
|
80
|
-
const since = new Date(now.getTime() - LOOKBACK_DAYS * 86_400_000).toISOString().slice(0, 10);
|
|
81
|
-
const path =
|
|
82
|
-
`repos/${repo}/actions/workflows/${WORKFLOW_FILE}/runs` +
|
|
83
|
-
`?event=push&status=success&created=${encodeURIComponent(`>=${since}`)}&per_page=100`;
|
|
84
|
-
const res = gh([
|
|
85
|
-
"api",
|
|
86
|
-
path,
|
|
87
|
-
"--jq",
|
|
88
|
-
"[.workflow_runs[] | {id, run_number, tree: .head_commit.tree_id}]",
|
|
89
|
-
]);
|
|
90
|
-
// No run list is not fatal: main() turns this into skip=false, which runs the suite.
|
|
91
|
-
if (!res.ok) throw new Error(`could not list ${WORKFLOW_FILE} runs (${res.reason})`);
|
|
92
|
-
return JSON.parse(res.out || "[]");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function jobConclusionIn(repo, job) {
|
|
96
|
-
return (runId) => {
|
|
97
|
-
const res = gh([
|
|
98
|
-
"api",
|
|
99
|
-
`repos/${repo}/actions/runs/${runId}/jobs?per_page=100`,
|
|
100
|
-
"--jq",
|
|
101
|
-
`[.jobs[] | select(.name == ${JSON.stringify(job)}) | .conclusion] | first // ""`,
|
|
102
|
-
]);
|
|
103
|
-
// An unreadable job list proves nothing about this lane, so the run does not count.
|
|
104
|
-
if (!res.ok) {
|
|
105
|
-
console.error(`[check-tree-cache] could not read jobs of run ${runId} (${res.reason})`);
|
|
106
|
-
return "";
|
|
107
|
-
}
|
|
108
|
-
return res.out.trim();
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function headTree() {
|
|
113
|
-
const { status, stdout } = spawnSync("git", ["rev-parse", "HEAD^{tree}"], {
|
|
114
|
-
encoding: "utf8",
|
|
115
|
-
stdio: ["ignore", "pipe", "ignore"],
|
|
116
|
-
});
|
|
117
|
-
return status === 0 ? stdout.trim() : "";
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export function main(env) {
|
|
121
|
-
let result;
|
|
122
|
-
try {
|
|
123
|
-
const isPr = env.EVENT_NAME === "pull_request";
|
|
124
|
-
result = decideTreeSkip({
|
|
125
|
-
eventName: env.EVENT_NAME,
|
|
126
|
-
title: env.PR_TITLE,
|
|
127
|
-
headTree: isPr ? headTree() : "",
|
|
128
|
-
runs: isPr ? greenPushRuns(env.REPO) : [],
|
|
129
|
-
jobConclusion: jobConclusionIn(env.REPO, env.JOB),
|
|
130
|
-
});
|
|
131
|
-
} catch (err) {
|
|
132
|
-
result = { skip: false, reason: `lookup failed (${err.message}) — running the suite` };
|
|
133
|
-
}
|
|
134
|
-
console.error(`[check-tree-cache] skip=${result.skip} — ${result.reason}`);
|
|
135
|
-
process.stdout.write(`skip=${result.skip}\n`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) main(process.env);
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Example. Copy into scripts/ci/lanes/ and own it. bkit install does not write this file
|
|
3
|
-
// and does not overwrite a copy.
|
|
4
|
-
/**
|
|
5
|
-
* check-tree-cache.test.mjs — unit tests for the pull request tree cache.
|
|
6
|
-
*
|
|
7
|
-
* Pure Node, no runner: `node scripts/ci/lanes/check-tree-cache.test.mjs`.
|
|
8
|
-
* Exit: 0 = all tests passed, 1 = at least one test failed.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { spawnSync } from "node:child_process";
|
|
12
|
-
import fs from "node:fs";
|
|
13
|
-
import os from "node:os";
|
|
14
|
-
import path from "node:path";
|
|
15
|
-
import { fileURLToPath } from "node:url";
|
|
16
|
-
import { decideTreeSkip } from "./check-tree-cache.mjs";
|
|
17
|
-
|
|
18
|
-
const SCRIPT = fileURLToPath(new URL("./check-tree-cache.mjs", import.meta.url));
|
|
19
|
-
|
|
20
|
-
/** Run the script with fake `gh` / `git` binaries first on PATH. */
|
|
21
|
-
function runWithFakes({ gh, git, eventName = "pull_request", title = "feat: x" }) {
|
|
22
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "tree-cache-"));
|
|
23
|
-
try {
|
|
24
|
-
fs.writeFileSync(path.join(dir, "gh"), `#!/bin/sh\n${gh}\n`, { mode: 0o755 });
|
|
25
|
-
fs.writeFileSync(path.join(dir, "git"), `#!/bin/sh\n${git}\n`, { mode: 0o755 });
|
|
26
|
-
const r = spawnSync(process.execPath, [SCRIPT], {
|
|
27
|
-
encoding: "utf8",
|
|
28
|
-
env: {
|
|
29
|
-
...process.env,
|
|
30
|
-
PATH: `${dir}${path.delimiter}${process.env.PATH}`,
|
|
31
|
-
REPO: "o/r",
|
|
32
|
-
EVENT_NAME: eventName,
|
|
33
|
-
JOB: "bkit-tests-unit",
|
|
34
|
-
PR_TITLE: title,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
return { status: r.status, stdout: r.stdout.trim(), stderr: r.stderr };
|
|
38
|
-
} finally {
|
|
39
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let passed = 0;
|
|
44
|
-
let failed = 0;
|
|
45
|
-
|
|
46
|
-
function test(name, fn) {
|
|
47
|
-
try {
|
|
48
|
-
fn();
|
|
49
|
-
passed++;
|
|
50
|
-
console.log(` ok ${name}`);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
failed++;
|
|
53
|
-
console.log(` FAIL ${name} — ${err.message}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function assert(cond, message) {
|
|
58
|
-
if (!cond) throw new Error(message);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const TREE = "t".repeat(40);
|
|
62
|
-
const OTHER = "o".repeat(40);
|
|
63
|
-
const green = () => "success";
|
|
64
|
-
const base = { eventName: "pull_request", title: "feat: x", headTree: TREE };
|
|
65
|
-
|
|
66
|
-
test("a pull request whose files a green push run tested skips", () => {
|
|
67
|
-
const r = decideTreeSkip({
|
|
68
|
-
...base,
|
|
69
|
-
runs: [{ id: 7, run_number: 3, tree: TREE }],
|
|
70
|
-
jobConclusion: green,
|
|
71
|
-
});
|
|
72
|
-
assert(r.skip === true, r.reason);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("a push run never skips, even with the same files green", () => {
|
|
76
|
-
for (const eventName of ["push", "workflow_dispatch"]) {
|
|
77
|
-
const r = decideTreeSkip({
|
|
78
|
-
...base,
|
|
79
|
-
eventName,
|
|
80
|
-
runs: [{ id: 7, run_number: 3, tree: TREE }],
|
|
81
|
-
jobConclusion: green,
|
|
82
|
-
});
|
|
83
|
-
assert(r.skip === false, `${eventName}: ${r.reason}`);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test("[force build] / [force cache] in the title run the suite", () => {
|
|
88
|
-
for (const title of ["feat: x [force build]", "[force cache] feat: x"]) {
|
|
89
|
-
const r = decideTreeSkip({
|
|
90
|
-
...base,
|
|
91
|
-
title,
|
|
92
|
-
runs: [{ id: 7, run_number: 3, tree: TREE }],
|
|
93
|
-
jobConclusion: green,
|
|
94
|
-
});
|
|
95
|
-
assert(r.skip === false, `${title}: ${r.reason}`);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test("other files → no skip", () => {
|
|
100
|
-
const r = decideTreeSkip({
|
|
101
|
-
...base,
|
|
102
|
-
runs: [{ id: 7, run_number: 3, tree: OTHER }],
|
|
103
|
-
jobConclusion: green,
|
|
104
|
-
});
|
|
105
|
-
assert(r.skip === false, r.reason);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test("same files, but that run skipped this lane ([skip ci] / run_level=none) → no skip", () => {
|
|
109
|
-
const r = decideTreeSkip({
|
|
110
|
-
...base,
|
|
111
|
-
runs: [{ id: 7, run_number: 3, tree: TREE }],
|
|
112
|
-
jobConclusion: () => "skipped",
|
|
113
|
-
});
|
|
114
|
-
assert(r.skip === false, r.reason);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test("a later matching run with the lane green is found past one that skipped it", () => {
|
|
118
|
-
const seen = [];
|
|
119
|
-
const r = decideTreeSkip({
|
|
120
|
-
...base,
|
|
121
|
-
runs: [
|
|
122
|
-
{ id: 1, run_number: 1, tree: TREE },
|
|
123
|
-
{ id: 2, run_number: 2, tree: TREE },
|
|
124
|
-
],
|
|
125
|
-
jobConclusion: (id) => {
|
|
126
|
-
seen.push(id);
|
|
127
|
-
return id === 1 ? "success" : "skipped";
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
assert(r.skip === true, r.reason);
|
|
131
|
-
assert(seen.join(",") === "2,1", `newest first, got ${seen}`);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test("no tree for HEAD → no skip", () => {
|
|
135
|
-
const r = decideTreeSkip({
|
|
136
|
-
...base,
|
|
137
|
-
headTree: "",
|
|
138
|
-
runs: [{ id: 7, run_number: 3, tree: "" }],
|
|
139
|
-
jobConclusion: green,
|
|
140
|
-
});
|
|
141
|
-
assert(r.skip === false, r.reason);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const RUNS = `echo '[{"id":7,"run_number":3,"tree":"${TREE}"}]'`;
|
|
145
|
-
const GH_OK = `case "$2" in *jobs*) echo success ;; *) ${RUNS} ;; esac`;
|
|
146
|
-
|
|
147
|
-
test("end to end: matching green push run prints skip=true", () => {
|
|
148
|
-
const r = runWithFakes({ gh: GH_OK, git: `echo ${TREE}` });
|
|
149
|
-
assert(r.status === 0 && r.stdout === "skip=true", JSON.stringify(r));
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("end to end: a push event prints skip=false without calling gh", () => {
|
|
153
|
-
const r = runWithFakes({ gh: "exit 9", git: `echo ${TREE}`, eventName: "push" });
|
|
154
|
-
assert(r.status === 0 && r.stdout === "skip=false", JSON.stringify(r));
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test("a gh failure exits 0 with skip=false", () => {
|
|
158
|
-
const r = runWithFakes({ gh: "exit 4", git: `echo ${TREE}` });
|
|
159
|
-
assert(r.status === 0 && r.stdout === "skip=false", JSON.stringify(r));
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test("unparseable gh output exits 0 with skip=false", () => {
|
|
163
|
-
const r = runWithFakes({ gh: "echo 'not json'", git: `echo ${TREE}` });
|
|
164
|
-
assert(r.status === 0 && r.stdout === "skip=false", JSON.stringify(r));
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("a failed job lookup does not count the run: skip=false", () => {
|
|
168
|
-
const r = runWithFakes({
|
|
169
|
-
gh: `case "$2" in *jobs*) echo boom >&2; exit 1 ;; *) ${RUNS} ;; esac`,
|
|
170
|
-
git: `echo ${TREE}`,
|
|
171
|
-
});
|
|
172
|
-
assert(r.status === 0 && r.stdout === "skip=false", JSON.stringify(r));
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test("a git failure exits 0 with skip=false", () => {
|
|
176
|
-
const r = runWithFakes({ gh: GH_OK, git: "exit 128" });
|
|
177
|
-
assert(r.status === 0 && r.stdout === "skip=false", JSON.stringify(r));
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
console.log(`\n${passed} passed, ${failed} failed`);
|
|
181
|
-
process.exit(failed > 0 ? 1 : 0);
|