@smoothbricks/nx-plugin 0.4.6 → 0.4.7
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/index.js +16 -7
- package/package.json +1 -1
- package/src/index.test.ts +10 -0
- package/src/index.ts +16 -7
package/dist/index.js
CHANGED
|
@@ -549,14 +549,23 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
549
549
|
cache: cargoWorkspace.inputsCache,
|
|
550
550
|
})))).flat()),
|
|
551
551
|
];
|
|
552
|
-
|
|
552
|
+
// Generated crate sources (wire codecs, vocabularies, fixtures) are
|
|
553
|
+
// gitignored and invisible to nx's file hasher; they reach these targets
|
|
554
|
+
// as the outputs of the targets a repository adds to `dependsOn`. Hashing
|
|
555
|
+
// those outputs here means a repository never has to restate `inputs` to
|
|
556
|
+
// add them - and a restated `inputs` REPLACES this union with the root
|
|
557
|
+
// project's `default`, which owns no crate file, so the archive then
|
|
558
|
+
// cache-hits against edited crates while every per-crate test reruns on
|
|
559
|
+
// the stale binary. That verdict is wrong, not merely slow.
|
|
560
|
+
const workspaceCargoInputs = [
|
|
561
|
+
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
562
|
+
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
563
|
+
];
|
|
564
|
+
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
553
565
|
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(workspaceRoot, cargoWorkspaceRoot, PLUGIN_NEXTEST_CONFIG));
|
|
554
566
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
555
567
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
556
|
-
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [
|
|
557
|
-
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
558
|
-
`{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
|
|
559
|
-
];
|
|
568
|
+
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
|
|
560
569
|
const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) => plan.pieces.map((piece) => cargoTargetDependency(projectName, {
|
|
561
570
|
projectName: plan.package.projectName,
|
|
562
571
|
targetName: piece.targetName,
|
|
@@ -574,7 +583,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
574
583
|
targets['cargo-lint'] = {
|
|
575
584
|
executor: 'nx:run-commands',
|
|
576
585
|
cache: true,
|
|
577
|
-
inputs:
|
|
586
|
+
inputs: workspaceCargoInputs,
|
|
578
587
|
outputs: [],
|
|
579
588
|
options: {
|
|
580
589
|
commands: ['cargo fmt --all --check', CARGO_LINT_CLIPPY_COMMAND],
|
|
@@ -613,7 +622,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
613
622
|
targets[CARGO_CROSS_LINT_TARGET] = {
|
|
614
623
|
executor: 'nx:run-commands',
|
|
615
624
|
cache: true,
|
|
616
|
-
inputs:
|
|
625
|
+
inputs: workspaceCargoInputs,
|
|
617
626
|
outputs: [],
|
|
618
627
|
options: {
|
|
619
628
|
command: CARGO_CROSS_LINT_COMMAND,
|
package/package.json
CHANGED
package/src/index.test.ts
CHANGED
|
@@ -395,6 +395,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
395
395
|
expect(targets[name]?.dependsOn).toContain('cargo-fetch');
|
|
396
396
|
}
|
|
397
397
|
expect(targets['cargo-sweep']?.dependsOn).toBeUndefined();
|
|
398
|
+
// The archive and the compile it stands for hash every crate's sources
|
|
399
|
+
// AND the outputs of the targets they depend on: generated crate inputs
|
|
400
|
+
// are gitignored, so a repository that had to restate `inputs` to add
|
|
401
|
+
// them replaced the crate union with the root's `default` and shipped a
|
|
402
|
+
// stale archive to every per-crate test.
|
|
403
|
+
for (const name of ['cargo-test-compile', 'cargo-test-archive', 'cargo-lint', CARGO_CROSS_LINT_TARGET]) {
|
|
404
|
+
const inputs = targets[name]?.inputs ?? [];
|
|
405
|
+
expect(inputs).toContainEqual({ dependentTasksOutputFiles: '**/*', transitive: false });
|
|
406
|
+
expect(inputs).toContain('{projectRoot}/crates/ferris-core/**/*');
|
|
407
|
+
}
|
|
398
408
|
expect(targets['cargo-test-compile']?.executor).toBe('nx:run-commands');
|
|
399
409
|
expect(targets['cargo-test-compile']?.cache).toBe(false);
|
|
400
410
|
expect(targets['cargo-test-compile']?.outputs).toEqual([]);
|
package/src/index.ts
CHANGED
|
@@ -688,17 +688,26 @@ async function createProjectTargets(
|
|
|
688
688
|
).flat(),
|
|
689
689
|
),
|
|
690
690
|
];
|
|
691
|
-
|
|
691
|
+
// Generated crate sources (wire codecs, vocabularies, fixtures) are
|
|
692
|
+
// gitignored and invisible to nx's file hasher; they reach these targets
|
|
693
|
+
// as the outputs of the targets a repository adds to `dependsOn`. Hashing
|
|
694
|
+
// those outputs here means a repository never has to restate `inputs` to
|
|
695
|
+
// add them - and a restated `inputs` REPLACES this union with the root
|
|
696
|
+
// project's `default`, which owns no crate file, so the archive then
|
|
697
|
+
// cache-hits against edited crates while every per-crate test reruns on
|
|
698
|
+
// the stale binary. That verdict is wrong, not merely slow.
|
|
699
|
+
const workspaceCargoInputs: TargetConfiguration['inputs'] = [
|
|
700
|
+
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
701
|
+
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
702
|
+
];
|
|
703
|
+
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
692
704
|
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(
|
|
693
705
|
cargoWorkspaceRoot,
|
|
694
706
|
nextestToolConfigArg(workspaceRoot, cargoWorkspaceRoot, PLUGIN_NEXTEST_CONFIG),
|
|
695
707
|
);
|
|
696
708
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
697
709
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
698
|
-
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [
|
|
699
|
-
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
700
|
-
`{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
|
|
701
|
-
];
|
|
710
|
+
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
|
|
702
711
|
const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) =>
|
|
703
712
|
plan.pieces.map((piece) =>
|
|
704
713
|
cargoTargetDependency(projectName, {
|
|
@@ -720,7 +729,7 @@ async function createProjectTargets(
|
|
|
720
729
|
targets['cargo-lint'] = {
|
|
721
730
|
executor: 'nx:run-commands',
|
|
722
731
|
cache: true,
|
|
723
|
-
inputs:
|
|
732
|
+
inputs: workspaceCargoInputs,
|
|
724
733
|
outputs: [],
|
|
725
734
|
options: {
|
|
726
735
|
commands: ['cargo fmt --all --check', CARGO_LINT_CLIPPY_COMMAND],
|
|
@@ -759,7 +768,7 @@ async function createProjectTargets(
|
|
|
759
768
|
targets[CARGO_CROSS_LINT_TARGET] = {
|
|
760
769
|
executor: 'nx:run-commands',
|
|
761
770
|
cache: true,
|
|
762
|
-
inputs:
|
|
771
|
+
inputs: workspaceCargoInputs,
|
|
763
772
|
outputs: [],
|
|
764
773
|
options: {
|
|
765
774
|
command: CARGO_CROSS_LINT_COMMAND,
|