@smoothbricks/nx-plugin 0.4.1 → 0.4.2
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/README.md +80 -20
- package/dist/bin/smoo-nx-cargo-hash.d.ts +3 -0
- package/dist/bin/smoo-nx-cargo-hash.d.ts.map +1 -0
- package/dist/bin/smoo-nx-cargo-hash.js +16 -0
- package/dist/cargo-source-hash.d.ts +12 -0
- package/dist/cargo-source-hash.d.ts.map +1 -0
- package/dist/cargo-source-hash.js +208 -0
- package/dist/cargo-workspace.d.ts +22 -20
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +268 -58
- package/dist/cross-check-policy.d.ts +5 -10
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +7 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +331 -187
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +54 -0
- package/package.json +9 -3
- package/src/bin/smoo-nx-cargo-hash.ts +18 -0
- package/src/cargo-source-hash.test.ts +51 -0
- package/src/cargo-source-hash.ts +138 -0
- package/src/cargo-workspace.test.ts +236 -90
- package/src/cargo-workspace.ts +337 -64
- package/src/cross-check-policy.test.ts +37 -7
- package/src/cross-check-policy.ts +9 -21
- package/src/ensure-built.test.ts +8 -3
- package/src/index.test.ts +334 -43
- package/src/index.ts +370 -220
- package/src/workspace-config-policy.test.ts +48 -0
- package/src/workspace-config-policy.ts +60 -0
package/dist/cargo-workspace.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { join, normalize, posix, relative, sep } from 'node:path';
|
|
3
|
+
import { dirname, isAbsolute, join, normalize, posix, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { readNxJson } from 'nx/src/config/nx-json.js';
|
|
4
5
|
import { parse as parseToml } from 'smol-toml';
|
|
5
6
|
export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
6
7
|
const workspaceTomlPath = join(absoluteProjectRoot, 'Cargo.toml');
|
|
@@ -8,7 +9,7 @@ export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
|
8
9
|
return [];
|
|
9
10
|
}
|
|
10
11
|
const parsed = parseToml(readFileSync(workspaceTomlPath, 'utf-8'));
|
|
11
|
-
if (!isRecord(parsed) || !isRecord(parsed.workspace)
|
|
12
|
+
if (!isRecord(parsed) || !isRecord(parsed.workspace)) {
|
|
12
13
|
return [];
|
|
13
14
|
}
|
|
14
15
|
const excludedDirs = new Set();
|
|
@@ -22,7 +23,10 @@ export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
const packageDirs = new Set();
|
|
25
|
-
|
|
26
|
+
if (isRecord(parsed.package))
|
|
27
|
+
packageDirs.add('.');
|
|
28
|
+
const members = Array.isArray(parsed.workspace.members) ? parsed.workspace.members : [];
|
|
29
|
+
for (const member of members) {
|
|
26
30
|
if (typeof member !== 'string' || member.length === 0) {
|
|
27
31
|
continue;
|
|
28
32
|
}
|
|
@@ -33,12 +37,14 @@ export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
const packages = [];
|
|
40
|
+
const workspacePathDeps = workspacePathDependencies(parsed, absoluteProjectRoot);
|
|
41
|
+
const external = new Map();
|
|
36
42
|
for (const memberDir of packageDirs) {
|
|
37
43
|
const crateTomlPath = join(absoluteProjectRoot, memberDir, 'Cargo.toml');
|
|
38
44
|
if (!existsSync(crateTomlPath)) {
|
|
39
45
|
continue;
|
|
40
46
|
}
|
|
41
|
-
const crateParsed = parseToml(readFileSync(crateTomlPath, 'utf-8'));
|
|
47
|
+
const crateParsed = memberDir === '.' ? parsed : parseToml(readFileSync(crateTomlPath, 'utf-8'));
|
|
42
48
|
if (!isRecord(crateParsed) || !isRecord(crateParsed.package) || typeof crateParsed.package.name !== 'string') {
|
|
43
49
|
continue;
|
|
44
50
|
}
|
|
@@ -47,6 +53,21 @@ export function listCargoWorkspacePackages(absoluteProjectRoot) {
|
|
|
47
53
|
dir: memberDir,
|
|
48
54
|
testShards: readTestShards(crateParsed.package, crateTomlPath),
|
|
49
55
|
});
|
|
56
|
+
// Cargo automatically includes in-workspace path dependencies as members,
|
|
57
|
+
// except explicitly excluded packages.
|
|
58
|
+
const dependencies = [];
|
|
59
|
+
enqueuePathDependencies(crateParsed, memberDir, workspacePathDeps, dependencies, external, absoluteProjectRoot, absoluteProjectRoot);
|
|
60
|
+
if (isRecord(crateParsed.target)) {
|
|
61
|
+
for (const target of Object.values(crateParsed.target)) {
|
|
62
|
+
if (isRecord(target)) {
|
|
63
|
+
enqueuePathDependencies(target, memberDir, workspacePathDeps, dependencies, external, absoluteProjectRoot, absoluteProjectRoot);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const dependency of dependencies) {
|
|
68
|
+
if (!isExcludedCargoMember(dependency, excludedDirs))
|
|
69
|
+
packageDirs.add(dependency);
|
|
70
|
+
}
|
|
50
71
|
}
|
|
51
72
|
packages.sort((left, right) => left.name.localeCompare(right.name));
|
|
52
73
|
return packages;
|
|
@@ -67,6 +88,8 @@ function isExcludedCargoMember(memberDir, excludedDirs) {
|
|
|
67
88
|
*/
|
|
68
89
|
function expandCargoMemberDirs(absoluteProjectRoot, member, requireGlobMatch = true) {
|
|
69
90
|
const normalized = member.split('\\').join('/').replace(/\/+$/, '');
|
|
91
|
+
if (normalized === '.')
|
|
92
|
+
return ['.'];
|
|
70
93
|
const segments = normalized.split('/');
|
|
71
94
|
if (normalized.length === 0 ||
|
|
72
95
|
normalized.startsWith('/') ||
|
|
@@ -138,65 +161,267 @@ export function attributeCargoWorkspacePackages(packages, projects) {
|
|
|
138
161
|
}
|
|
139
162
|
return attributed;
|
|
140
163
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
164
|
+
/**
|
|
165
|
+
* The named input a workspace must declare when a crate's path dependencies
|
|
166
|
+
* resolve outside the Nx workspace. Nx hashes filesets against the workspace
|
|
167
|
+
* file map only, so a glob pointing above the root — or an absolute path
|
|
168
|
+
* spliced under `{workspaceRoot}` — matches nothing and every cached verdict
|
|
169
|
+
* silently ignores the dependency. A runtime named input can hash any tree.
|
|
170
|
+
*/
|
|
171
|
+
export const EXTERNAL_RUST_CRATES_INPUT = 'externalRustCrates';
|
|
172
|
+
export async function cargoPackageTestInputs({ workspaceRoot, absoluteProjectRoot, memberDir, inputRoot = '{projectRoot}', }) {
|
|
173
|
+
const manifests = new Map();
|
|
174
|
+
const loadManifest = async (path) => {
|
|
175
|
+
const normalized = resolve(path);
|
|
176
|
+
const cached = manifests.get(normalized);
|
|
177
|
+
if (cached !== undefined)
|
|
178
|
+
return cached;
|
|
179
|
+
const parsed = parseToml(await readFile(normalized, 'utf-8'));
|
|
180
|
+
manifests.set(normalized, parsed);
|
|
181
|
+
return parsed;
|
|
182
|
+
};
|
|
183
|
+
const rootManifest = await loadManifest(join(absoluteProjectRoot, 'Cargo.toml'));
|
|
184
|
+
// The closure over in-tree path dependencies, not the direct edge set: a
|
|
185
|
+
// test binary links every crate beneath it, and the chained cargo-test
|
|
186
|
+
// targets order runs without contributing to each other's hash, so a
|
|
187
|
+
// dependency reachable only through another crate would otherwise change
|
|
188
|
+
// nothing in the target that links it.
|
|
189
|
+
const dirs = new Set();
|
|
190
|
+
const external = new Map();
|
|
191
|
+
const pending = [normalize(memberDir).split(sep).join('/')];
|
|
192
|
+
const declaredSources = new Set();
|
|
193
|
+
// Workspace patches/replacements can substitute local code for locked sources.
|
|
194
|
+
if (isRecord(rootManifest.patch)) {
|
|
195
|
+
for (const replacements of Object.values(rootManifest.patch)) {
|
|
196
|
+
enqueuePathDependencies({ dependencies: replacements }, '.', new Map(), pending, external, absoluteProjectRoot, workspaceRoot);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (isRecord(rootManifest.replace)) {
|
|
200
|
+
enqueuePathDependencies({ dependencies: rootManifest.replace }, '.', new Map(), pending, external, absoluteProjectRoot, workspaceRoot);
|
|
201
|
+
}
|
|
202
|
+
while (pending.length > 0) {
|
|
203
|
+
const dir = pending.pop();
|
|
204
|
+
if (dir === undefined || dirs.has(dir)) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
dirs.add(dir);
|
|
208
|
+
const crateTomlPath = join(absoluteProjectRoot, dir, 'Cargo.toml');
|
|
209
|
+
if (!existsSync(crateTomlPath)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const crateParsed = await loadManifest(crateTomlPath);
|
|
213
|
+
if (!isRecord(crateParsed)) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
let owner = resolve(absoluteProjectRoot, dir);
|
|
217
|
+
if (isRecord(crateParsed.package) && typeof crateParsed.package.workspace === 'string') {
|
|
218
|
+
owner = resolve(owner, crateParsed.package.workspace);
|
|
219
|
+
if (isOutsideRoot(relative(workspaceRoot, owner))) {
|
|
220
|
+
external.set(`${dir} workspace`, owner);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
let workspacePathDeps = new Map();
|
|
224
|
+
while (!isOutsideRoot(relative(workspaceRoot, owner))) {
|
|
225
|
+
const manifestPath = join(owner, 'Cargo.toml');
|
|
226
|
+
if (existsSync(manifestPath)) {
|
|
227
|
+
const manifest = await loadManifest(manifestPath);
|
|
228
|
+
if (isRecord(manifest.workspace)) {
|
|
229
|
+
workspacePathDeps = workspacePathDependencies(manifest, owner);
|
|
230
|
+
declaredSources.add(manifestPath);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
150
233
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
234
|
+
const parent = dirname(owner);
|
|
235
|
+
if (parent === owner)
|
|
236
|
+
break;
|
|
237
|
+
owner = parent;
|
|
238
|
+
}
|
|
239
|
+
enqueuePathDependencies(crateParsed, dir, workspacePathDeps, pending, external, absoluteProjectRoot, workspaceRoot);
|
|
240
|
+
// All cfg variants can affect a compiled target; do not evaluate Cargo cfg here.
|
|
241
|
+
if (isRecord(crateParsed.target)) {
|
|
242
|
+
for (const target of Object.values(crateParsed.target)) {
|
|
243
|
+
if (isRecord(target)) {
|
|
244
|
+
enqueuePathDependencies(target, dir, workspacePathDeps, pending, external, absoluteProjectRoot, workspaceRoot);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (isRecord(crateParsed.package) && typeof crateParsed.package.build === 'string') {
|
|
249
|
+
declaredSources.add(resolve(absoluteProjectRoot, dir, crateParsed.package.build));
|
|
250
|
+
}
|
|
251
|
+
for (const targetName of ['lib', 'bin', 'example', 'test', 'bench']) {
|
|
252
|
+
const targets = crateParsed[targetName];
|
|
253
|
+
for (const target of Array.isArray(targets) ? targets : [targets]) {
|
|
254
|
+
if (isRecord(target) && typeof target.path === 'string') {
|
|
255
|
+
declaredSources.add(resolve(absoluteProjectRoot, dir, target.path));
|
|
155
256
|
}
|
|
156
257
|
}
|
|
157
258
|
}
|
|
158
259
|
}
|
|
159
|
-
const
|
|
260
|
+
const inputPath = (absolutePath) => {
|
|
261
|
+
const cargoRelative = relative(absoluteProjectRoot, absolutePath).split(sep).join('/');
|
|
262
|
+
return isOutsideRoot(cargoRelative)
|
|
263
|
+
? posix.join('{workspaceRoot}', relative(workspaceRoot, absolutePath).split(sep).join('/'))
|
|
264
|
+
: posix.join(inputRoot, cargoRelative);
|
|
265
|
+
};
|
|
266
|
+
const inputs = new Set([`${inputRoot}/Cargo.toml`, `${inputRoot}/Cargo.lock`]);
|
|
267
|
+
const exclusions = new Set();
|
|
160
268
|
for (const dir of [...dirs].sort()) {
|
|
161
|
-
|
|
269
|
+
const absoluteDir = resolve(absoluteProjectRoot, dir);
|
|
270
|
+
// Cargo packages can compile include_bytes!, headers, schemas and build.rs,
|
|
271
|
+
// not only Rust sources. Nested packages are separate source owners.
|
|
272
|
+
inputs.add(`${inputPath(absoluteDir)}/**/*`);
|
|
273
|
+
const scan = [absoluteDir];
|
|
274
|
+
while (scan.length > 0) {
|
|
275
|
+
const current = scan.pop();
|
|
276
|
+
if (current === undefined || !existsSync(current))
|
|
277
|
+
continue;
|
|
278
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
279
|
+
if (!entry.isDirectory())
|
|
280
|
+
continue;
|
|
281
|
+
const child = join(current, entry.name);
|
|
282
|
+
if (['target', '.git', 'node_modules', '.nx'].includes(entry.name)) {
|
|
283
|
+
}
|
|
284
|
+
else if (existsSync(join(child, 'Cargo.toml'))) {
|
|
285
|
+
const childDir = relative(absoluteProjectRoot, child).split(sep).join('/');
|
|
286
|
+
if (!dirs.has(childDir))
|
|
287
|
+
exclusions.add(`!${inputPath(child)}/**`);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
scan.push(child);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
162
294
|
}
|
|
163
|
-
|
|
164
|
-
|
|
295
|
+
for (const source of [...declaredSources].sort()) {
|
|
296
|
+
const sourceRelative = relative(workspaceRoot, source);
|
|
297
|
+
if (isOutsideRoot(sourceRelative)) {
|
|
298
|
+
external.set(source, source);
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
inputs.add(inputPath(source));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Cargo/rustup search from the command's working directory upwards. Do not
|
|
305
|
+
// hash unrelated descendant configuration or generated Cargo target caches.
|
|
306
|
+
for (let current = resolve(absoluteProjectRoot);; current = dirname(current)) {
|
|
307
|
+
for (const config of [
|
|
308
|
+
'.cargo/config',
|
|
309
|
+
'.cargo/config.toml',
|
|
310
|
+
'rust-toolchain',
|
|
311
|
+
'rust-toolchain.toml',
|
|
312
|
+
'rustfmt.toml',
|
|
313
|
+
'.rustfmt.toml',
|
|
314
|
+
'clippy.toml',
|
|
315
|
+
'.clippy.toml',
|
|
316
|
+
]) {
|
|
317
|
+
inputs.add(inputPath(join(current, config)));
|
|
318
|
+
if (config === '.cargo/config' || config === '.cargo/config.toml') {
|
|
319
|
+
const configPath = join(current, config);
|
|
320
|
+
if (existsSync(configPath)) {
|
|
321
|
+
const cargoConfig = await loadManifest(configPath);
|
|
322
|
+
if (isRecord(cargoConfig.build) && typeof cargoConfig.build['target-dir'] === 'string') {
|
|
323
|
+
const targetDir = resolve(current, cargoConfig.build['target-dir']);
|
|
324
|
+
if (!isOutsideRoot(relative(workspaceRoot, targetDir))) {
|
|
325
|
+
exclusions.add(`!${inputPath(targetDir)}/**`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (current === resolve(workspaceRoot) || dirname(current) === current)
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
inputs.add(`${inputRoot}/.config/nextest.toml`);
|
|
335
|
+
for (const generated of ['.git', 'node_modules', '.nx']) {
|
|
336
|
+
inputs.add(`!{workspaceRoot}/**/${generated}/**`);
|
|
337
|
+
}
|
|
338
|
+
inputs.add(`!${inputRoot}/**/target/**`);
|
|
339
|
+
inputs.add('!{workspaceRoot}/**/target/**');
|
|
340
|
+
for (const exclusion of [...exclusions].sort())
|
|
341
|
+
inputs.add(exclusion);
|
|
342
|
+
// Arbitrary build-script reads outside package trees, custom output trees,
|
|
343
|
+
// and ambient tools/environment require explicit target or named inputs.
|
|
344
|
+
if (external.size > 0) {
|
|
345
|
+
if (readNxJson(workspaceRoot).namedInputs?.[EXTERNAL_RUST_CRATES_INPUT] === undefined) {
|
|
346
|
+
const listed = [...external]
|
|
347
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
348
|
+
.map(([name, dir]) => `${name} -> ${dir}`)
|
|
349
|
+
.join(', ');
|
|
350
|
+
throw new Error(`${memberDir}/Cargo.toml references inputs outside the Nx workspace (${listed}) that no fileset can hash; ` +
|
|
351
|
+
`declare namedInputs.${EXTERNAL_RUST_CRATES_INPUT} in ${join(workspaceRoot, 'nx.json')} ` +
|
|
352
|
+
'with runtime inputs that hash those external sources and configuration');
|
|
353
|
+
}
|
|
354
|
+
inputs.add(EXTERNAL_RUST_CRATES_INPUT);
|
|
355
|
+
}
|
|
356
|
+
return [...inputs];
|
|
165
357
|
}
|
|
166
|
-
|
|
167
|
-
const
|
|
358
|
+
function enqueuePathDependencies(scope, memberDir, workspacePathDeps, pending, external, absoluteProjectRoot, workspaceRoot) {
|
|
359
|
+
for (const tableName of ['dependencies', 'dev-dependencies', 'build-dependencies']) {
|
|
360
|
+
const table = scope[tableName];
|
|
361
|
+
if (!isRecord(table)) {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
for (const [depName, spec] of Object.entries(table)) {
|
|
365
|
+
const pathDep = pathDependencyDir(memberDir, depName, spec, workspacePathDeps, absoluteProjectRoot, workspaceRoot);
|
|
366
|
+
if (pathDep === null) {
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (pathDep.external) {
|
|
370
|
+
external.set(depName, pathDep.dir);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
pending.push(pathDep.dir);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function workspacePathDependencies(parsed, root) {
|
|
168
379
|
const deps = new Map();
|
|
169
380
|
if (!isRecord(parsed) || !isRecord(parsed.workspace) || !isRecord(parsed.workspace.dependencies)) {
|
|
170
381
|
return deps;
|
|
171
382
|
}
|
|
172
383
|
for (const [name, spec] of Object.entries(parsed.workspace.dependencies)) {
|
|
173
384
|
if (isRecord(spec) && typeof spec.path === 'string') {
|
|
174
|
-
|
|
385
|
+
const path = spec.path.split('\\').join('/');
|
|
386
|
+
deps.set(name, resolve(root, path));
|
|
175
387
|
}
|
|
176
388
|
}
|
|
177
389
|
return deps;
|
|
178
390
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
391
|
+
/**
|
|
392
|
+
* Resolve inherited dependencies from their owning workspace and local paths
|
|
393
|
+
* from their member directory. Paths inside Nx remain in the ordinary source
|
|
394
|
+
* closure even when they escape the Cargo workspace; paths outside Nx require
|
|
395
|
+
* an explicit runtime named input.
|
|
396
|
+
*/
|
|
397
|
+
function pathDependencyDir(memberDir, depName, spec, workspacePathDeps, absoluteProjectRoot, workspaceRoot) {
|
|
186
398
|
if (!isRecord(spec)) {
|
|
187
399
|
return null;
|
|
188
400
|
}
|
|
401
|
+
let raw;
|
|
189
402
|
if (spec.workspace === true) {
|
|
190
|
-
|
|
403
|
+
const workspacePath = workspacePathDeps.get(depName);
|
|
404
|
+
if (workspacePath === undefined) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
raw = workspacePath;
|
|
191
408
|
}
|
|
192
|
-
if (typeof spec.path
|
|
193
|
-
|
|
409
|
+
else if (typeof spec.path === 'string') {
|
|
410
|
+
const localPath = spec.path.split('\\').join('/');
|
|
411
|
+
raw =
|
|
412
|
+
isAbsolute(localPath) || posix.isAbsolute(localPath)
|
|
413
|
+
? localPath
|
|
414
|
+
: posix.join(memberDir.split('\\').join('/'), localPath);
|
|
194
415
|
}
|
|
195
|
-
|
|
196
|
-
if (resolved.startsWith('..')) {
|
|
416
|
+
else {
|
|
197
417
|
return null;
|
|
198
418
|
}
|
|
199
|
-
|
|
419
|
+
const absolute = resolve(absoluteProjectRoot, raw);
|
|
420
|
+
const local = relative(absoluteProjectRoot, absolute).split(sep).join(posix.sep) || '.';
|
|
421
|
+
return { dir: local, external: isOutsideRoot(relative(workspaceRoot, absolute)) };
|
|
422
|
+
}
|
|
423
|
+
function isOutsideRoot(path) {
|
|
424
|
+
return path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path);
|
|
200
425
|
}
|
|
201
426
|
function isRecord(value) {
|
|
202
427
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -213,8 +438,7 @@ function isRecord(value) {
|
|
|
213
438
|
*
|
|
214
439
|
* It is declared rather than inferred because the only honest input is how long
|
|
215
440
|
* the suite takes, which target inference cannot measure. Defaulting to 1 keeps
|
|
216
|
-
* small crates on a single target
|
|
217
|
-
* sharding them would buy nothing and pay a per-target cargo freshness check.
|
|
441
|
+
* small crates on a single target without paying another Cargo freshness check.
|
|
218
442
|
*/
|
|
219
443
|
function readTestShards(cratePackage, crateTomlPath) {
|
|
220
444
|
const metadata = isRecord(cratePackage.metadata) ? cratePackage.metadata : null;
|
|
@@ -245,7 +469,7 @@ export const CARGO_TEST_COMPILE_TARGET = 'cargo-test-compile';
|
|
|
245
469
|
export const CARGO_TEST_EXCEPTIONS_SUFFIX = 'exceptions';
|
|
246
470
|
/**
|
|
247
471
|
* A crate on one target keeps the bare name; a split crate suffixes the piece,
|
|
248
|
-
* so `cargo-test-
|
|
472
|
+
* so `cargo-test-example-core-shard2` still reads as "example-core's tests".
|
|
249
473
|
*/
|
|
250
474
|
export function cargoTestPackageTargetName(packageName, piece) {
|
|
251
475
|
const base = `cargo-test-${packageName}`;
|
|
@@ -268,24 +492,10 @@ export function packageNameFromCargoTestTarget(targetName) {
|
|
|
268
492
|
/**
|
|
269
493
|
* The tests nextest.toml singles out with an override, as one filterset.
|
|
270
494
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* - a `test-group` is scoped to a single nextest RUN, so letting the hash
|
|
276
|
-
* scatter its members across shards silently dissolves it. The real-APFS
|
|
277
|
-
* group exists because those tests contend on Disk Arbitration
|
|
278
|
-
* machine-wide, where an unscoped `diskutil apfs list -plist` measured 0.7s
|
|
279
|
-
* idle against 14.4s while another process is attaching.
|
|
280
|
-
* - a raised `slow-timeout` marks a test whose cost is not the suite's cost.
|
|
281
|
-
* `lesser_capabilities_fail_to_compile_...` rustc's a fixture that
|
|
282
|
-
* `cargo test --no-run` cannot pre-build, so it costs 25.6s on a cold
|
|
283
|
-
* target directory against 1.8s warm. Every CI runner is cold, and left in
|
|
284
|
-
* a shard that spike lands on whichever 250-odd tests share it.
|
|
285
|
-
*
|
|
286
|
-
* One target for all of them rather than one each: they sit in different groups
|
|
287
|
-
* so they run concurrently, making the combined wall the max of the classes
|
|
288
|
-
* rather than their sum.
|
|
495
|
+
* Overrides can encode constraints that must survive sharding: a test group
|
|
496
|
+
* limits concurrency within one nextest run, while a raised slow timeout can
|
|
497
|
+
* identify expensive tests that should not delay an otherwise bounded shard.
|
|
498
|
+
* Keep the configured exceptions in one run so group limits remain effective.
|
|
289
499
|
*
|
|
290
500
|
* Deriving this from the config that declares the classes, rather than
|
|
291
501
|
* restating their filters, means adding an override there is the whole change —
|
|
@@ -34,11 +34,6 @@ export declare const DEVENV_CROSS_PROFILE = "linux-cross";
|
|
|
34
34
|
* build-output families, so no aggregate `build` picks it up either.
|
|
35
35
|
*/
|
|
36
36
|
export declare const CARGO_CROSS_LINT_TARGET = "cargo-lint-cross";
|
|
37
|
-
/**
|
|
38
|
-
* Point this cargo at a project-local home so parallel Nx cargos do not
|
|
39
|
-
* exclusive-lock `~/.cargo/.package-cache`. Downloaded crates stay shared.
|
|
40
|
-
*/
|
|
41
|
-
export declare function withProjectCargoHome(homeRel: string, command: string): string;
|
|
42
37
|
/**
|
|
43
38
|
* The prefix `cargoFrozen` writes. Exported so target inference can recognize
|
|
44
39
|
* the commands whose precondition `CARGO_FETCH_TARGET` supplies without
|
|
@@ -104,11 +99,11 @@ export declare const CARGO_FETCH_COMMAND = "cargo fetch --locked";
|
|
|
104
99
|
* `cargo fmt` is absent on purpose: formatting is target-independent and already
|
|
105
100
|
* covered by `cargo-lint`, so repeating it here would only cost time.
|
|
106
101
|
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
102
|
+
* Keep the caller's CARGO_HOME: it owns registry sources, credentials and global
|
|
103
|
+
* Cargo configuration, including paths relative to that configuration. Relocating
|
|
104
|
+
* or replaying it through --config changes path resolution or precedence.
|
|
105
|
+
* Cargo may serialize registry access on its package-cache lock; these checks
|
|
106
|
+
* are unbounded, and correctness takes priority over overlapping that access.
|
|
112
107
|
*/
|
|
113
108
|
export declare const CARGO_CROSS_LINT_COMMAND: string;
|
|
114
109
|
export declare const CARGO_LINT_CLIPPY_COMMAND: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAI1D
|
|
1
|
+
{"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAI1D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,QAElC,CAAC;AAEJ,eAAO,MAAM,yBAAyB,QAErC,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,mFAAyG,CAAC"}
|
|
@@ -35,13 +35,6 @@ export const DEVENV_CROSS_PROFILE = 'linux-cross';
|
|
|
35
35
|
*/
|
|
36
36
|
export const CARGO_CROSS_LINT_TARGET = 'cargo-lint-cross';
|
|
37
37
|
const CARGO_CROSS_LINT_GUARD = `[ -n "\${CC_x86_64_unknown_linux_gnu:-}" ] || [ "$(uname -s)" = Linux ] || { echo 'cargo-lint-cross needs the linux-cross C toolchain; run: bun run check:linux' >&2; exit 2; }`;
|
|
38
|
-
/**
|
|
39
|
-
* Point this cargo at a project-local home so parallel Nx cargos do not
|
|
40
|
-
* exclusive-lock `~/.cargo/.package-cache`. Downloaded crates stay shared.
|
|
41
|
-
*/
|
|
42
|
-
export function withProjectCargoHome(homeRel, command) {
|
|
43
|
-
return `host_cargo_home="\${CARGO_HOME:-$HOME/.cargo}"; mkdir -p ${homeRel}; if [ -d "$host_cargo_home/registry" ]; then ln -sfn "$host_cargo_home/registry" ${homeRel}/registry; fi; if [ -d "$host_cargo_home/git" ]; then ln -sfn "$host_cargo_home/git" ${homeRel}/git; fi; CARGO_HOME="$PWD/${homeRel}" ${command}`;
|
|
44
|
-
}
|
|
45
38
|
/**
|
|
46
39
|
* The prefix `cargoFrozen` writes. Exported so target inference can recognize
|
|
47
40
|
* the commands whose precondition `CARGO_FETCH_TARGET` supplies without
|
|
@@ -109,14 +102,14 @@ export const CARGO_FETCH_COMMAND = 'cargo fetch --locked';
|
|
|
109
102
|
* `cargo fmt` is absent on purpose: formatting is target-independent and already
|
|
110
103
|
* covered by `cargo-lint`, so repeating it here would only cost time.
|
|
111
104
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
105
|
+
* Keep the caller's CARGO_HOME: it owns registry sources, credentials and global
|
|
106
|
+
* Cargo configuration, including paths relative to that configuration. Relocating
|
|
107
|
+
* or replaying it through --config changes path resolution or precedence.
|
|
108
|
+
* Cargo may serialize registry access on its package-cache lock; these checks
|
|
109
|
+
* are unbounded, and correctness takes priority over overlapping that access.
|
|
117
110
|
*/
|
|
118
|
-
export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${
|
|
119
|
-
export const CARGO_LINT_CLIPPY_COMMAND =
|
|
111
|
+
export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${cargoFrozen(`clippy --workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross -- -D warnings`)}`;
|
|
112
|
+
export const CARGO_LINT_CLIPPY_COMMAND = cargoFrozen('clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings');
|
|
120
113
|
/** Root `package.json` script name, in the repo's `verb:qualifier` style. */
|
|
121
114
|
export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
|
|
122
115
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAGL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAGL,yBAAyB,EAQ1B,MAAM,sBAAsB,CAAC;AAY9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAmDrC,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AA0FD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AAkID,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|