@smoothbricks/nx-plugin 0.4.4 → 0.4.6
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 +35 -21
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +10 -4
- package/dist/cargo-workspace.d.ts +60 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +96 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +189 -118
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -2
- package/dist/source-directories.d.ts +11 -0
- package/dist/source-directories.d.ts.map +1 -0
- package/dist/source-directories.js +19 -0
- package/nextest.toml +9 -3
- package/package.json +1 -1
- package/src/bounded-test-policy.test.ts +67 -0
- package/src/bounded-test-policy.ts +11 -4
- package/src/cargo-workspace.ts +117 -29
- package/src/index.test.ts +166 -103
- package/src/index.ts +207 -128
- package/src/package-target-policy.test.ts +16 -0
- package/src/package-target-policy.ts +3 -2
- package/src/source-directories.ts +21 -0
package/src/index.test.ts
CHANGED
|
@@ -73,7 +73,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
73
73
|
};
|
|
74
74
|
const rustOnly = await runLint();
|
|
75
75
|
expect(rustOnly).toMatchObject({ exitCode: 0 });
|
|
76
|
-
expect(rustOnly.output).toContain('cargo-lint
|
|
76
|
+
expect(rustOnly.output).toContain('cargo-lint');
|
|
77
77
|
await workspace.write('packages/rust/src/check.js', 'debugger;\n');
|
|
78
78
|
const withJavaScript = await runLint();
|
|
79
79
|
expect(withJavaScript.exitCode).not.toBe(0);
|
|
@@ -386,7 +386,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
386
386
|
// needs the locked graph downloaded whether or not the chain runs first.
|
|
387
387
|
for (const name of [
|
|
388
388
|
'cargo-test-compile',
|
|
389
|
-
'cargo-
|
|
389
|
+
'cargo-test-archive',
|
|
390
|
+
'cargo-lint',
|
|
390
391
|
CARGO_CROSS_LINT_TARGET,
|
|
391
392
|
'mutation',
|
|
392
393
|
'bench',
|
|
@@ -403,15 +404,40 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
403
404
|
});
|
|
404
405
|
expect(targets['cargo-test']?.executor).toBe('nx:noop');
|
|
405
406
|
expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-test-ferris-wasm']);
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
//
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
407
|
+
// One workspace compile, packed once. Every per-crate runner reads that
|
|
408
|
+
// archive, so the runners fan out instead of chaining: none of them
|
|
409
|
+
// builds, re-resolves features, or writes cargo's flocked `target/`.
|
|
410
|
+
expect(targets['cargo-test-archive']?.executor).toBe('nx:run-commands');
|
|
411
|
+
expect(targets['cargo-test-archive']?.cache).toBe(true);
|
|
412
|
+
expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/target/nextest/archive.tar.zst']);
|
|
413
|
+
expect(targets['cargo-test-archive']?.options).toMatchObject({ cwd: 'packages/ferris', parallel: false });
|
|
414
|
+
// nextest does not create the archive's parent directory and fails the
|
|
415
|
+
// whole build if it is missing (measured: "error writing to archive").
|
|
416
|
+
expect(targets['cargo-test-archive']?.options?.commands?.[0]).toBe('mkdir -p target/nextest');
|
|
417
|
+
// `--tool-config-file`, never `--config-file`: the plugin's settings must
|
|
418
|
+
// sit UNDER the repository's `.config/nextest.toml`, which is the only
|
|
419
|
+
// place an `archive.include` for a cdylib or fixture can be declared.
|
|
420
|
+
// `$PWD` because tool config paths must be absolute and an absolute path
|
|
421
|
+
// in the command text would split one cache entry per checkout.
|
|
422
|
+
expect(String(targets['cargo-test-archive']?.options?.commands?.[1])).toMatch(
|
|
423
|
+
/^cargo --frozen nextest archive --workspace --archive-file target\/nextest\/archive\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
424
|
+
);
|
|
425
|
+
expect(targets['cargo-test-archive']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
|
|
426
|
+
expect(String(targets['cargo-test-archive']?.configurations?.production?.commands?.[1])).toContain(
|
|
427
|
+
'nextest archive --workspace --release --archive-file',
|
|
428
|
+
);
|
|
429
|
+
expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
430
|
+
expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
431
|
+
// The runner executes the archive's binaries and remaps the workspace
|
|
432
|
+
// root: without `--workspace-remap`, a restored archive hands tests the
|
|
433
|
+
// PRODUCING tree's absolute CARGO_MANIFEST_DIR (measured on a moved tree).
|
|
434
|
+
// `--workspace` is not merely redundant here, nextest rejects it with
|
|
435
|
+
// `--archive-file`.
|
|
412
436
|
expect(targets['cargo-test-ferris-core']?.options?.command).toMatch(
|
|
413
|
-
/^cargo --frozen nextest run --workspace -E 'package\(ferris-core\)' --no-tests=pass --user-config-file none --config-file
|
|
437
|
+
/^cargo --frozen nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(ferris-core\)' --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
414
438
|
);
|
|
439
|
+
expect(targets['cargo-test-ferris-core']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
|
|
440
|
+
expect(targets['cargo-test-ferris-core']?.configurations?.production).toEqual({});
|
|
415
441
|
expect(targets['cargo-test-ferris-core']?.inputs).toEqual(
|
|
416
442
|
expect.arrayContaining([
|
|
417
443
|
'{projectRoot}/Cargo.toml',
|
|
@@ -420,16 +446,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
420
446
|
]),
|
|
421
447
|
);
|
|
422
448
|
expect(targets['cargo-test-ferris-core']?.inputs).not.toContain('{projectRoot}/crates/ferris-wasm/**/*');
|
|
423
|
-
|
|
424
|
-
|
|
449
|
+
// One clippy for the workspace in one target dir: a per-crate closure
|
|
450
|
+
// compiled every shared dependency once per crate.
|
|
451
|
+
expect(targets['cargo-lint']?.options).toMatchObject({
|
|
425
452
|
cwd: 'packages/ferris',
|
|
426
453
|
commands: [
|
|
427
|
-
'cargo fmt
|
|
428
|
-
'cargo --frozen clippy
|
|
454
|
+
'cargo fmt --all --check',
|
|
455
|
+
'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
|
|
429
456
|
],
|
|
430
457
|
});
|
|
431
|
-
expect(targets['cargo-lint
|
|
432
|
-
expect(targets['cargo-lint
|
|
458
|
+
expect(targets['cargo-lint']?.cache).toBe(true);
|
|
459
|
+
expect(targets['cargo-lint']?.outputs).toEqual([]);
|
|
460
|
+
expect(targets['cargo-lint']?.inputs).toEqual(
|
|
461
|
+
expect.arrayContaining(['{projectRoot}/crates/ferris-core/**/*', '{projectRoot}/crates/ferris-wasm/**/*']),
|
|
462
|
+
);
|
|
433
463
|
expect(targets.lint?.dependsOn).toEqual(['cargo-lint']);
|
|
434
464
|
expect(targets[CARGO_CROSS_LINT_TARGET]?.options).toMatchObject({
|
|
435
465
|
command: CARGO_CROSS_LINT_COMMAND,
|
|
@@ -447,6 +477,32 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
447
477
|
}
|
|
448
478
|
});
|
|
449
479
|
|
|
480
|
+
it('cleans every cargo directory its own commands write, including the ones caching refuses', async () => {
|
|
481
|
+
const workspace = await createWorkspace();
|
|
482
|
+
try {
|
|
483
|
+
await workspace.write('packages/ferris/package.json', '{"name":"ferris"}\n');
|
|
484
|
+
await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = ["crates/ferris-core"]\n');
|
|
485
|
+
await workspace.write('packages/ferris/crates/ferris-core/Cargo.toml', '[package]\nname = "ferris-core"\n');
|
|
486
|
+
|
|
487
|
+
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
488
|
+
|
|
489
|
+
// A clippy target dir is not an Nx output — restoring an 11 GiB build
|
|
490
|
+
// tree from a cache is worse than rebuilding it — so `clean` cannot find
|
|
491
|
+
// these through `outputs`. They are read back off the commands that
|
|
492
|
+
// write them, which is why a new `--target-dir` cannot be forgotten here.
|
|
493
|
+
expect(targets.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
494
|
+
expect(targets.clean?.cache).toBe(false);
|
|
495
|
+
expect(targets.clean?.options?.outputs).toEqual([
|
|
496
|
+
'{projectRoot}/dist',
|
|
497
|
+
'{workspaceRoot}/packages/ferris/target/cargo-lint',
|
|
498
|
+
'{workspaceRoot}/packages/ferris/target/cargo-lint-cross',
|
|
499
|
+
'{workspaceRoot}/packages/ferris/target/nextest',
|
|
500
|
+
]);
|
|
501
|
+
} finally {
|
|
502
|
+
await workspace.cleanup();
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
|
|
450
506
|
it('keeps Rust-only lint source-aware after migrating defaults without replacing mixed or custom lint', async () => {
|
|
451
507
|
const workspace = await createWorkspace();
|
|
452
508
|
const root = 'packages/ferris';
|
|
@@ -567,6 +623,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
567
623
|
const rootProject = '@fixture/codebase';
|
|
568
624
|
const rootFetch = { projects: [rootProject], target: 'cargo-fetch' };
|
|
569
625
|
const rootCompile = { projects: [rootProject], target: 'cargo-test-compile' };
|
|
626
|
+
const rootArchive = { projects: [rootProject], target: 'cargo-test-archive' };
|
|
570
627
|
|
|
571
628
|
expect(
|
|
572
629
|
[...projects]
|
|
@@ -582,28 +639,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
582
639
|
command: 'cargo --frozen test --workspace --no-run',
|
|
583
640
|
cwd: '.',
|
|
584
641
|
});
|
|
585
|
-
expect(root['cargo-lint']?.
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
{ projects: ['wasm'], target: 'cargo-lint-runtime-wasm' },
|
|
642
|
+
expect(root['cargo-lint']?.options?.commands).toEqual([
|
|
643
|
+
'cargo fmt --all --check',
|
|
644
|
+
'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
|
|
589
645
|
]);
|
|
646
|
+
expect(root['cargo-lint']?.dependsOn).toContain('cargo-fetch');
|
|
590
647
|
expect(root['cargo-test']?.dependsOn).toHaveLength(5);
|
|
591
648
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
]);
|
|
596
|
-
expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([
|
|
597
|
-
|
|
598
|
-
'cargo-test-runtime-core-shard1',
|
|
599
|
-
]);
|
|
600
|
-
expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([
|
|
601
|
-
rootFetch,
|
|
602
|
-
'cargo-test-runtime-core-shard2',
|
|
603
|
-
]);
|
|
649
|
+
// Root mode: every piece of every project hangs off the one root archive,
|
|
650
|
+
// in any order. The crate is selected by filterset alone — `-p` would
|
|
651
|
+
// re-resolve features, and there is nothing left to build anyway.
|
|
652
|
+
expect(runtime['cargo-test-runtime-core-shard1']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
653
|
+
expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
654
|
+
expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
604
655
|
expect(runtime['cargo-test-runtime-core-shard1']?.options).toMatchObject({ cwd: '.' });
|
|
605
656
|
expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toContain(
|
|
606
|
-
|
|
657
|
+
"nextest run --archive-file target/nextest/archive.tar.zst --workspace-remap . -E 'package(runtime-core)",
|
|
607
658
|
);
|
|
608
659
|
expect(native['cargo-test-native-napi']?.options?.command).toContain('--no-tests=pass');
|
|
609
660
|
expect(runtime['cargo-test']?.dependsOn).toEqual([
|
|
@@ -611,16 +662,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
611
662
|
'cargo-test-runtime-core-shard2',
|
|
612
663
|
'cargo-test-runtime-core-exceptions',
|
|
613
664
|
]);
|
|
614
|
-
|
|
665
|
+
// A package owning crates validates through the root's one clippy verdict.
|
|
666
|
+
expect(runtime['cargo-lint']?.dependsOn).toEqual([{ projects: [rootProject], target: 'cargo-lint' }]);
|
|
615
667
|
expect(runtime.lint?.dependsOn).toEqual(['cargo-lint']);
|
|
616
|
-
expect(runtime['cargo-lint-runtime-core']
|
|
617
|
-
expect(runtime['cargo-lint-runtime-core']?.options?.cwd).toBe('.');
|
|
668
|
+
expect(runtime['cargo-lint-runtime-core']).toBeUndefined();
|
|
618
669
|
expect(runtime.clean).toBeUndefined();
|
|
619
670
|
|
|
620
|
-
expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([
|
|
621
|
-
rootFetch,
|
|
622
|
-
{ projects: ['runtime'], target: 'cargo-test-runtime-core-exceptions' },
|
|
623
|
-
]);
|
|
671
|
+
expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
624
672
|
expect(wasm['cargo-wasm']?.options).toMatchObject({ cwd: '.' });
|
|
625
673
|
expect(wasm['cargo-wasm']?.options?.commands).toContain(
|
|
626
674
|
'cargo --frozen build --release --target wasm32-unknown-unknown --target-dir target/cargo-wasm -p runtime-wasm',
|
|
@@ -630,7 +678,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
630
678
|
expect(wasm.build?.dependsOn).toContainEqual(rootCompile);
|
|
631
679
|
expect(wasm.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
632
680
|
|
|
633
|
-
|
|
681
|
+
// The crate whose project also builds the debug cdylib keeps that edge:
|
|
682
|
+
// its tests load the artifact `napi-debug` writes into `target/debug`.
|
|
683
|
+
expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, rootArchive, 'napi-debug']);
|
|
634
684
|
expect(native['napi-debug']?.dependsOn).toContainEqual(rootCompile);
|
|
635
685
|
expect(native['napi-debug']?.options).toMatchObject({
|
|
636
686
|
cwd: '.',
|
|
@@ -652,8 +702,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
652
702
|
it('keeps root packages, nested workspaces and multiple owned crates in their own lint graph', async () => {
|
|
653
703
|
const workspace = await createWorkspace();
|
|
654
704
|
const declared: Record<string, TargetConfiguration> = {
|
|
655
|
-
'cargo-lint
|
|
656
|
-
'cargo-lint': { dependsOn: ['cargo-lint-alpha-core'] },
|
|
705
|
+
'cargo-lint': { dependsOn: ['...', 'prepare-check'] },
|
|
657
706
|
lint: { dependsOn: ['cargo-lint', 'custom-check'] },
|
|
658
707
|
};
|
|
659
708
|
try {
|
|
@@ -686,45 +735,49 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
686
735
|
const group = projects.get('packages/group')?.targets ?? {};
|
|
687
736
|
const inner = projects.get('nested')?.targets ?? {};
|
|
688
737
|
const leaf = projects.get('nested/modules/leaf')?.targets ?? {};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
'
|
|
693
|
-
|
|
694
|
-
|
|
738
|
+
// Each cargo workspace root runs one clippy over all its members; the
|
|
739
|
+
// packages owning crates validate through that verdict.
|
|
740
|
+
expect(outer['cargo-lint']?.options).toMatchObject({
|
|
741
|
+
cwd: '.',
|
|
742
|
+
commands: [
|
|
743
|
+
'cargo fmt --all --check',
|
|
744
|
+
'cargo --frozen clippy --workspace --all-targets --target-dir target/cargo-lint -- -D warnings',
|
|
745
|
+
],
|
|
746
|
+
});
|
|
747
|
+
expect(outer['cargo-lint']?.inputs).toEqual(
|
|
748
|
+
expect.arrayContaining([
|
|
749
|
+
'{projectRoot}/packages/group/crates/alpha/**/*',
|
|
750
|
+
'{projectRoot}/packages/group/crates/beta/**/*',
|
|
751
|
+
]),
|
|
752
|
+
);
|
|
753
|
+
expect(group['cargo-lint']?.dependsOn).toEqual([{ projects: ['outer-root'], target: 'cargo-lint' }]);
|
|
695
754
|
expect(group.build?.dependsOn).toEqual([
|
|
696
755
|
'^build',
|
|
697
756
|
{ projects: ['outer-root'], target: 'cargo-test-compile' },
|
|
698
757
|
'tsc-js',
|
|
699
758
|
]);
|
|
700
|
-
expect(outer['cargo-lint-host-core']
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
]);
|
|
704
|
-
expect(
|
|
705
|
-
|
|
706
|
-
{ projects: ['inner-leaf-project'], target: 'cargo-lint-inner-leaf' },
|
|
707
|
-
]);
|
|
708
|
-
expect(leaf['cargo-lint-inner-leaf']?.options).toMatchObject({
|
|
709
|
-
cwd: 'nested',
|
|
710
|
-
commands: [
|
|
711
|
-
'cargo fmt -p inner-leaf --check',
|
|
712
|
-
'cargo --frozen clippy -p inner-leaf --all-targets --target-dir target/cargo-lint-inner-leaf -- -D warnings',
|
|
713
|
-
],
|
|
714
|
-
});
|
|
715
|
-
expect(leaf['cargo-lint-inner-leaf']?.dependsOn).toEqual([{ projects: ['inner-root'], target: 'cargo-fetch' }]);
|
|
716
|
-
expect(leaf['cargo-lint-inner-leaf']?.inputs).toContain('{workspaceRoot}/nested/modules/leaf/**/*');
|
|
717
|
-
expect(leaf['cargo-lint-inner-leaf']?.inputs).not.toContain('{workspaceRoot}/packages/group/crates/alpha/**/*');
|
|
759
|
+
expect(outer['cargo-lint-host-core']).toBeUndefined();
|
|
760
|
+
expect(inner['cargo-lint']?.options).toMatchObject({ cwd: 'nested' });
|
|
761
|
+
expect(inner['cargo-lint']?.inputs).toContain('{projectRoot}/**/*');
|
|
762
|
+
expect(inner['cargo-lint']?.inputs).not.toContain('{workspaceRoot}/packages/group/crates/alpha/**/*');
|
|
763
|
+
expect(leaf['cargo-lint']?.dependsOn).toEqual([{ projects: ['inner-root'], target: 'cargo-lint' }]);
|
|
764
|
+
expect(leaf['cargo-lint-inner-leaf']).toBeUndefined();
|
|
718
765
|
expect(leaf['cargo-test-inner-leaf']?.options?.cwd).toBe('nested');
|
|
719
766
|
expect(inner['cargo-test-compile']?.options?.cwd).toBe('nested');
|
|
720
|
-
expect(leaf['cargo-test-inner-leaf']?.
|
|
721
|
-
|
|
722
|
-
|
|
767
|
+
expect(leaf['cargo-test-inner-leaf']?.dependsOn).toEqual([
|
|
768
|
+
{ projects: ['inner-root'], target: 'cargo-fetch' },
|
|
769
|
+
{ projects: ['inner-root'], target: 'cargo-test-archive' },
|
|
770
|
+
]);
|
|
771
|
+
// The profile lives in the archive, so the runner's production
|
|
772
|
+
// configuration has nothing left to say.
|
|
773
|
+
expect(leaf['cargo-test-inner-leaf']?.configurations?.production).toEqual({});
|
|
774
|
+
expect(inner['cargo-test-archive']?.options?.cwd).toBe('nested');
|
|
775
|
+
expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')).toMatchObject({
|
|
776
|
+
executor: 'nx:noop',
|
|
723
777
|
cache: true,
|
|
724
778
|
outputs: [],
|
|
725
|
-
dependsOn: [{ projects: ['outer-root'], target: 'cargo-
|
|
779
|
+
dependsOn: [{ projects: ['outer-root'], target: 'cargo-lint' }, 'prepare-check'],
|
|
726
780
|
});
|
|
727
|
-
expect(resolveDeclaredOverInferred(group, declared, 'cargo-lint')?.dependsOn).toEqual(['cargo-lint-alpha-core']);
|
|
728
781
|
expect(resolveDeclaredOverInferred(group, declared, 'lint')?.dependsOn).toEqual(['cargo-lint', 'custom-check']);
|
|
729
782
|
} finally {
|
|
730
783
|
await workspace.cleanup();
|
|
@@ -739,7 +792,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
739
792
|
await workspace.write('crate/Cargo.toml', '[package]\nname = "cache-crate"\n');
|
|
740
793
|
await workspace.write('cargo-home/config.toml', '[build]\njobs = 1\n');
|
|
741
794
|
const targets = await inferProjectTargets(workspace, 'package.json');
|
|
742
|
-
const runtimeCommands = (targets['cargo-lint
|
|
795
|
+
const runtimeCommands = (targets['cargo-lint']?.inputs ?? []).flatMap((input) =>
|
|
743
796
|
typeof input !== 'string' && 'runtime' in input ? [input.runtime] : [],
|
|
744
797
|
);
|
|
745
798
|
const capture = async (extraEnv: Record<string, string>) =>
|
|
@@ -784,20 +837,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
784
837
|
|
|
785
838
|
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
786
839
|
|
|
787
|
-
// Scoped by filterset over
|
|
788
|
-
//
|
|
840
|
+
// Scoped by filterset over one archived workspace build: exactly one
|
|
841
|
+
// crate runs, and no `-p` re-resolves its features.
|
|
789
842
|
expect(cargoPackageSelection(String(targets['cargo-test-ferris-core']?.options?.command ?? ''))).toEqual({
|
|
790
|
-
|
|
843
|
+
archiveRun: true,
|
|
791
844
|
packageFlags: [],
|
|
792
845
|
filtered: ['ferris-core'],
|
|
793
846
|
});
|
|
794
847
|
expect(cargoPackageSelection(String(targets['cargo-test-ferris-wasm']?.options?.command ?? ''))).toEqual({
|
|
795
|
-
|
|
848
|
+
archiveRun: true,
|
|
796
849
|
packageFlags: [],
|
|
797
850
|
filtered: ['ferris-wasm'],
|
|
798
851
|
});
|
|
799
|
-
expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-
|
|
800
|
-
expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-
|
|
852
|
+
expect(targets['cargo-test-ferris-core']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
853
|
+
expect(targets['cargo-test-ferris-wasm']?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
801
854
|
expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-test-ferris-wasm']);
|
|
802
855
|
} finally {
|
|
803
856
|
await workspace.cleanup();
|
|
@@ -1083,12 +1136,17 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1083
1136
|
},
|
|
1084
1137
|
});
|
|
1085
1138
|
expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-cowshed-napi']);
|
|
1086
|
-
// cargo-fetch survives the napi-debug
|
|
1087
|
-
//
|
|
1088
|
-
//
|
|
1089
|
-
|
|
1139
|
+
// cargo-fetch survives the napi-debug edge: the per-crate runner is itself
|
|
1140
|
+
// a frozen cargo command, so its precondition is its own edge. It reads
|
|
1141
|
+
// the workspace archive and still waits for the debug cdylib its own
|
|
1142
|
+
// project builds, because its tests load that artifact from `target/`.
|
|
1143
|
+
expect(targets['cargo-test-cowshed-napi']?.dependsOn).toEqual([
|
|
1144
|
+
'cargo-fetch',
|
|
1145
|
+
'cargo-test-archive',
|
|
1146
|
+
'napi-debug',
|
|
1147
|
+
]);
|
|
1090
1148
|
expect(targets['cargo-test-cowshed-napi']?.options?.command).toMatch(
|
|
1091
|
-
/^cargo --frozen nextest run --workspace -E 'package\(cowshed-napi\)' --no-tests=pass --user-config-file none --config-file
|
|
1149
|
+
/^cargo --frozen nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(cowshed-napi\)' --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
1092
1150
|
);
|
|
1093
1151
|
expect(targets['napi-test']).toMatchObject({
|
|
1094
1152
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
@@ -1167,7 +1225,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1167
1225
|
// An unsharded crate keeps the bare name and takes no --partition, so
|
|
1168
1226
|
// declaring nothing is exactly the old single-target behaviour.
|
|
1169
1227
|
expect(targets['cargo-test-small']?.options?.command).toMatch(
|
|
1170
|
-
/nextest run --workspace -E 'package\(small\)' --no-tests=pass --user-config-file none/,
|
|
1228
|
+
/nextest run --archive-file target\/nextest\/archive\.tar\.zst --workspace-remap \. -E 'package\(small\)' --no-tests=pass --user-config-file none/,
|
|
1171
1229
|
);
|
|
1172
1230
|
// The shards partition the crate MINUS the classes nextest.toml singles
|
|
1173
1231
|
// out, i of N. Those are lifted out because a test-group only holds
|
|
@@ -1180,22 +1238,22 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1180
1238
|
}
|
|
1181
1239
|
for (const index of [1, 2, 3]) {
|
|
1182
1240
|
expect(targets[`cargo-test-big-shard${index}`]?.options?.command).toContain(
|
|
1183
|
-
|
|
1241
|
+
`-E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-tests=pass`,
|
|
1184
1242
|
);
|
|
1185
1243
|
expect(targets[`cargo-test-big-shard${index}`]?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
|
|
1186
1244
|
}
|
|
1187
1245
|
// Exact complement of the shards' filterset, so the union is the crate.
|
|
1188
1246
|
expect(targets['cargo-test-big-exceptions']?.options?.command).toContain(
|
|
1189
|
-
|
|
1247
|
+
`-E 'package(big) and (${exceptional})' --no-tests=pass`,
|
|
1190
1248
|
);
|
|
1191
1249
|
expect(targets['cargo-test-big-exceptions']?.options?.command).not.toContain('--partition');
|
|
1192
1250
|
expect(targets['cargo-test-big-exceptions']?.options?.timeoutMs).toBe(BOUNDED_TEST_TIMEOUT_MS);
|
|
1193
1251
|
// An unsharded crate needs no pin: its whole suite is already one run.
|
|
1194
1252
|
expect(targets['cargo-test-small-exceptions']).toBeUndefined();
|
|
1195
1253
|
expect(targets['cargo-test-big']).toBeUndefined();
|
|
1196
|
-
// Every piece reaches the aggregate, and they
|
|
1197
|
-
//
|
|
1198
|
-
//
|
|
1254
|
+
// Every piece reaches the aggregate, and they all hang off the one
|
|
1255
|
+
// archive: a run extracts binaries to its own temp directory and writes
|
|
1256
|
+
// nothing to cargo's flocked target/, so nothing is left to serialize.
|
|
1199
1257
|
expect(targets['cargo-test']?.dependsOn).toEqual([
|
|
1200
1258
|
'cargo-test-big-shard1',
|
|
1201
1259
|
'cargo-test-big-shard2',
|
|
@@ -1203,11 +1261,15 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1203
1261
|
'cargo-test-big-exceptions',
|
|
1204
1262
|
'cargo-test-small',
|
|
1205
1263
|
]);
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1264
|
+
for (const name of [
|
|
1265
|
+
'cargo-test-big-shard1',
|
|
1266
|
+
'cargo-test-big-shard2',
|
|
1267
|
+
'cargo-test-big-shard3',
|
|
1268
|
+
'cargo-test-big-exceptions',
|
|
1269
|
+
'cargo-test-small',
|
|
1270
|
+
]) {
|
|
1271
|
+
expect(targets[name]?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
1272
|
+
}
|
|
1211
1273
|
// Pieces of one crate share its inputs: they are one suite, split only to
|
|
1212
1274
|
// fit the bound, so any change to the crate invalidates all of them.
|
|
1213
1275
|
expect(targets['cargo-test-big-shard2']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
|
|
@@ -1464,16 +1526,17 @@ function resolveDeclaredOverInferred(
|
|
|
1464
1526
|
* How a cargo test command is scoped to one crate, split into the three facts
|
|
1465
1527
|
* that can independently go wrong.
|
|
1466
1528
|
*
|
|
1467
|
-
* `--
|
|
1468
|
-
* `cargo
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1529
|
+
* `--archive-file` must be present: the runner executes binaries one workspace
|
|
1530
|
+
* `cargo nextest archive --workspace` already built, so a per-crate run cannot
|
|
1531
|
+
* compile anything. Narrowing comes from the nextest filterset, which selects
|
|
1532
|
+
* what RUNS. `--package` narrows too, but it re-resolves that crate's features,
|
|
1533
|
+
* which is a build — 57.9s of a 120s bounded budget on a hosted 3-core macOS
|
|
1534
|
+
* runner when the runners still built — so its presence is a regression even
|
|
1535
|
+
* though it selects the same tests. nextest rejects it outright beside
|
|
1536
|
+
* `--archive-file`, and this assertion says so before cargo does.
|
|
1474
1537
|
*/
|
|
1475
1538
|
function cargoPackageSelection(command: string): {
|
|
1476
|
-
|
|
1539
|
+
archiveRun: boolean;
|
|
1477
1540
|
packageFlags: string[];
|
|
1478
1541
|
filtered: string[];
|
|
1479
1542
|
} {
|
|
@@ -1488,7 +1551,7 @@ function cargoPackageSelection(command: string): {
|
|
|
1488
1551
|
}
|
|
1489
1552
|
}
|
|
1490
1553
|
return {
|
|
1491
|
-
|
|
1554
|
+
archiveRun: tokens.includes('--archive-file'),
|
|
1492
1555
|
packageFlags,
|
|
1493
1556
|
filtered: [...command.matchAll(/\bpackage\(([^)]+)\)/g)].flatMap((match) =>
|
|
1494
1557
|
match[1] === undefined ? [] : [match[1]],
|