@diffci.com/diffci 0.3.48 → 0.3.49
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/node_modules/@diffci.com/core/README.md +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 +2 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +3 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/planner/rust-command.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/planner/rust-command.js +92 -0
- package/node_modules/@diffci.com/core/dist/planner/rust-command.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js +3 -0
- package/node_modules/@diffci.com/core/dist/planner/test-command.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/index.js +5 -3
- package/node_modules/@diffci.com/core/dist/repo/adapters/index.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.d.ts +3 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js +97 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust-invocation.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.d.ts +51 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js +528 -16
- package/node_modules/@diffci.com/core/dist/repo/adapters/rust.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.d.ts +11 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/types.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +31 -5
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js +45 -2
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.d.ts +11 -0
- package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.js +181 -0
- package/node_modules/@diffci.com/core/dist/repo/runner-setup-files.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.d.ts +1 -0
- package/node_modules/@diffci.com/core/dist/repo/test-discovery.js +4 -3
- 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 +13 -0
- package/node_modules/@diffci.com/core/package.json +1 -0
- package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +2 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +3 -1
- package/node_modules/@diffci.com/core/src/planner/rust-command.ts +89 -0
- package/node_modules/@diffci.com/core/src/planner/test-command.ts +2 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/index.ts +5 -3
- package/node_modules/@diffci.com/core/src/repo/adapters/rust-invocation.ts +87 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/rust.ts +447 -16
- package/node_modules/@diffci.com/core/src/repo/adapters/types.ts +5 -0
- package/node_modules/@diffci.com/core/src/repo/graph.ts +29 -5
- package/node_modules/@diffci.com/core/src/repo/impact.ts +43 -2
- package/node_modules/@diffci.com/core/src/repo/runner-setup-files.ts +164 -0
- package/node_modules/@diffci.com/core/src/repo/test-discovery.ts +5 -3
- package/node_modules/@diffci.com/core/src/repo/types.ts +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
function record(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
const plain = (value) => typeof value === "string" && value.trim() === "cargo test";
|
|
8
|
+
/** Steps that install a toolchain, restore caches or check out the code. They choose which compiler
|
|
9
|
+
* runs, the same for the selected and the full command, but not which tests run or with what flags. */
|
|
10
|
+
const SETUP_ACTION = /^(?:actions\/checkout|actions\/cache(?:\/restore)?|actions\/upload-artifact|Swatinem\/rust-cache|dtolnay\/rust-toolchain|actions-rust-lang\/setup-rust-toolchain|actions-rs\/toolchain)@[A-Za-z0-9._/-]+$/;
|
|
11
|
+
/** Other Cargo and rustup commands that build, lint, format or install, but run no tests. One command
|
|
12
|
+
* per step: chaining, substitution or redirection could hide another invocation. */
|
|
13
|
+
const NON_TEST_COMMAND = /^(?:cargo (?:build|check|clippy|fmt|doc)|rustup (?:component|target|toolchain|default|show|update))(?: [A-Za-z0-9_.,:=@+/-]+)*$/;
|
|
14
|
+
/** Environment that changes output or retries, never what is compiled or tested. */
|
|
15
|
+
const NEUTRAL_ENV = new Set(["CARGO_TERM_COLOR", "CARGO_INCREMENTAL", "CARGO_NET_RETRY", "CARGO_NET_GIT_FETCH_WITH_CLI",
|
|
16
|
+
"CARGO_REGISTRIES_CRATES_IO_PROTOCOL", "RUST_BACKTRACE", "RUSTUP_MAX_RETRIES", "CI"]);
|
|
17
|
+
const neutralEnv = (value) => value === undefined || record(value)
|
|
18
|
+
&& Object.entries(value).every(([key, setting]) => NEUTRAL_ENV.has(key) && ["string", "number", "boolean"].includes(typeof setting) && !String(setting).includes("${{"));
|
|
19
|
+
/** Workflow and job keys with no effect on how a step's command runs. */
|
|
20
|
+
const WORKFLOW_KEYS = new Set(["name", "run-name", "on", "true", "permissions", "concurrency", "env", "jobs"]);
|
|
21
|
+
const JOB_KEYS = new Set(["name", "runs-on", "permissions", "concurrency", "timeout-minutes", "needs", "strategy", "env", "steps"]);
|
|
22
|
+
const SETUP_STEP_KEYS = new Set(["name", "id", "uses", "with", "if", "env", "timeout-minutes", "continue-on-error"]);
|
|
23
|
+
const TEST_STEP_KEYS = new Set(["name", "id", "run", "env", "timeout-minutes"]);
|
|
24
|
+
/** Evidence for the one invocation whose flags and execution context we can reproduce.
|
|
25
|
+
* Do not turn a Cargo manifest, a wrapper or a feature-specific CI run into plain cargo test. */
|
|
26
|
+
export function rustTestInvocation(repoPath, files) {
|
|
27
|
+
let found = false;
|
|
28
|
+
if (files.includes("package.json")) {
|
|
29
|
+
try {
|
|
30
|
+
const manifest = JSON.parse(readFileSync(join(repoPath, "package.json"), "utf8"));
|
|
31
|
+
if (!record(manifest))
|
|
32
|
+
return undefined;
|
|
33
|
+
if ("scripts" in manifest) {
|
|
34
|
+
if (!record(manifest.scripts))
|
|
35
|
+
return undefined;
|
|
36
|
+
// A plain command under an unrelated script name is not evidence that the actual
|
|
37
|
+
// test entrypoint has the same semantics. Unknown scripts may wrap additional suites.
|
|
38
|
+
if (!plain(manifest.scripts.test) || Object.values(manifest.scripts).some(script => !plain(script)))
|
|
39
|
+
return undefined;
|
|
40
|
+
if (Object.keys(manifest.scripts).some(name => /^(?:pre|post)/.test(name)))
|
|
41
|
+
return undefined;
|
|
42
|
+
found = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
for (const path of files.filter(path => /^\.github\/workflows\/[^/]+\.ya?ml$/.test(path))) {
|
|
50
|
+
try {
|
|
51
|
+
const workflow = parse(readFileSync(join(repoPath, path), "utf8"));
|
|
52
|
+
if (!record(workflow) || !record(workflow.jobs) || Object.keys(workflow).some(key => !WORKFLOW_KEYS.has(key)) || !neutralEnv(workflow.env))
|
|
53
|
+
return undefined;
|
|
54
|
+
for (const job of Object.values(workflow.jobs)) {
|
|
55
|
+
// A reusable workflow, container, service, default shell or working directory, or a
|
|
56
|
+
// conditional job may run another suite or change the context; we do not infer it.
|
|
57
|
+
if (!record(job) || !Array.isArray(job.steps) || Object.keys(job).some(key => !JOB_KEYS.has(key)) || !neutralEnv(job.env))
|
|
58
|
+
return undefined;
|
|
59
|
+
// A matrix may vary the runner or toolchain, which the selected and the full command share,
|
|
60
|
+
// but not the test command: that must stay literally `cargo test` below.
|
|
61
|
+
if (job.strategy !== undefined && (!record(job.strategy) || Object.keys(job.strategy).some(key => !["matrix", "fail-fast", "max-parallel"].includes(key))))
|
|
62
|
+
return undefined;
|
|
63
|
+
for (const step of job.steps) {
|
|
64
|
+
if (!record(step))
|
|
65
|
+
return undefined;
|
|
66
|
+
if ("run" in step) {
|
|
67
|
+
if (plain(step.run)) {
|
|
68
|
+
// The test step itself runs unconditionally, in the checkout root, with the default shell.
|
|
69
|
+
if (Object.keys(step).some(key => !TEST_STEP_KEYS.has(key)) || !neutralEnv(step.env))
|
|
70
|
+
return undefined;
|
|
71
|
+
found = true;
|
|
72
|
+
}
|
|
73
|
+
else if (typeof step.run !== "string" || !NON_TEST_COMMAND.test(step.run.trim())
|
|
74
|
+
|| Object.keys(step).some(key => !["name", "id", "run", "env", "if", "timeout-minutes", "continue-on-error"].includes(key)) || !neutralEnv(step.env)) {
|
|
75
|
+
// Wrappers, nextest, cargo make, just, other `cargo test` flags and unknown scripts are
|
|
76
|
+
// not reproduced, before or after the test and in any job.
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (typeof step.uses !== "string" || !SETUP_ACTION.test(step.uses)
|
|
81
|
+
|| Object.keys(step).some(key => !SETUP_STEP_KEYS.has(key)) || !neutralEnv(step.env)
|
|
82
|
+
// Checking out another repository, ref or directory changes which code `cargo test` sees.
|
|
83
|
+
|| step.uses.startsWith("actions/checkout@") && step.with !== undefined
|
|
84
|
+
&& (!record(step.with) || Object.keys(step.with).some(key => !["fetch-depth", "persist-credentials", "lfs", "submodules", "clean", "show-progress"].includes(key)))) {
|
|
85
|
+
// Unknown and local actions can replace cargo or persist environment for later steps.
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return found ? "cargo test" : undefined;
|
|
96
|
+
}
|
|
97
|
+
//# sourceM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AAC;QAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1C,CAAC"}
|
|
@@ -5,19 +5,69 @@ export interface CargoTarget {
|
|
|
5
5
|
src_path: string;
|
|
6
6
|
test: boolean;
|
|
7
7
|
doctest: boolean;
|
|
8
|
+
"required-features"?: string[];
|
|
8
9
|
}
|
|
9
10
|
export interface CargoPackage {
|
|
10
11
|
id: string;
|
|
11
12
|
name: string;
|
|
12
13
|
manifest_path: string;
|
|
13
14
|
targets: CargoTarget[];
|
|
15
|
+
source?: string | null;
|
|
16
|
+
dependencies?: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
features: string[];
|
|
19
|
+
uses_default_features: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
features?: Record<string, string[]>;
|
|
14
22
|
}
|
|
15
23
|
export interface CargoMetadata {
|
|
16
24
|
packages: CargoPackage[];
|
|
17
25
|
workspace_members: string[];
|
|
26
|
+
/** The members plain `cargo test` at the root builds and tests (root package or `default-members`). */
|
|
27
|
+
workspace_default_members?: string[];
|
|
18
28
|
workspace_root: string;
|
|
29
|
+
resolve?: {
|
|
30
|
+
nodes: Array<{
|
|
31
|
+
id: string;
|
|
32
|
+
dependencies: string[];
|
|
33
|
+
}>;
|
|
34
|
+
} | null;
|
|
19
35
|
}
|
|
36
|
+
/** Cargo's own feature resolution (`cargo tree`, format `{p}|{f}`) for the full invocation and for
|
|
37
|
+
* sets of tested crates. Cargo decides features, including resolver 2 and host/target splits. */
|
|
38
|
+
export interface CargoFeatureEvidence {
|
|
39
|
+
workspace: string;
|
|
40
|
+
units: Array<{
|
|
41
|
+
crates: string[];
|
|
42
|
+
tree: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/** Runs Cargo for each set of crates; undefined when any run fails. */
|
|
46
|
+
export type CargoFeatureResolver = (units: string[][]) => CargoFeatureEvidence | undefined;
|
|
47
|
+
/** Packages whose features change when a tested crate runs without the rest of the full invocation,
|
|
48
|
+
* and the sets of tested crates (each crate alone, and each crate with its dependents) that give a
|
|
49
|
+
* package exactly the full invocation's features. */
|
|
50
|
+
export interface RustFeatureCoverage {
|
|
51
|
+
deficits: Record<string, string[]>;
|
|
52
|
+
units: Array<{
|
|
53
|
+
crates: string[];
|
|
54
|
+
covers: string[];
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
export declare const CARGO_TREE_ARGS: string[];
|
|
58
|
+
/** Package (`name vX.Y.Z`) to the distinct feature sets Cargo resolved for it; undefined when the
|
|
59
|
+
* output is not a feature tree. A package built for both host and target can have two sets. */
|
|
60
|
+
export declare function parseCargoFeatureTree(output: string): Map<string, Set<string>> | undefined;
|
|
61
|
+
/** Whether any declaration can make a package's features depend on which crates are selected. With
|
|
62
|
+
* no feature requests, no disabled defaults and no forwarding, every package always gets its default
|
|
63
|
+
* features, whatever subset of the workspace Cargo builds. */
|
|
64
|
+
export declare function cargoFeaturesVary(metadata: CargoMetadata): boolean;
|
|
65
|
+
/** Feature resolution is monotonic in the crates Cargo is asked to build: a selected set gives every
|
|
66
|
+
* package at least the features of any subset and at most those of the full invocation. A package
|
|
67
|
+
* therefore keeps exactly the full invocation's features (per host/target build, since the sets
|
|
68
|
+
* compared are the same) whenever one unit inside the selection already resolves it that way. */
|
|
69
|
+
export declare function rustFeatureCoverage(evidence: CargoFeatureEvidence, members: readonly string[]): RustFeatureCoverage | undefined;
|
|
20
70
|
/** Metadata is external input: incomplete output is not an empty successful graph. */
|
|
21
71
|
export declare function parseCargoMetadata(output: string): CargoMetadata;
|
|
22
|
-
export declare function analyzeRustMetadata(context: AdapterContext, output: string): AdapterContribution;
|
|
72
|
+
export declare function analyzeRustMetadata(context: AdapterContext, output: string, resolveFeatures?: CargoFeatureResolver): AdapterContribution;
|
|
23
73
|
export declare const rustAdapter: RepositoryAdapter;
|