@diffci.com/diffci 0.3.13 → 0.3.14
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-client/src/client/agent-selection.js +4 -1
- package/dist-client/src/client/cli.js +4 -49
- package/dist-client/src/client/command-batches.js +80 -0
- package/dist-client/src/client/failure-baseline.js +99 -0
- package/dist-client/src/client/observe.js +11 -3
- package/dist-client/src/client/pilot-packet.js +0 -31
- package/dist-client/src/client/verify-savings.js +12 -1
- package/dist-client/src/client/verify.js +53 -5
- package/dist-client/src/client/workflow-templates.js +80 -0
- package/node_modules/@diffci.com/core/README.md +13 -7
- package/node_modules/@diffci.com/core/dist/analyze.js +2 -1
- package/node_modules/@diffci.com/core/dist/analyze.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +9 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +122 -19
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/types.d.ts +9 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js +16 -3
- package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +99 -42
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/compiled-projects.d.ts +16 -0
- package/node_modules/@diffci.com/core/dist/repo/compiled-projects.js +101 -0
- package/node_modules/@diffci.com/core/dist/repo/compiled-projects.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.d.ts +68 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.js +278 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/graph.d.ts +4 -2
- package/node_modules/@diffci.com/core/dist/repo/graph.js +107 -31
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact-types.d.ts +7 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +32 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +241 -20
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/runner-universe.js +9 -3
- package/node_modules/@diffci.com/core/dist/repo/runner-universe.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/script-universe.d.ts +16 -0
- package/node_modules/@diffci.com/core/dist/repo/script-universe.js +173 -0
- package/node_modules/@diffci.com/core/dist/repo/script-universe.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.d.ts +12 -0
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +54 -7
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/types.d.ts +8 -0
- package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.d.ts +15 -0
- package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js +157 -0
- package/node_modules/@diffci.com/core/dist/repo/workflow-test-steps.js.map +1 -0
- package/node_modules/@diffci.com/core/package.json +5 -0
- package/node_modules/@diffci.com/core/src/analyze.ts +2 -1
- package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +1 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +106 -20
- package/node_modules/@diffci.com/core/src/git/types.ts +9 -0
- package/node_modules/@diffci.com/core/src/planner/test-command.ts +17 -3
- package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +120 -30
- package/node_modules/@diffci.com/core/src/repo/compiled-projects.ts +108 -0
- package/node_modules/@diffci.com/core/src/repo/file-references.ts +275 -0
- package/node_modules/@diffci.com/core/src/repo/graph.ts +104 -31
- package/node_modules/@diffci.com/core/src/repo/impact-types.ts +10 -0
- package/node_modules/@diffci.com/core/src/repo/impact.ts +243 -18
- package/node_modules/@diffci.com/core/src/repo/runner-universe.ts +6 -3
- package/node_modules/@diffci.com/core/src/repo/script-universe.ts +158 -0
- package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +62 -7
- package/node_modules/@diffci.com/core/src/repo/types.ts +5 -0
- package/node_modules/@diffci.com/core/src/repo/workflow-test-steps.ts +117 -0
- package/package.json +2 -2
|
@@ -28,6 +28,8 @@ import ts from "typescript";
|
|
|
28
28
|
export type TestFamily = "unit" | "snapshot" | "e2e" | "integration" | "benchmark";
|
|
29
29
|
|
|
30
30
|
export interface TestRunnerConfig {
|
|
31
|
+
/** A known unsupported declaration that makes even a nonempty test universe incomplete. */
|
|
32
|
+
discoveryError?: string;
|
|
31
33
|
/** Inline Vitest projects; undefined means no projects, null means ambiguous. */
|
|
32
34
|
projects?: { name: string; includes: string[]; runtimeSelectionSafe: boolean }[] | null;
|
|
33
35
|
runtimeSelectionUnsafe?: boolean;
|
|
@@ -61,6 +63,43 @@ export interface TestRunnerConfig {
|
|
|
61
63
|
authoritative: boolean;
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
/** Root-relative patterns cannot be interpreted as repository-relative patterns. Keep
|
|
67
|
+
* default roots supported, but require full validation for roots we do not resolve. */
|
|
68
|
+
function unsupportedRoot(source: string, runner: "vitest" | "jest"): string | undefined {
|
|
69
|
+
const key = runner === "jest" ? "rootDir" : "root";
|
|
70
|
+
const ast = ts.createSourceFile("config.ts", source, ts.ScriptTarget.Latest, true);
|
|
71
|
+
let unsupported = false;
|
|
72
|
+
const visit = (node: ts.Node): void => {
|
|
73
|
+
if (ts.isBinaryExpression(node) && node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment
|
|
74
|
+
&& node.operatorToken.kind <= ts.SyntaxKind.LastAssignment
|
|
75
|
+
&& (ts.isPropertyAccessExpression(node.left) && node.left.name.text === key
|
|
76
|
+
|| ts.isElementAccessExpression(node.left) && ts.isStringLiteral(node.left.argumentExpression) && node.left.argumentExpression.text === key)) unsupported = true;
|
|
77
|
+
if ((ts.isPropertyAssignment(node) || ts.isShorthandPropertyAssignment(node))
|
|
78
|
+
&& ((ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) && node.name.text === key
|
|
79
|
+
|| ts.isComputedPropertyName(node.name) && ts.isStringLiteral(node.name.expression) && node.name.expression.text === key)) {
|
|
80
|
+
const value = ts.isPropertyAssignment(node) ? node.initializer : undefined;
|
|
81
|
+
if (!value || !(ts.isStringLiteral(value) || ts.isNoSubstitutionTemplateLiteral(value))
|
|
82
|
+
|| ![".", "./", "./."].includes(value.text)) unsupported = true;
|
|
83
|
+
}
|
|
84
|
+
ts.forEachChild(node, visit);
|
|
85
|
+
};
|
|
86
|
+
visit(ast);
|
|
87
|
+
return unsupported ? `Unsupported ${runner} ${key}; root-relative test discovery requires full validation` : undefined;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface TestDiscoveryProfile {
|
|
91
|
+
testRunnerConfigs?: TestRunnerConfig[];
|
|
92
|
+
workspaceTestPackages?: { packageRoot: string; profile: TestDiscoveryProfile }[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Discovery blockers also apply to declared workspace suites and empty selections. */
|
|
96
|
+
export function testDiscoveryErrors(profile: TestDiscoveryProfile): string[] {
|
|
97
|
+
return [
|
|
98
|
+
...(profile.testRunnerConfigs ?? []).flatMap(config => config.discoveryError ? [`${config.file}: ${config.discoveryError}`] : []),
|
|
99
|
+
...(profile.workspaceTestPackages ?? []).flatMap(suite => testDiscoveryErrors(suite.profile).map(reason => `${suite.packageRoot}/${reason}`)),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
|
|
64
103
|
function runtimeIsolationUnsafe(source: string): boolean {
|
|
65
104
|
const ast = ts.createSourceFile("config.ts", source, ts.ScriptTarget.Latest, true);
|
|
66
105
|
let unsafe = false;
|
|
@@ -269,7 +308,9 @@ export function discoverTestRunnerConfigs(repoPath: string, scripts: Record<stri
|
|
|
269
308
|
const runner = m[1]!.toLowerCase() as "vitest" | "jest";
|
|
270
309
|
const isDefault = m[2] === undefined;
|
|
271
310
|
const extracted = extractTestPatterns(source);
|
|
311
|
+
const discoveryError = unsupportedRoot(source, runner);
|
|
272
312
|
configs.push({
|
|
313
|
+
...(discoveryError ? { discoveryError } : {}),
|
|
273
314
|
...(runner === "vitest" ? { projects: inlineProjects(source) } : {}),
|
|
274
315
|
...(runner === "vitest" && runtimeIsolationUnsafe(source) ? { runtimeSelectionUnsafe: true } : {}),
|
|
275
316
|
file: name,
|
|
@@ -282,10 +323,21 @@ export function discoverTestRunnerConfigs(repoPath: string, scripts: Record<stri
|
|
|
282
323
|
roots: extracted.roots,
|
|
283
324
|
declaresTests: extracted.declaresTests,
|
|
284
325
|
isDefault,
|
|
285
|
-
authoritative: extracted.declaresTests && extracted.complete && extracted.includes.length > 0,
|
|
326
|
+
authoritative: !discoveryError && extracted.declaresTests && extracted.complete && extracted.includes.length > 0,
|
|
286
327
|
});
|
|
287
328
|
}
|
|
288
329
|
|
|
330
|
+
// A bare runner config still has a real default suite. Until those defaults can be
|
|
331
|
+
// assigned per invocation, neither an explicit sibling nor a first matching config
|
|
332
|
+
// can safely replace it. Partial declarations have the same missing-suite risk.
|
|
333
|
+
if (configs.length > 1) {
|
|
334
|
+
for (const config of configs) {
|
|
335
|
+
if (!config.authoritative && !config.discoveryError) {
|
|
336
|
+
config.discoveryError = "Multiple runner configurations require completely understood explicit test includes; full validation required";
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
289
341
|
// THE REPLACEMENT RULE, and it is deliberately narrow.
|
|
290
342
|
//
|
|
291
343
|
// Only the DEFAULT config (`jest.config.ts`, `vitest.config.ts`) describes what the bare runner
|
|
@@ -306,9 +358,10 @@ export function discoverTestRunnerConfigs(repoPath: string, scripts: Record<stri
|
|
|
306
358
|
|
|
307
359
|
// Excludes, ignores and roots are NARROWING, so they are honoured only from configs whose
|
|
308
360
|
// declaration was fully understood - and only when the declaration is actually in force.
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
|
|
361
|
+
// A restriction belongs to one runner invocation, not to the union of all suites.
|
|
362
|
+
// With multiple configs, keep the conservative include union without global vetoes:
|
|
363
|
+
// a named suite may deliberately run files excluded by the default config.
|
|
364
|
+
const authoritative = replacedDefaults && configs.length === 1 ? defaults : [];
|
|
312
365
|
return {
|
|
313
366
|
configs,
|
|
314
367
|
patterns: Array.from(patterns),
|
|
@@ -422,8 +475,8 @@ export interface TestFileMatcherOptions {
|
|
|
422
475
|
roots?: readonly string[];
|
|
423
476
|
}
|
|
424
477
|
|
|
425
|
-
function compile(patterns: readonly string[]): RegExp[] {
|
|
426
|
-
return patterns.flatMap((p) => expandBraces(p.includes("/") ? p : `**/${p}`)).map(globToRegex);
|
|
478
|
+
function compile(patterns: readonly string[], widenBarePatterns = true): RegExp[] {
|
|
479
|
+
return patterns.flatMap((p) => expandBraces(!widenBarePatterns || p.includes("/") ? p : `**/${p}`)).map(globToRegex);
|
|
427
480
|
}
|
|
428
481
|
|
|
429
482
|
/** Builds a matcher over repo-relative posix paths. Patterns without a slash (bare filename globs)
|
|
@@ -433,7 +486,9 @@ export function createTestFileMatcher(
|
|
|
433
486
|
options: TestFileMatcherOptions = {},
|
|
434
487
|
): TestFileMatcher {
|
|
435
488
|
const regexes = compile(patterns);
|
|
436
|
-
|
|
489
|
+
// Widening an include is conservative, but widening an exclude can hide tests.
|
|
490
|
+
// In particular, `example.test.js` excludes only that root-relative file.
|
|
491
|
+
const excludes = compile(options.excludePatterns ?? [], false);
|
|
437
492
|
const authoritative = compile(options.authoritativePatterns ?? []);
|
|
438
493
|
const ignoreRegexes = options.ignoreRegexes ?? [];
|
|
439
494
|
const roots = options.roots ?? [];
|
|
@@ -46,6 +46,9 @@ export interface RepositoryProfile {
|
|
|
46
46
|
adapterBlockers?: string[];
|
|
47
47
|
goTestPackages?: Record<string, string>;
|
|
48
48
|
goTestEnvironment?: Record<string, string>;
|
|
49
|
+
/** Exact source/embed ownership reported by Go metadata, not generic graph membership.
|
|
50
|
+
* Absent (including older cached profiles) means changed paths require full validation. */
|
|
51
|
+
goDependencyPaths?: { sources: string[]; embeds: string[] };
|
|
49
52
|
/** Maven/JUnit test file to owning reactor module (repo-relative, "." for root). */
|
|
50
53
|
mavenTestModules?: Record<string, string>;
|
|
51
54
|
/** Nested modules excluded by an explicit root-module execution scope. Changes here force full CI. */
|
|
@@ -175,6 +178,8 @@ export interface UnresolvedDependency {
|
|
|
175
178
|
specifier: string;
|
|
176
179
|
reason: string;
|
|
177
180
|
dynamic: boolean;
|
|
181
|
+
/** The specifier is an expression, not a module name, so the target is unknown. */
|
|
182
|
+
computed?: boolean;
|
|
178
183
|
typeOnly: boolean;
|
|
179
184
|
}
|
|
180
185
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
/**
|
|
3
|
+
* Can this GitHub Actions workflow run the repository's tests? (2026-10-21.)
|
|
4
|
+
*
|
|
5
|
+
* WHY. Any change under `.github/workflows/` forced full validation: 48 of 132 verification receipts in one
|
|
6
|
+
* dogfood repository and 25 of 124 in the other. A workflow that runs tests defines the environment the suite
|
|
7
|
+
* runs in, so a change to it can affect every test and full validation is right. A workflow that only
|
|
8
|
+
* deploys, publishes, scans or labels cannot change a test outcome; tests observe it only by reading the
|
|
9
|
+
* file, which the reference resolver (src/repo/file-references.ts) handles like any other data file.
|
|
10
|
+
*
|
|
11
|
+
* THE QUESTION ANSWERED HERE IS ONE-SIDED. `true` means "may run tests" and is the answer whenever the
|
|
12
|
+
* file cannot be read with confidence: unparseable YAML, a reusable workflow, a local or unrecognised
|
|
13
|
+
* action, a test runner anywhere on a command line, an npm script whose closure reaches tests, or an
|
|
14
|
+
* interpreter executing a repository file (which may itself run tests). Only a workflow made entirely
|
|
15
|
+
* of recognised non-test steps answers `false`.
|
|
16
|
+
*/
|
|
17
|
+
import { parse } from "yaml";
|
|
18
|
+
import { testScriptClosure } from "./file-references.js";
|
|
19
|
+
|
|
20
|
+
/** Actions known not to execute repository tests. Anything else is assumed to. */
|
|
21
|
+
const NON_TEST_ACTIONS = [
|
|
22
|
+
"actions/checkout", "actions/setup-node", "actions/setup-go", "actions/setup-java", "actions/setup-python",
|
|
23
|
+
"actions/cache", "actions/upload-artifact", "actions/download-artifact", "actions/configure-pages",
|
|
24
|
+
"actions/upload-pages-artifact", "actions/deploy-pages", "actions/attest-build-provenance", "actions/labeler",
|
|
25
|
+
"actions/create-github-app-token", "actions/stale", "actions/first-interaction", "github/codeql-action/",
|
|
26
|
+
"pnpm/action-setup", "oven-sh/setup-bun", "softprops/action-gh-release", "peter-evans/create-pull-request",
|
|
27
|
+
"peter-evans/create-or-update-comment", "aws-actions/configure-aws-credentials", "google-github-actions/auth",
|
|
28
|
+
"google-github-actions/setup-gcloud", "azure/login", "dependabot/fetch-metadata", "cloudflare/wrangler-action",
|
|
29
|
+
];
|
|
30
|
+
const TEST_RUNNERS = /(?:^|[\s/"'`(;&|])(?:vitest|jest|mocha|ava|tap|playwright|cypress|karma|jasmine|pytest|tox|nox|phpunit|rspec|diffci|ctest)(?=$|[\s"'`);&|])|(?:node|tsx|bun|deno)(?:\s+--?[\w-]+(?:=\S+)?)*\s+--?test\b|\b(?:go|cargo|dotnet|swift|mix|zig)\s+test\b|\b(?:mvn|mvnw|gradle|gradlew|sbt|bazel|make|just)\b/;
|
|
31
|
+
const PACKAGE_SCRIPT = /\b(?:npm|pnpm|yarn|bun)\s+(?:(?:run|run-script|-w\s+\S+|--workspace[= ]\S+|--prefix[= ]\S+|--if-present|-r|--recursive|--silent|-s)\s+)*([\w:.-]+)/g;
|
|
32
|
+
const INTERPRETER_FILE = /\b(?:node|tsx|ts-node|bash|sh|zsh|pwsh|powershell|python3?|ruby|perl|deno\s+run|bun(?:\s+run)?|npx\s+(?:--\S+\s+)*tsx)\s+(?:-{1,2}[\w-]+(?:=\S+)?\s+)*\.{0,2}\/?[\w./-]+\.(?:m?[jt]s|c[jt]s|sh|ps1|py|rb|pl)\b|(?:^|[\s;&|])\.{1,2}\/[\w./-]+/;
|
|
33
|
+
const PACKAGE_MANAGER_BUILTINS = new Set(["ci", "install", "i", "add", "remove", "uninstall", "publish", "pack", "version", "view", "info", "whoami", "login", "config", "cache", "audit", "outdated", "ls", "list", "exec", "dlx", "init", "create", "link", "prune", "dedupe", "rebuild", "set-script", "pkg", "fund", "doctor", "help", "--version", "-v"]);
|
|
34
|
+
|
|
35
|
+
/** `strict` asks only whether the command runs a test runner or the test script; otherwise running any
|
|
36
|
+
* repository file also counts, because that file may run tests itself. */
|
|
37
|
+
function commandRunsTests(text: string, scripts: Readonly<Record<string, string>>, seen: Set<string> = new Set(), strict = false): boolean {
|
|
38
|
+
if (TEST_RUNNERS.test(text) || (!strict && INTERPRETER_FILE.test(text))) return true;
|
|
39
|
+
for (const match of text.matchAll(PACKAGE_SCRIPT)) {
|
|
40
|
+
const name = match[1] ?? "";
|
|
41
|
+
if (!name || seen.has(name) || PACKAGE_MANAGER_BUILTINS.has(name)) continue;
|
|
42
|
+
if (name === "test" || name === "t" || name.startsWith("test:")) return true;
|
|
43
|
+
if (typeof scripts[name] !== "string") return true;
|
|
44
|
+
seen.add(name);
|
|
45
|
+
if (commandRunsTests(scripts[name] ?? "", scripts, seen, strict)) return true;
|
|
46
|
+
for (const hook of [`pre${name}`, `post${name}`]) if (typeof scripts[hook] === "string" && commandRunsTests(scripts[hook] ?? "", scripts, seen, strict)) return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Can something a workflow names reach the test suite through that workflow? (2026-10-21.)
|
|
53
|
+
*
|
|
54
|
+
* A workflow step that names a file can only influence test results by preparing what a LATER step in
|
|
55
|
+
* the same job runs tests against. A check script run as its own CI step is required CI, which stays
|
|
56
|
+
* authoritative, not part of the suite DiffCI selects from. One dogfood repository's deploy workflow runs two such
|
|
57
|
+
* checks, and counting them blocked every site HTML change in its replayed history.
|
|
58
|
+
*
|
|
59
|
+
* So the answer is true when a job step matching `names` is, or precedes, a step that runs the test
|
|
60
|
+
* command or a test runner, or an action not known to be test-free; when a reusable-workflow job or
|
|
61
|
+
* job-level configuration names it in a job that runs tests; and whenever the YAML cannot be read.
|
|
62
|
+
*/
|
|
63
|
+
export function workflowFeedsTests(workflowText: string, names: RegExp, scripts: Readonly<Record<string, string>> = {}): boolean {
|
|
64
|
+
let document: unknown;
|
|
65
|
+
try { document = parse(workflowText); } catch { return true; }
|
|
66
|
+
if (!document || typeof document !== "object") return true;
|
|
67
|
+
const jobs = (document as { jobs?: unknown }).jobs;
|
|
68
|
+
if (!jobs || typeof jobs !== "object") return names.test(workflowText);
|
|
69
|
+
const testStep = (step: unknown): boolean => {
|
|
70
|
+
if (!step || typeof step !== "object") return true;
|
|
71
|
+
const { uses, run } = step as { uses?: unknown; run?: unknown };
|
|
72
|
+
if (typeof uses === "string") {
|
|
73
|
+
const action = uses.split("@")[0]!.toLowerCase();
|
|
74
|
+
if (!NON_TEST_ACTIONS.some((known) => known.endsWith("/") ? action.startsWith(known) : action === known)) return true;
|
|
75
|
+
} else if (uses !== undefined) return true;
|
|
76
|
+
if (run !== undefined && typeof run !== "string") return true;
|
|
77
|
+
return typeof run === "string" && commandRunsTests(run, scripts, new Set(), true);
|
|
78
|
+
};
|
|
79
|
+
for (const job of Object.values(jobs as Record<string, unknown>)) {
|
|
80
|
+
if (!job || typeof job !== "object") return true;
|
|
81
|
+
const { steps, uses, ...configuration } = job as { steps?: unknown; uses?: unknown };
|
|
82
|
+
if (uses !== undefined) { if (names.test(JSON.stringify(job))) return true; continue; }
|
|
83
|
+
if (!Array.isArray(steps)) return true;
|
|
84
|
+
const firstNaming = steps.findIndex((step) => names.test(JSON.stringify(step)));
|
|
85
|
+
const jobRunsTests = steps.some(testStep);
|
|
86
|
+
if (jobRunsTests && names.test(JSON.stringify(configuration))) return true;
|
|
87
|
+
if (firstNaming !== -1 && steps.slice(firstNaming).some(testStep)) return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** True unless every job in `workflowText` is made of recognised non-test steps. */
|
|
93
|
+
export function workflowMayRunTests(workflowText: string | undefined, scripts: Readonly<Record<string, string>> = {}): boolean {
|
|
94
|
+
if (workflowText === undefined) return true;
|
|
95
|
+
let document: unknown;
|
|
96
|
+
try { document = parse(workflowText); } catch { return true; }
|
|
97
|
+
if (!document || typeof document !== "object") return true;
|
|
98
|
+
const jobs = (document as { jobs?: unknown }).jobs;
|
|
99
|
+
if (!jobs || typeof jobs !== "object") return true;
|
|
100
|
+
for (const job of Object.values(jobs as Record<string, unknown>)) {
|
|
101
|
+
if (!job || typeof job !== "object") return true;
|
|
102
|
+
const record = job as { uses?: unknown; steps?: unknown; container?: unknown; services?: unknown };
|
|
103
|
+
if (record.uses !== undefined) return true;
|
|
104
|
+
if (!Array.isArray(record.steps)) return true;
|
|
105
|
+
for (const step of record.steps) {
|
|
106
|
+
if (!step || typeof step !== "object") return true;
|
|
107
|
+
const { uses, run } = step as { uses?: unknown; run?: unknown };
|
|
108
|
+
if (typeof uses === "string") {
|
|
109
|
+
const action = uses.split("@")[0]!.toLowerCase();
|
|
110
|
+
if (!NON_TEST_ACTIONS.some((known) => known.endsWith("/") ? action.startsWith(known) : action === known)) return true;
|
|
111
|
+
} else if (uses !== undefined) return true;
|
|
112
|
+
if (typeof run === "string" && commandRunsTests(run, scripts)) return true;
|
|
113
|
+
if (run !== undefined && typeof run !== "string") return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffci.com/diffci",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "Fail-closed, change-aware verification for AI coding agents with conservative affected-test selection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"package:smoke": "node scripts/package-smoke.mjs"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@diffci.com/core": "git+https://github.com/DiffCI/core.git#
|
|
61
|
+
"@diffci.com/core": "git+https://github.com/DiffCI/core.git#e7ffdaf103800e71d74375afe4bc82604953bf19",
|
|
62
62
|
"yaml": "^2.9.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|