vigiles 41.1.0 → 41.2.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/action.yml +78 -2
- package/dist/cli-flag-check.js +11 -1
- package/dist/cli-main.js +82 -4
- package/dist/core/changed-base.d.ts +34 -0
- package/dist/core/changed-base.js +82 -0
- package/dist/core/config-schema.d.ts +9 -0
- package/dist/core/config-schema.js +7 -0
- package/dist/core/test-reach.d.ts +99 -0
- package/dist/core/test-reach.js +725 -0
- package/dist/core/test-selection.d.ts +86 -0
- package/dist/core/test-selection.js +176 -0
- package/dist/host/changed-files.io.d.ts +23 -0
- package/dist/host/changed-files.io.js +171 -0
- package/dist/vigilesrc.schema.json +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type Reach, type Unresolved } from "./test-reach.js";
|
|
2
|
+
/** Why one harness file was selected. */
|
|
3
|
+
export type SelectionReason = {
|
|
4
|
+
readonly kind: "self";
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: "run-all";
|
|
7
|
+
readonly trigger: string;
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "folder";
|
|
10
|
+
readonly changed: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "import";
|
|
13
|
+
readonly changed: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "reads";
|
|
16
|
+
readonly changed: string;
|
|
17
|
+
readonly call: string;
|
|
18
|
+
};
|
|
19
|
+
export interface SelectedFile {
|
|
20
|
+
readonly file: string;
|
|
21
|
+
readonly reason: SelectionReason;
|
|
22
|
+
}
|
|
23
|
+
export interface Selection {
|
|
24
|
+
readonly selected: readonly SelectedFile[];
|
|
25
|
+
readonly skipped: readonly string[];
|
|
26
|
+
/**
|
|
27
|
+
* Skipped files that make an effect call whose path could not be evaluated
|
|
28
|
+
* (a function parameter, a command read from a file), with the first such
|
|
29
|
+
* call. Not selected for it — measured, doing so ran most files on every
|
|
30
|
+
* change — but always NAMED, so the gap is in the output, not hidden.
|
|
31
|
+
*/
|
|
32
|
+
readonly unresolved: readonly {
|
|
33
|
+
readonly file: string;
|
|
34
|
+
readonly at: Unresolved;
|
|
35
|
+
}[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Files whose change can alter any harness's outcome, relative to the run's
|
|
39
|
+
* cwd. The CI workflow folder is added from {@link ChangedSince}, because it
|
|
40
|
+
* sits at the git root, which need not be the cwd.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DEFAULT_RUN_ALL_ON: readonly string[];
|
|
43
|
+
export interface SelectInput {
|
|
44
|
+
/** Harness files, POSIX, cwd-relative. */
|
|
45
|
+
readonly files: readonly string[];
|
|
46
|
+
/** Changed files, POSIX, cwd-relative. */
|
|
47
|
+
readonly changed: readonly string[];
|
|
48
|
+
/** Globs (cwd-relative) whose change selects every file. */
|
|
49
|
+
readonly runAllOn: readonly string[];
|
|
50
|
+
/** What a harness file reaches (`./test-reach.ts`); asked only when the cheaper rules missed. */
|
|
51
|
+
readonly reach: (file: string) => Reach;
|
|
52
|
+
}
|
|
53
|
+
/** Pure: decide which files run, and why. Order of `files` is kept. */
|
|
54
|
+
export declare function selectTests(input: SelectInput): Selection;
|
|
55
|
+
/** One line per selected file, then the tally — or the explicit zero line. */
|
|
56
|
+
export declare function formatSelection(sel: Selection, ref: string, since: ChangedSince): string;
|
|
57
|
+
/** A ref the user named, or why it cannot be used. */
|
|
58
|
+
export type ParsedRef = {
|
|
59
|
+
readonly kind: "ok";
|
|
60
|
+
readonly ref: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: "error";
|
|
63
|
+
readonly message: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Refuse an empty ref, and one starting with `-`: it reaches `git` as an
|
|
67
|
+
* argument, where it would be read as an OPTION.
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseChangedRef(raw: string): ParsedRef;
|
|
70
|
+
export interface ChangedSince {
|
|
71
|
+
/** Changed files, POSIX, relative to the cwd. */
|
|
72
|
+
readonly files: readonly string[];
|
|
73
|
+
/** The commit compared against. */
|
|
74
|
+
readonly base: string;
|
|
75
|
+
/** How `base` was found: the merge-base, or the ref itself in a shallow clone. */
|
|
76
|
+
readonly via: "merge-base" | "ref";
|
|
77
|
+
/** The CI workflow folder as a glob, relative to the cwd — a run-all trigger. */
|
|
78
|
+
readonly workflowsGlob: string;
|
|
79
|
+
}
|
|
80
|
+
export type ChangedResult = ({
|
|
81
|
+
readonly kind: "ok";
|
|
82
|
+
} & ChangedSince) | {
|
|
83
|
+
readonly kind: "error";
|
|
84
|
+
readonly message: string;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=test-selection.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_RUN_ALL_ON = void 0;
|
|
4
|
+
exports.selectTests = selectTests;
|
|
5
|
+
exports.formatSelection = formatSelection;
|
|
6
|
+
exports.parseChangedRef = parseChangedRef;
|
|
7
|
+
/**
|
|
8
|
+
* `vigiles test --changed=<ref>` — run only the harness files a change can reach.
|
|
9
|
+
*
|
|
10
|
+
* A harness file is SELECTED when any of these holds, checked in this order and
|
|
11
|
+
* reported with the first that matched:
|
|
12
|
+
*
|
|
13
|
+
* 1. `self` — the harness file itself changed.
|
|
14
|
+
* 2. `run-all` — a file every harness depends on changed (`package.json`, a
|
|
15
|
+
* lockfile, `.vigilesrc.json`, a CI workflow, or a glob listed in
|
|
16
|
+
* `.vigilesrc.json` `test.runAllOn`). Every file is selected.
|
|
17
|
+
* 3. `folder` — a changed file sits in the harness's own directory or below it.
|
|
18
|
+
* 4. `import` — a changed file is in the harness's static import closure
|
|
19
|
+
* (relative specifiers only, resolved, followed transitively;
|
|
20
|
+
* a build output read as its source — `./test-reach.ts`).
|
|
21
|
+
* 5. `reads` — a changed file is one an effect call in that closure runs,
|
|
22
|
+
* reads or copies, wherever it lives.
|
|
23
|
+
*
|
|
24
|
+
* 🔴 WHY THE FOLDER RULE, AND WHY IT COMES BEFORE IMPORTS. The common harness
|
|
25
|
+
* shape spawns the script it tests (`spawnSync("node", ["hook.mjs"])`) or reads
|
|
26
|
+
* a fixture beside it. Neither is an import, so an import-graph selector cannot
|
|
27
|
+
* see it: measured on Vitest 5.1 (`--changed`, `related`) and Jest 30.5
|
|
28
|
+
* (`--findRelatedTests`), editing a spawned script reported "no affected tests"
|
|
29
|
+
* and exited 0 — a green run that tested nothing. Build systems that get this
|
|
30
|
+
* right (Bazel `data`, Nx `inputs`, Pants `dependencies`) make the author
|
|
31
|
+
* DECLARE such inputs. Colocation is the declaration harness authors already
|
|
32
|
+
* write: the hook and its harness share a folder. So a harness owns its folder,
|
|
33
|
+
* and the import closure adds what lives elsewhere (a shared helper).
|
|
34
|
+
*
|
|
35
|
+
* What it does NOT see, said plainly: a file an effect call reaches through a
|
|
36
|
+
* path nothing is known about (a helper's parameter, a command read from a
|
|
37
|
+
* file). Selecting such harnesses on every change was measured on a consumer
|
|
38
|
+
* repository of 155 harnesses: 114 ran on an average narrowed change instead
|
|
39
|
+
* of 19, which is no selection at all. So they are not selected for it, and the
|
|
40
|
+
* output NAMES them (`Selection.unresolved`); `test.runAllOn` covers a known
|
|
41
|
+
* input, and the full run on the default branch runs every file.
|
|
42
|
+
*
|
|
43
|
+
* Paths here are POSIX and relative to the run's cwd; a path outside it starts
|
|
44
|
+
* with `../` and never matches a folder. Pure: the git diff and the file reads
|
|
45
|
+
* arrive through `src/host/changed-files.io.ts`.
|
|
46
|
+
*/
|
|
47
|
+
const node_path_1 = require("node:path");
|
|
48
|
+
const minimatch_1 = require("minimatch");
|
|
49
|
+
const test_reach_js_1 = require("./test-reach.js");
|
|
50
|
+
/**
|
|
51
|
+
* Files whose change can alter any harness's outcome, relative to the run's
|
|
52
|
+
* cwd. The CI workflow folder is added from {@link ChangedSince}, because it
|
|
53
|
+
* sits at the git root, which need not be the cwd.
|
|
54
|
+
*/
|
|
55
|
+
exports.DEFAULT_RUN_ALL_ON = [
|
|
56
|
+
"package.json",
|
|
57
|
+
"package-lock.json",
|
|
58
|
+
"npm-shrinkwrap.json",
|
|
59
|
+
"yarn.lock",
|
|
60
|
+
"pnpm-lock.yaml",
|
|
61
|
+
"bun.lock",
|
|
62
|
+
"bun.lockb",
|
|
63
|
+
".vigilesrc.json",
|
|
64
|
+
];
|
|
65
|
+
/** Pure: decide which files run, and why. Order of `files` is kept. */
|
|
66
|
+
function selectTests(input) {
|
|
67
|
+
const trigger = input.changed.find((c) => input.runAllOn.some((g) => (0, minimatch_1.minimatch)(c, g, { dot: true })));
|
|
68
|
+
if (trigger !== undefined)
|
|
69
|
+
return runAll(input.files, trigger);
|
|
70
|
+
const decided = input.files.map((file) => ({
|
|
71
|
+
file,
|
|
72
|
+
...decide(file, input),
|
|
73
|
+
}));
|
|
74
|
+
return {
|
|
75
|
+
selected: decided.flatMap(({ file, reason }) => reason === undefined ? [] : [{ file, reason }]),
|
|
76
|
+
skipped: decided.flatMap((d) => (d.reason ? [] : [d.file])),
|
|
77
|
+
unresolved: decided.flatMap(({ file, reason, unknown }) => reason === undefined && unknown !== undefined
|
|
78
|
+
? [{ file, at: unknown }]
|
|
79
|
+
: []),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function runAll(files, trigger) {
|
|
83
|
+
const reason = { kind: "run-all", trigger };
|
|
84
|
+
return {
|
|
85
|
+
selected: files.map((file) => ({ file, reason })),
|
|
86
|
+
skipped: [],
|
|
87
|
+
unresolved: [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Why `file` runs, or why not: the first unresolved effect call of a skipped
|
|
92
|
+
* file rides along, so its reach is computed once.
|
|
93
|
+
*/
|
|
94
|
+
function decide(file, input) {
|
|
95
|
+
if (input.changed.includes(file))
|
|
96
|
+
return { reason: { kind: "self" } };
|
|
97
|
+
const dir = (0, node_path_1.dirname)(file);
|
|
98
|
+
const inFolder = input.changed.find((c) => isUnder(c, dir));
|
|
99
|
+
if (inFolder !== undefined)
|
|
100
|
+
return { reason: { kind: "folder", changed: inFolder } };
|
|
101
|
+
const r = input.reach(file);
|
|
102
|
+
return { reason: reachReason(r, input.changed), unknown: r.unresolved[0] };
|
|
103
|
+
}
|
|
104
|
+
function reachReason(r, changed) {
|
|
105
|
+
const hit = changed
|
|
106
|
+
.map((c) => ({ changed: c, hit: (0, test_reach_js_1.reachMatch)(r, c) }))
|
|
107
|
+
.find((h) => h.hit !== undefined);
|
|
108
|
+
if (hit?.hit === undefined)
|
|
109
|
+
return undefined;
|
|
110
|
+
return hit.hit.kind === "reads"
|
|
111
|
+
? { kind: "reads", changed: hit.changed, call: hit.hit.call }
|
|
112
|
+
: { kind: "import", changed: hit.changed };
|
|
113
|
+
}
|
|
114
|
+
/** Is `path` in `dir` or below it? A `../` path is outside every folder. */
|
|
115
|
+
function isUnder(path, dir) {
|
|
116
|
+
if (path.startsWith("../"))
|
|
117
|
+
return false;
|
|
118
|
+
return dir === "." || path.startsWith(`${dir}/`);
|
|
119
|
+
}
|
|
120
|
+
/** One line per selected file, then the tally — or the explicit zero line. */
|
|
121
|
+
function formatSelection(sel, ref, since) {
|
|
122
|
+
const total = String(sel.selected.length + sel.skipped.length);
|
|
123
|
+
const how = since.via === "merge-base"
|
|
124
|
+
? `merge-base of ${ref} and HEAD`
|
|
125
|
+
: `${ref} itself — no merge-base in this clone`;
|
|
126
|
+
const head = `--changed=${ref}: ${String(since.files.length)} changed file(s) since ${since.base.slice(0, 12)} (${how}).`;
|
|
127
|
+
const gap = unresolvedLine(sel);
|
|
128
|
+
if (sel.selected.length === 0) {
|
|
129
|
+
return (`${head}\n0 of ${total} test file(s) selected: no changed file is a harness, ` +
|
|
130
|
+
`in a harness's folder, import closure or effect calls, or a run-all trigger.\n` +
|
|
131
|
+
`Nothing ran; ${String(sel.skipped.length)} skipped. Run without --changed to run them all.${gap}`);
|
|
132
|
+
}
|
|
133
|
+
const lines = sel.selected.map((s) => ` ▸ ${s.file} — ${describeReason(s.reason)}`);
|
|
134
|
+
return (`${head}\nSelected ${String(sel.selected.length)} of ${total} test file(s); ` +
|
|
135
|
+
`${String(sel.skipped.length)} skipped:\n${lines.join("\n")}${gap}`);
|
|
136
|
+
}
|
|
137
|
+
/** The skipped files whose effect calls could not be evaluated — said, never hidden. */
|
|
138
|
+
function unresolvedLine(sel) {
|
|
139
|
+
const first = sel.unresolved[0];
|
|
140
|
+
if (first === undefined)
|
|
141
|
+
return "";
|
|
142
|
+
const { call, file, line } = first.at;
|
|
143
|
+
return (`\n⚠ ${String(sel.unresolved.length)} skipped file(s) also make an effect call whose path ` +
|
|
144
|
+
`cannot be evaluated (first: ${first.file} — ${call}() at ${file}:${String(line)}). ` +
|
|
145
|
+
`A change they read that way is not seen; the full run (no --changed) covers them.`);
|
|
146
|
+
}
|
|
147
|
+
function describeReason(r) {
|
|
148
|
+
switch (r.kind) {
|
|
149
|
+
case "self":
|
|
150
|
+
return "self: the file changed";
|
|
151
|
+
case "run-all":
|
|
152
|
+
return `run-all: ${r.trigger} changed`;
|
|
153
|
+
case "folder":
|
|
154
|
+
return `folder: ${r.changed} changed`;
|
|
155
|
+
case "import":
|
|
156
|
+
return `import: ${r.changed} changed`;
|
|
157
|
+
case "reads":
|
|
158
|
+
return `reads: ${r.changed} changed (${r.call})`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Refuse an empty ref, and one starting with `-`: it reaches `git` as an
|
|
163
|
+
* argument, where it would be read as an OPTION.
|
|
164
|
+
*/
|
|
165
|
+
function parseChangedRef(raw) {
|
|
166
|
+
if (raw === "")
|
|
167
|
+
return { kind: "error", message: "--changed= needs a git ref" };
|
|
168
|
+
if (raw.startsWith("-")) {
|
|
169
|
+
return {
|
|
170
|
+
kind: "error",
|
|
171
|
+
message: `--changed=${raw}: a ref cannot start with "-"`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return { kind: "ok", ref: raw };
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=test-selection.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChangedResult } from "../core/test-selection.js";
|
|
2
|
+
import { type BaseDecision, type BaseFacts } from "../core/changed-base.js";
|
|
3
|
+
import { type SourceHost } from "../core/test-reach.js";
|
|
4
|
+
/** Reads for the import closure, from disk. */
|
|
5
|
+
export declare const nodeSourceHost: SourceHost;
|
|
6
|
+
/**
|
|
7
|
+
* Files changed between `ref`'s merge-base with HEAD and the WORKING TREE:
|
|
8
|
+
* committed, staged, unstaged, and untracked (not ignored). Renames count as
|
|
9
|
+
* both paths. With no merge-base (a shallow clone, such as a CI checkout of a
|
|
10
|
+
* pull request's merge commit), the ref itself is the base — for a merge commit
|
|
11
|
+
* that is exactly the pull request's change, and elsewhere it can only add
|
|
12
|
+
* files, never drop one. Paths come back relative to the REAL cwd.
|
|
13
|
+
*/
|
|
14
|
+
export declare function changedSince(cwd: string, ref: string): ChangedResult;
|
|
15
|
+
/** Where this run is: the CI provider and event, and the local default branch. */
|
|
16
|
+
export declare function readBaseFacts(cwd: string, env: Readonly<NodeJS.ProcessEnv>): BaseFacts;
|
|
17
|
+
/**
|
|
18
|
+
* Make a decided base present: a shallow CI checkout does not carry the pull
|
|
19
|
+
* request's base commit, so it is fetched from origin. A base that is still
|
|
20
|
+
* missing turns the decision into "everything runs", with the reason.
|
|
21
|
+
*/
|
|
22
|
+
export declare function ensureBase(cwd: string, d: BaseDecision): BaseDecision;
|
|
23
|
+
//# sourceMappingURL=changed-files.io.d.ts.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nodeSourceHost = void 0;
|
|
7
|
+
exports.changedSince = changedSince;
|
|
8
|
+
exports.readBaseFacts = readBaseFacts;
|
|
9
|
+
exports.ensureBase = ensureBase;
|
|
10
|
+
/**
|
|
11
|
+
* The machine side of `vigiles test --changed=<ref>`: what git says changed,
|
|
12
|
+
* and the file reads the import closure needs. The decision is pure and lives
|
|
13
|
+
* in `src/core/test-selection.ts`.
|
|
14
|
+
*/
|
|
15
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
+
const node_child_process_1 = require("node:child_process");
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const node_path_1 = require("node:path");
|
|
19
|
+
const changed_base_js_1 = require("../core/changed-base.js");
|
|
20
|
+
const test_reach_js_1 = require("../core/test-reach.js");
|
|
21
|
+
/** Reads for the import closure, from disk. */
|
|
22
|
+
exports.nodeSourceHost = {
|
|
23
|
+
read: (path) => {
|
|
24
|
+
try {
|
|
25
|
+
return (0, node_fs_1.readFileSync)(path, "utf-8");
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
isFile: (path) => (0, node_fs_1.statSync)(path, { throwIfNoEntry: false })?.isFile() === true,
|
|
32
|
+
realpath: (path) => {
|
|
33
|
+
try {
|
|
34
|
+
return (0, node_fs_1.realpathSync)(path);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return path;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
// tsc's own walk, so a tsconfig's `include`/`exclude` mean what tsc means.
|
|
41
|
+
readDirectory: (...args) => typescript_1.default.sys.readDirectory(...args),
|
|
42
|
+
};
|
|
43
|
+
function git(cwd, args) {
|
|
44
|
+
try {
|
|
45
|
+
return (0, node_child_process_1.execFileSync)("git", args, {
|
|
46
|
+
cwd,
|
|
47
|
+
encoding: "utf-8",
|
|
48
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** `ref` as a commit, its merge-base with HEAD when the clone has one. */
|
|
56
|
+
function baseOf(cwd, ref) {
|
|
57
|
+
const commit = git(cwd, [
|
|
58
|
+
"rev-parse",
|
|
59
|
+
"--verify",
|
|
60
|
+
"--quiet",
|
|
61
|
+
`${ref}^{commit}`,
|
|
62
|
+
])?.trim();
|
|
63
|
+
if (commit === undefined)
|
|
64
|
+
return undefined;
|
|
65
|
+
const mergeBase = git(cwd, ["merge-base", commit, "HEAD"])?.trim();
|
|
66
|
+
return mergeBase === undefined
|
|
67
|
+
? { base: commit, via: "ref" }
|
|
68
|
+
: { base: mergeBase, via: "merge-base" };
|
|
69
|
+
}
|
|
70
|
+
/** Root-relative paths: the diff to the working tree, plus untracked files. */
|
|
71
|
+
function changedPaths(root, base) {
|
|
72
|
+
const diff = git(root, ["diff", "--name-only", "--no-renames", "-z", base]);
|
|
73
|
+
if (diff === undefined)
|
|
74
|
+
return undefined;
|
|
75
|
+
const untracked = git(root, ["ls-files", "--others", "--exclude-standard", "-z"]) ?? "";
|
|
76
|
+
return [...new Set([...diff.split("\0"), ...untracked.split("\0")])].filter((p) => p !== "");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Files changed between `ref`'s merge-base with HEAD and the WORKING TREE:
|
|
80
|
+
* committed, staged, unstaged, and untracked (not ignored). Renames count as
|
|
81
|
+
* both paths. With no merge-base (a shallow clone, such as a CI checkout of a
|
|
82
|
+
* pull request's merge commit), the ref itself is the base — for a merge commit
|
|
83
|
+
* that is exactly the pull request's change, and elsewhere it can only add
|
|
84
|
+
* files, never drop one. Paths come back relative to the REAL cwd.
|
|
85
|
+
*/
|
|
86
|
+
function changedSince(cwd, ref) {
|
|
87
|
+
const root = git(cwd, ["rev-parse", "--show-toplevel"])?.trim();
|
|
88
|
+
if (root === undefined) {
|
|
89
|
+
return {
|
|
90
|
+
kind: "error",
|
|
91
|
+
message: `--changed=${ref}: ${cwd} is not inside a git repository`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const found = baseOf(cwd, ref);
|
|
95
|
+
if (found === undefined) {
|
|
96
|
+
const hint = `In a shallow clone, fetch it first (git fetch origin ${ref}).`;
|
|
97
|
+
return { kind: "error", message: `--changed=${ref}: unknown ref. ${hint}` };
|
|
98
|
+
}
|
|
99
|
+
const paths = changedPaths(root, found.base);
|
|
100
|
+
if (paths === undefined) {
|
|
101
|
+
return {
|
|
102
|
+
kind: "error",
|
|
103
|
+
message: `--changed=${ref}: git diff against ${found.base} failed`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const real = (0, node_fs_1.realpathSync)(cwd);
|
|
107
|
+
const rel = (p) => (0, test_reach_js_1.posixRelative)(real, (0, node_path_1.join)(root, p));
|
|
108
|
+
return {
|
|
109
|
+
kind: "ok",
|
|
110
|
+
...found,
|
|
111
|
+
files: paths.map(rel).sort(),
|
|
112
|
+
workflowsGlob: `${rel(".github/workflows")}/**`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// Bare `--changed`: the facts `decideBase` needs, and the fetch it may ask for
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
function readEvent(path) {
|
|
119
|
+
if (path === undefined)
|
|
120
|
+
return undefined;
|
|
121
|
+
try {
|
|
122
|
+
const payload = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
|
|
123
|
+
return payload;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function ciFacts(env) {
|
|
130
|
+
if (env["GITHUB_ACTIONS"] === "true") {
|
|
131
|
+
return {
|
|
132
|
+
provider: "github",
|
|
133
|
+
event: env["GITHUB_EVENT_NAME"],
|
|
134
|
+
prBase: (0, changed_base_js_1.prBaseFromEvent)(readEvent(env["GITHUB_EVENT_PATH"])),
|
|
135
|
+
baseRef: env["GITHUB_BASE_REF"],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const ci = env["CI"];
|
|
139
|
+
const onCi = ci !== undefined && ci !== "" && ci !== "false" && ci !== "0";
|
|
140
|
+
return onCi ? { provider: "other" } : { provider: "none" };
|
|
141
|
+
}
|
|
142
|
+
function hasCommit(cwd, ref) {
|
|
143
|
+
return (git(cwd, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`]) !==
|
|
144
|
+
undefined);
|
|
145
|
+
}
|
|
146
|
+
const DEFAULT_BRANCHES = ["origin/HEAD", "origin/main", "origin/master"];
|
|
147
|
+
/** Where this run is: the CI provider and event, and the local default branch. */
|
|
148
|
+
function readBaseFacts(cwd, env) {
|
|
149
|
+
return {
|
|
150
|
+
ci: ciFacts(env),
|
|
151
|
+
defaultBranch: DEFAULT_BRANCHES.find((b) => hasCommit(cwd, b)),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Make a decided base present: a shallow CI checkout does not carry the pull
|
|
156
|
+
* request's base commit, so it is fetched from origin. A base that is still
|
|
157
|
+
* missing turns the decision into "everything runs", with the reason.
|
|
158
|
+
*/
|
|
159
|
+
function ensureBase(cwd, d) {
|
|
160
|
+
if (d.kind === "all" || hasCommit(cwd, d.ref))
|
|
161
|
+
return d;
|
|
162
|
+
if (d.fetch !== undefined)
|
|
163
|
+
git(cwd, ["fetch", "--no-tags", "--depth=1", "origin", d.fetch]);
|
|
164
|
+
return hasCommit(cwd, d.ref)
|
|
165
|
+
? d
|
|
166
|
+
: {
|
|
167
|
+
kind: "all",
|
|
168
|
+
why: `${d.why}: not in this clone and could not be fetched, so every file runs`,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=changed-files.io.js.map
|
|
@@ -3270,6 +3270,25 @@
|
|
|
3270
3270
|
},
|
|
3271
3271
|
"additionalProperties": false
|
|
3272
3272
|
},
|
|
3273
|
+
"test": {
|
|
3274
|
+
"type": "object",
|
|
3275
|
+
"properties": {
|
|
3276
|
+
"runAllOn": {
|
|
3277
|
+
"anyOf": [
|
|
3278
|
+
{
|
|
3279
|
+
"type": "string"
|
|
3280
|
+
},
|
|
3281
|
+
{
|
|
3282
|
+
"type": "array",
|
|
3283
|
+
"items": {
|
|
3284
|
+
"type": "string"
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
]
|
|
3288
|
+
}
|
|
3289
|
+
},
|
|
3290
|
+
"additionalProperties": false
|
|
3291
|
+
},
|
|
3273
3292
|
"nudge": {
|
|
3274
3293
|
"type": "string",
|
|
3275
3294
|
"const": "dismissed"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vigiles",
|
|
3
|
-
"version": "41.
|
|
3
|
+
"version": "41.2.0",
|
|
4
4
|
"description": "Audit, test and measure the harness your AI agent runs on — grade your CLAUDE.md / AGENTS.md, skills, subagents and hooks, run them against a scripted model, and measure whether they actually fire.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|