@smoothbricks/nx-plugin 0.4.25 → 0.4.27
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 +1078 -98
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +16 -85
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +16 -17
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +37 -44
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +50 -8
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +691 -71
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +108 -12
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +299 -18
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +213 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +624 -177
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +435 -230
- package/dist/managed-assets.d.ts +6 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.js +3 -2
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -1
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -62
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +607 -17
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +1009 -118
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -75
- package/package.json +75 -13
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo-process.ts +286 -0
- package/src/__tests__/counted-cargo.ts +730 -0
- package/src/__tests__/fixture-cargo-home.ts +36 -0
- package/src/__tests__/fixture-nx-env.ts +157 -2
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +17 -86
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -22
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +432 -62
- package/src/cargo-closure-input.ts +51 -57
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +1044 -0
- package/src/cargo-source-hash.test.ts +203 -93
- package/src/cargo-source-hash.ts +762 -75
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +344 -18
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1043 -483
- package/src/ensure-built.ts +870 -197
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +1070 -360
- package/src/index.ts +524 -255
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-assets.ts +12 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +3 -2
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +495 -0
- package/src/nx-cache-bound.test.ts +109 -0
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +112 -0
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +99 -0
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +181 -0
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -1
- package/test-timings.json +85 -28
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
- package/src/__tests__/in-process-nx-index.ts +0 -9
package/src/index.test.ts
CHANGED
|
@@ -1,181 +1,82 @@
|
|
|
1
1
|
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { chmod, mkdir, mkdtemp, readdir, readFile, rm, symlink, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { chmod, mkdir, mkdtemp, readdir, readFile, realpath, rm, symlink, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
import type {
|
|
6
|
+
import { isEslintFileSet } from '@smoothbricks/nx-plugin/eslint-file-set';
|
|
7
|
+
import type {
|
|
8
|
+
CreateNodesContextV2,
|
|
9
|
+
CreateNodesV2,
|
|
10
|
+
ProjectGraph,
|
|
11
|
+
ProjectGraphProjectNode,
|
|
12
|
+
TargetConfiguration,
|
|
13
|
+
} from 'nx/src/devkit-exports.js';
|
|
14
|
+
import { WorkspaceContext } from 'nx/src/native/index.js';
|
|
8
15
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
9
16
|
import { createTargetDefaultsResults } from 'nx/src/project-graph/utils/project-configuration/target-defaults.js';
|
|
10
17
|
import { mergeTargetConfigurations } from 'nx/src/project-graph/utils/project-configuration-utils.js';
|
|
11
|
-
import {
|
|
18
|
+
import { createTaskGraph } from 'nx/src/tasks-runner/create-task-graph.js';
|
|
19
|
+
import { getOutputsForTargetAndConfiguration } from 'nx/src/tasks-runner/utils.js';
|
|
20
|
+
import { resetWorkspaceContext } from 'nx/src/utils/workspace-context.js';
|
|
21
|
+
import { useFixtureCargoHome } from './__tests__/fixture-cargo-home.js';
|
|
22
|
+
import { runtimeInputValue } from './__tests__/runtime-input.js';
|
|
23
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
24
|
+
import { CARGO_CLOSURE_INPUT } from './cargo-closure-input.js';
|
|
12
25
|
import { exceptionalTestFilter, packageNameFromCargoTestTarget } from './cargo-workspace.js';
|
|
13
26
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_LINT_CLIPPY_COMMAND } from './cross-check-policy.js';
|
|
14
|
-
import { createNodesV2, createNodesV2ForPlatform } from './index.js';
|
|
27
|
+
import { cargoCommandNpmPackages, createNodesV2, createNodesV2ForPlatform } from './index.js';
|
|
28
|
+
import { NEXTEST_EXTRACTION_DIRECTORY } from './nextest-extraction.js';
|
|
15
29
|
import { applyWorkspaceConfig, RELEASE_CONFIGURATION } from './workspace-config-policy.js';
|
|
16
30
|
|
|
17
|
-
|
|
31
|
+
useFixtureCargoHome();
|
|
18
32
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(root, 'node_modules'), 'dir');
|
|
26
|
-
await workspace.write('package.json', '{"name":"lint-workspace","private":true,"workspaces":["packages/*"]}\n');
|
|
27
|
-
await workspace.write(
|
|
28
|
-
'nx.json',
|
|
29
|
-
JSON.stringify({
|
|
30
|
-
plugins: [fileURLToPath(new URL('../dist/index.js', import.meta.url))],
|
|
31
|
-
namedInputs: { default: ['{projectRoot}/**/*'] },
|
|
32
|
-
targetDefaults: { lint: { cache: true } },
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
await workspace.write(
|
|
36
|
-
'biome.json',
|
|
37
|
-
'{"formatter":{"enabled":false},"linter":{"rules":{"suspicious":{"noDebugger":"off"}}}}\n',
|
|
38
|
-
);
|
|
39
|
-
await workspace.write(
|
|
40
|
-
'eslint.config.mjs',
|
|
41
|
-
'export default [{ files: ["**/*.{js,ts}"], rules: { "no-debugger": "error" } }];\n',
|
|
42
|
-
);
|
|
43
|
-
await workspace.write('Cargo.toml', '[workspace]\nmembers = ["packages/rust"]\nresolver = "2"\n');
|
|
44
|
-
await workspace.write('Cargo.lock', 'version = 4\n\n[[package]]\nname = "lint-crate"\nversion = "0.1.0"\n');
|
|
45
|
-
await workspace.write('packages/rust/package.json', '{"name":"rust-fixture"}\n');
|
|
46
|
-
await workspace.write(
|
|
47
|
-
'packages/rust/Cargo.toml',
|
|
48
|
-
'[package]\nname = "lint-crate"\nversion = "0.1.0"\nedition = "2021"\n',
|
|
49
|
-
);
|
|
50
|
-
await workspace.write('packages/rust/src/lib.rs', 'pub fn answer() -> u32 {\n 42\n}\n');
|
|
51
|
-
const runLint = async () => {
|
|
52
|
-
const child = Bun.spawn(['bun', join(repositoryRoot, 'node_modules/.bin/nx'), 'run', 'rust-fixture:lint'], {
|
|
53
|
-
cwd: root,
|
|
54
|
-
env: {
|
|
55
|
-
...process.env,
|
|
56
|
-
PATH: `${join(repositoryRoot, 'node_modules/.bin')}:${process.env.PATH ?? ''}`,
|
|
57
|
-
NX_DAEMON: 'false',
|
|
58
|
-
NX_ISOLATE_PLUGINS: 'false',
|
|
59
|
-
NX_WORKSPACE_DATA_DIRECTORY: join(root, '.nx/workspace-data'),
|
|
60
|
-
NX_CACHE_DIRECTORY: join(root, '.nx/cache'),
|
|
61
|
-
RUSTC_WRAPPER: '',
|
|
62
|
-
RUSTC_WORKSPACE_WRAPPER: '',
|
|
63
|
-
},
|
|
64
|
-
stdout: 'pipe',
|
|
65
|
-
stderr: 'pipe',
|
|
66
|
-
});
|
|
67
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
68
|
-
child.exited,
|
|
69
|
-
new Response(child.stdout).text(),
|
|
70
|
-
new Response(child.stderr).text(),
|
|
71
|
-
]);
|
|
72
|
-
return { exitCode, output: stdout + stderr };
|
|
73
|
-
};
|
|
74
|
-
const rustOnly = await runLint();
|
|
75
|
-
expect(rustOnly).toMatchObject({ exitCode: 0 });
|
|
76
|
-
expect(rustOnly.output).toContain('cargo-lint');
|
|
77
|
-
await workspace.write('packages/rust/src/check.js', 'debugger;\n');
|
|
78
|
-
const withJavaScript = await runLint();
|
|
79
|
-
expect(withJavaScript.exitCode).not.toBe(0);
|
|
80
|
-
expect(withJavaScript.output).toContain('no-debugger');
|
|
81
|
-
await workspace.write(
|
|
82
|
-
'packages/rust/package.json',
|
|
83
|
-
JSON.stringify({
|
|
84
|
-
name: 'rust-fixture',
|
|
85
|
-
nx: { targets: { lint: { executor: 'nx:run-commands', options: { command: 'printf explicit-lint' } } } },
|
|
86
|
-
}),
|
|
87
|
-
);
|
|
88
|
-
const overridden = await runLint();
|
|
89
|
-
expect(overridden).toMatchObject({ exitCode: 0 });
|
|
90
|
-
expect(overridden.output).toContain('explicit-lint');
|
|
91
|
-
} finally {
|
|
92
|
-
await workspace.cleanup();
|
|
93
|
-
}
|
|
94
|
-
}, 120_000);
|
|
33
|
+
const [, rawInferTargets] = createNodesV2;
|
|
34
|
+
const inferTargets: typeof rawInferTargets = async (files, options, context) => {
|
|
35
|
+
await prepareCargoFixture(context.workspaceRoot);
|
|
36
|
+
return rawInferTargets(files, options, context);
|
|
37
|
+
};
|
|
95
38
|
|
|
96
|
-
|
|
39
|
+
describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
40
|
+
it('never lets a cache hit on the build aggregate restore its children’s dist', async () => {
|
|
97
41
|
const workspace = await createWorkspace();
|
|
98
|
-
|
|
99
|
-
|
|
42
|
+
// The emitter keys on one input outside its project, as a transform or toolchain does. The
|
|
43
|
+
// aggregate hashes only the project, so a toolchain change moves the emitter's key and not the
|
|
44
|
+
// aggregate's: the aggregate replays from cache right after the emitter reran.
|
|
45
|
+
const emit: TargetConfiguration = {
|
|
46
|
+
executor: 'nx:run-commands',
|
|
47
|
+
cache: true,
|
|
48
|
+
inputs: ['{projectRoot}/source.txt', '{workspaceRoot}/toolchain.txt'],
|
|
49
|
+
outputs: ['{projectRoot}/dist'],
|
|
50
|
+
options: { command: 'mkdir -p dist && cat source.txt ../../toolchain.txt > dist/app.js', cwd: '{projectRoot}' },
|
|
51
|
+
};
|
|
52
|
+
const declared = { 'emit-js': emit };
|
|
100
53
|
try {
|
|
101
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(root, 'node_modules'), 'dir');
|
|
102
|
-
await workspace.write(
|
|
103
|
-
'package.json',
|
|
104
|
-
'{"name":"aggregate-workspace","private":true,"workspaces":["packages/*"]}\n',
|
|
105
|
-
);
|
|
106
|
-
await workspace.write(
|
|
107
|
-
'nx.json',
|
|
108
|
-
JSON.stringify({
|
|
109
|
-
plugins: [fileURLToPath(new URL('../dist/index.js', import.meta.url))],
|
|
110
|
-
namedInputs: { default: ['{projectRoot}/**/*'] },
|
|
111
|
-
}),
|
|
112
|
-
);
|
|
113
|
-
// Emitted artifacts are not sources, so the aggregate's own inputs never see them.
|
|
114
|
-
await workspace.write('.gitignore', 'dist\n.nx\nnode_modules\n');
|
|
115
|
-
await workspace.write('toolchain.txt', 'toolchain-1\n');
|
|
116
|
-
await workspace.write('packages/app/source.txt', 'source\n');
|
|
117
|
-
// The emitter keys on one input outside its project, as a transform or
|
|
118
|
-
// toolchain does. The inferred `build` aggregate hashes only the project,
|
|
119
|
-
// so a toolchain change moves the emitter's key and not the aggregate's.
|
|
120
54
|
await workspace.write(
|
|
121
55
|
'packages/app/package.json',
|
|
122
|
-
JSON.stringify({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
}),
|
|
140
|
-
);
|
|
141
|
-
const build = async () => {
|
|
142
|
-
const child = Bun.spawn(['bun', join(repositoryRoot, 'node_modules/.bin/nx'), 'run', 'app:build'], {
|
|
143
|
-
cwd: root,
|
|
144
|
-
env: {
|
|
145
|
-
...process.env,
|
|
146
|
-
PATH: `${join(repositoryRoot, 'node_modules/.bin')}:${process.env.PATH ?? ''}`,
|
|
147
|
-
NX_DAEMON: 'false',
|
|
148
|
-
NX_ISOLATE_PLUGINS: 'false',
|
|
149
|
-
NX_WORKSPACE_DATA_DIRECTORY: join(root, '.nx/workspace-data'),
|
|
150
|
-
NX_CACHE_DIRECTORY: join(root, '.nx/cache'),
|
|
151
|
-
},
|
|
152
|
-
stdout: 'pipe',
|
|
153
|
-
stderr: 'pipe',
|
|
154
|
-
});
|
|
155
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
156
|
-
child.exited,
|
|
157
|
-
new Response(child.stdout).text(),
|
|
158
|
-
new Response(child.stderr).text(),
|
|
159
|
-
]);
|
|
160
|
-
return { exitCode, output: stdout + stderr };
|
|
56
|
+
JSON.stringify({ name: 'app', private: true, nx: { targets: declared } }),
|
|
57
|
+
);
|
|
58
|
+
const targets = await inferProjectTargets(workspace, 'packages/app/package.json');
|
|
59
|
+
const build = resolveDeclaredOverInferred(targets, declared, 'build');
|
|
60
|
+
expect(build?.dependsOn).toContain('emit-js');
|
|
61
|
+
expect(build?.cache).toBe(true);
|
|
62
|
+
if (build === undefined) throw new Error('app infers no build aggregate over emit-js');
|
|
63
|
+
|
|
64
|
+
// A replay restores exactly what Nx resolves as the task's outputs. Left without `outputs`, a
|
|
65
|
+
// `build` target gets Nx's legacy defaults, `{projectRoot}/dist` among them, and the replay
|
|
66
|
+
// puts back the dist the emitter wrote on the run that last produced the aggregate's key.
|
|
67
|
+
const app: ProjectGraphProjectNode = {
|
|
68
|
+
name: 'app',
|
|
69
|
+
type: 'lib',
|
|
70
|
+
data: { root: 'packages/app', targets: { build, 'emit-js': emit } },
|
|
161
71
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
expect(await artifact()).toBe('source\ntoolchain-1\n');
|
|
167
|
-
|
|
168
|
-
await workspace.write('toolchain.txt', 'toolchain-2\n');
|
|
169
|
-
const second = await build();
|
|
170
|
-
expect(second.exitCode, second.output).toBe(0);
|
|
171
|
-
// The emitter reran on its new key. The aggregate's key did not move, so
|
|
172
|
-
// it replays from cache — and a replay must not put back the dist it
|
|
173
|
-
// would have claimed on the first run.
|
|
174
|
-
expect(await artifact(), second.output).toBe('source\ntoolchain-2\n');
|
|
72
|
+
expect(getOutputsForTargetAndConfiguration({ project: 'app', target: 'build' }, {}, app)).toEqual([]);
|
|
73
|
+
expect(getOutputsForTargetAndConfiguration({ project: 'app', target: 'emit-js' }, {}, app)).toEqual([
|
|
74
|
+
'packages/app/dist',
|
|
75
|
+
]);
|
|
175
76
|
} finally {
|
|
176
77
|
await workspace.cleanup();
|
|
177
78
|
}
|
|
178
|
-
}
|
|
79
|
+
});
|
|
179
80
|
|
|
180
81
|
it('names standalone package projects from package metadata', async () => {
|
|
181
82
|
const workspace = await createWorkspace();
|
|
@@ -252,6 +153,63 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
252
153
|
}
|
|
253
154
|
});
|
|
254
155
|
|
|
156
|
+
it('keys installed patch data and pins without keying patch documentation', async () => {
|
|
157
|
+
const workspace = await createWorkspace();
|
|
158
|
+
try {
|
|
159
|
+
await workspace.write('packages/example/package.json', '{"name":"example","scripts":{"test":"bun test"}}\n');
|
|
160
|
+
await workspace.write('packages/example/tsconfig.lib.json', '{}\n');
|
|
161
|
+
await workspace.write('packages/example/tsconfig.test.json', '{}\n');
|
|
162
|
+
await workspace.write('patches/nx.patch', 'patch-one\n');
|
|
163
|
+
await workspace.write('patches/compiler/PIN', 'revision-one\n');
|
|
164
|
+
await workspace.write('patches/compiler/VERSION', 'version-one\n');
|
|
165
|
+
await workspace.write('patches/README.md', 'documentation-one\n');
|
|
166
|
+
await workspace.write('patches/compiler/notes.md', 'nested documentation-one\n');
|
|
167
|
+
await workspace.write('packages/unrelated/source.ts', 'export const value = 1;\n');
|
|
168
|
+
const targets = await inferProjectTargets(workspace, 'packages/example/package.json');
|
|
169
|
+
const context = new WorkspaceContext(
|
|
170
|
+
workspace.context.workspaceRoot,
|
|
171
|
+
join(workspace.context.workspaceRoot, '.nx/patch-input-context'),
|
|
172
|
+
);
|
|
173
|
+
for (const name of ['tsc-js', 'typecheck', 'typecheck-tests', 'lint']) {
|
|
174
|
+
const inputs = targets[name]?.inputs ?? [];
|
|
175
|
+
const patchInputs = inputs.filter(
|
|
176
|
+
(input): input is string => typeof input === 'string' && input.includes('{workspaceRoot}/patches/'),
|
|
177
|
+
);
|
|
178
|
+
expect(patchInputs.length).toBeGreaterThan(0);
|
|
179
|
+
const positive = patchInputs
|
|
180
|
+
.filter((input) => !input.startsWith('!'))
|
|
181
|
+
.map((input) => input.slice('{workspaceRoot}/'.length));
|
|
182
|
+
const negative = patchInputs
|
|
183
|
+
.filter((input) => input.startsWith('!'))
|
|
184
|
+
.map((input) => input.slice('!{workspaceRoot}/'.length));
|
|
185
|
+
expect(context.glob(positive, negative).sort()).toEqual([
|
|
186
|
+
'patches/compiler/PIN',
|
|
187
|
+
'patches/compiler/VERSION',
|
|
188
|
+
'patches/nx.patch',
|
|
189
|
+
]);
|
|
190
|
+
const before = context.hashFilesMatchingGlob(positive, negative);
|
|
191
|
+
await workspace.write('patches/README.md', name + ' docs\n');
|
|
192
|
+
await workspace.write('patches/compiler/notes.md', name + ' nested docs\n');
|
|
193
|
+
await workspace.write('packages/unrelated/source.ts', 'export const value = ' + name.length + ';\n');
|
|
194
|
+
context.incrementalUpdate(
|
|
195
|
+
['patches/README.md', 'patches/compiler/notes.md', 'packages/unrelated/source.ts'],
|
|
196
|
+
[],
|
|
197
|
+
);
|
|
198
|
+
expect(context.hashFilesMatchingGlob(positive, negative)).toBe(before);
|
|
199
|
+
let previous = before;
|
|
200
|
+
for (const file of ['patches/nx.patch', 'patches/compiler/PIN', 'patches/compiler/VERSION']) {
|
|
201
|
+
await workspace.write(file, name + ' changed ' + file + '\n');
|
|
202
|
+
context.incrementalUpdate([file], []);
|
|
203
|
+
const changed = context.hashFilesMatchingGlob(positive, negative);
|
|
204
|
+
expect(changed).not.toBe(previous);
|
|
205
|
+
previous = changed;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
} finally {
|
|
209
|
+
await workspace.cleanup();
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
255
213
|
it('uses the transformer-aware compiler for emit and validation', async () => {
|
|
256
214
|
const workspace = await createWorkspace();
|
|
257
215
|
try {
|
|
@@ -274,6 +232,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
274
232
|
'{workspaceRoot}/package.json',
|
|
275
233
|
'{workspaceRoot}/bun.lock',
|
|
276
234
|
'{workspaceRoot}/patches/**/*',
|
|
235
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
277
236
|
'{workspaceRoot}/tsconfig.base.json',
|
|
278
237
|
];
|
|
279
238
|
// An emit is a shipped artifact: it hashes the raw manifests, so a
|
|
@@ -285,20 +244,28 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
285
244
|
'{projectRoot}/tsconfig.lib.json',
|
|
286
245
|
]);
|
|
287
246
|
expect(targets['tsc-js']?.outputs).toEqual(['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}']);
|
|
247
|
+
// Typecheck runs the compiler devenv.smoo.nix pins (SMOO_TYPECHECK_TSC) itself, not through
|
|
248
|
+
// ttsc, whose auto-loaded transform plugins would check with their own compiler; and it refuses
|
|
249
|
+
// to fall back to another when the shell does not provide it.
|
|
250
|
+
const typecheckCompiler =
|
|
251
|
+
'"${SMOO_TYPECHECK_TSC:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}"';
|
|
288
252
|
expect(targets.typecheck?.options).toMatchObject({
|
|
289
|
-
command:
|
|
253
|
+
command: `${typecheckCompiler} -p tsconfig.lib.json --noEmit`,
|
|
290
254
|
cwd: 'packages/example',
|
|
291
255
|
});
|
|
292
256
|
const checkToolchainInputs = [
|
|
293
257
|
'{workspaceRoot}/patches/**/*',
|
|
258
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
294
259
|
'{workspaceRoot}/tsconfig.base.json',
|
|
295
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
260
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
296
261
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
297
262
|
];
|
|
263
|
+
// The compiler's store path names its pinned revision, so a compiler bump misses the cache.
|
|
298
264
|
expect(targets.typecheck?.inputs).toEqual([
|
|
299
265
|
'versionlessProduction',
|
|
300
266
|
'^production',
|
|
301
267
|
...checkToolchainInputs,
|
|
268
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
302
269
|
'{projectRoot}/tsconfig.lib.json',
|
|
303
270
|
]);
|
|
304
271
|
expect(targets.build?.executor).toBe('nx:noop');
|
|
@@ -311,20 +278,21 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
311
278
|
expect(targets['typecheck-tests']?.cache).toBe(true);
|
|
312
279
|
expect(targets['typecheck-tests']?.dependsOn).toEqual(['tsc-js', 'typecheck']);
|
|
313
280
|
expect(targets['typecheck-tests']?.options).toMatchObject({
|
|
314
|
-
command:
|
|
281
|
+
command: `${typecheckCompiler} -p tsconfig.test.json --noEmit`,
|
|
315
282
|
cwd: 'packages/example',
|
|
316
283
|
});
|
|
317
284
|
expect(targets['typecheck-tests']?.inputs).toEqual([
|
|
318
285
|
'versionlessDefault',
|
|
319
286
|
'^production',
|
|
320
287
|
...checkToolchainInputs,
|
|
288
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
321
289
|
'{projectRoot}/tsconfig.test.json',
|
|
322
290
|
]);
|
|
323
291
|
|
|
324
292
|
expect(targets['typecheck-tests:watch']?.executor).toBe('nx:run-commands');
|
|
325
293
|
expect(targets['typecheck-tests:watch']?.continuous).toBe(true);
|
|
326
294
|
expect(targets['typecheck-tests:watch']?.options).toMatchObject({
|
|
327
|
-
command:
|
|
295
|
+
command: `${typecheckCompiler} -p tsconfig.test.json --noEmit --watch`,
|
|
328
296
|
cwd: 'packages/example',
|
|
329
297
|
});
|
|
330
298
|
|
|
@@ -338,6 +306,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
338
306
|
|
|
339
307
|
expect(targets.lint?.cache).toBe(true);
|
|
340
308
|
expect(targets.lint?.dependsOn).toEqual(['typecheck-tests']);
|
|
309
|
+
expect(targets.lint?.inputs).toContain('^production');
|
|
341
310
|
} finally {
|
|
342
311
|
await workspace.cleanup();
|
|
343
312
|
}
|
|
@@ -356,10 +325,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
356
325
|
const targets = project?.targets ?? {};
|
|
357
326
|
const checkToolchain = [
|
|
358
327
|
'{workspaceRoot}/patches/**/*',
|
|
328
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
359
329
|
'{workspaceRoot}/tsconfig.base.json',
|
|
360
330
|
// Hashed by Nx itself: a `json` input costs no process, and neither
|
|
361
331
|
// does the crate digest that replaces the manifests below.
|
|
362
|
-
|
|
332
|
+
// The root manifest's scripts, smoo and nx sections are read by no check: an
|
|
333
|
+
// edit to a script or a developer link must not re-key every lint and typecheck.
|
|
334
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
363
335
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
364
336
|
];
|
|
365
337
|
|
|
@@ -381,16 +353,19 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
381
353
|
'versionlessProduction',
|
|
382
354
|
{ input: 'versionlessProduction', dependencies: true },
|
|
383
355
|
...checkToolchain,
|
|
356
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
384
357
|
'{projectRoot}/tsconfig.lib.json',
|
|
385
358
|
]);
|
|
386
359
|
expect(targets['typecheck-tests']?.inputs).toEqual([
|
|
387
360
|
'versionlessDefault',
|
|
388
361
|
{ input: 'versionlessProduction', dependencies: true },
|
|
389
362
|
...checkToolchain,
|
|
363
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
390
364
|
'{projectRoot}/tsconfig.test.json',
|
|
391
365
|
]);
|
|
392
366
|
expect(targets.lint?.inputs).toEqual([
|
|
393
367
|
'versionlessDefault',
|
|
368
|
+
{ input: 'versionlessProduction', dependencies: true },
|
|
394
369
|
...checkToolchain,
|
|
395
370
|
...[
|
|
396
371
|
'biome.json',
|
|
@@ -416,6 +391,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
416
391
|
'{workspaceRoot}/package.json',
|
|
417
392
|
'{workspaceRoot}/bun.lock',
|
|
418
393
|
'{workspaceRoot}/patches/**/*',
|
|
394
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
419
395
|
'{workspaceRoot}/tsconfig.base.json',
|
|
420
396
|
'{projectRoot}/tsconfig.lib.json',
|
|
421
397
|
]);
|
|
@@ -478,9 +454,11 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
478
454
|
'versionlessProduction',
|
|
479
455
|
'^production',
|
|
480
456
|
'{workspaceRoot}/patches/**/*',
|
|
457
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
481
458
|
'{workspaceRoot}/tsconfig.base.json',
|
|
482
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
459
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
483
460
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
461
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
484
462
|
'{projectRoot}/tsconfig.lib.json',
|
|
485
463
|
]);
|
|
486
464
|
} finally {
|
|
@@ -515,20 +493,23 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
515
493
|
];
|
|
516
494
|
const checkToolchain = [
|
|
517
495
|
'{workspaceRoot}/patches/**/*',
|
|
496
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
518
497
|
...configChain,
|
|
519
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
498
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
520
499
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
521
500
|
];
|
|
522
501
|
expect(targets.typecheck?.inputs).toEqual([
|
|
523
502
|
'versionlessProduction',
|
|
524
503
|
'^production',
|
|
525
504
|
...checkToolchain,
|
|
505
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
526
506
|
'{projectRoot}/tsconfig.lib.json',
|
|
527
507
|
]);
|
|
528
508
|
expect(targets['typecheck-tests']?.inputs).toEqual([
|
|
529
509
|
'versionlessDefault',
|
|
530
510
|
'^production',
|
|
531
511
|
...checkToolchain,
|
|
512
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
532
513
|
'{projectRoot}/tsconfig.test.json',
|
|
533
514
|
]);
|
|
534
515
|
// An emit reads the same options, and a stale artifact is worse than a
|
|
@@ -539,6 +520,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
539
520
|
'{workspaceRoot}/package.json',
|
|
540
521
|
'{workspaceRoot}/bun.lock',
|
|
541
522
|
'{workspaceRoot}/patches/**/*',
|
|
523
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
542
524
|
...configChain,
|
|
543
525
|
'{projectRoot}/tsconfig.lib.json',
|
|
544
526
|
]);
|
|
@@ -602,11 +584,13 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
602
584
|
'versionlessProduction',
|
|
603
585
|
'^production',
|
|
604
586
|
'{workspaceRoot}/patches/**/*',
|
|
587
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
605
588
|
'{workspaceRoot}/tsconfig.base.json',
|
|
606
589
|
'{workspaceRoot}/packages/example/tsconfig.cycle.json',
|
|
607
590
|
'{workspaceRoot}/packages/example/tsconfig.lib.json',
|
|
608
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
591
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
609
592
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
593
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
610
594
|
'{projectRoot}/tsconfig.lib.json',
|
|
611
595
|
]);
|
|
612
596
|
expect(JSON.stringify(inputs)).not.toContain('node_modules');
|
|
@@ -645,10 +629,12 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
645
629
|
'versionlessProduction',
|
|
646
630
|
'^production',
|
|
647
631
|
'{workspaceRoot}/patches/**/*',
|
|
632
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
648
633
|
'{workspaceRoot}/tsconfig.base.json',
|
|
649
634
|
'{workspaceRoot}/packages/tsconfig/base.json',
|
|
650
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
635
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
651
636
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
637
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
652
638
|
'{projectRoot}/tsconfig.lib.json',
|
|
653
639
|
]);
|
|
654
640
|
expect(stderr).toBe('');
|
|
@@ -681,9 +667,11 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
681
667
|
'versionlessProduction',
|
|
682
668
|
'^production',
|
|
683
669
|
'{workspaceRoot}/patches/**/*',
|
|
670
|
+
'!{workspaceRoot}/patches/**/*.md',
|
|
684
671
|
'{workspaceRoot}/tsconfig.base.json',
|
|
685
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
672
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
686
673
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
674
|
+
{ env: 'SMOO_TYPECHECK_TSC' },
|
|
687
675
|
'{projectRoot}/tsconfig.lib.json',
|
|
688
676
|
]);
|
|
689
677
|
} finally {
|
|
@@ -729,6 +717,42 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
729
717
|
}
|
|
730
718
|
});
|
|
731
719
|
|
|
720
|
+
it('makes lint check that the timing manifest names every file a timings-sharded Bun suite runs', async () => {
|
|
721
|
+
const workspace = await createWorkspace();
|
|
722
|
+
try {
|
|
723
|
+
const shard = (n: number) => ({
|
|
724
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
725
|
+
options: { command: `bun test --timings=test-timings.json --shard=${n}/2`, cwd: '{projectRoot}' },
|
|
726
|
+
});
|
|
727
|
+
await workspace.write(
|
|
728
|
+
'packages/sharded/package.json',
|
|
729
|
+
JSON.stringify({ name: 'sharded', nx: { targets: { 'test-a': shard(1), 'test-b': shard(2) } } }),
|
|
730
|
+
);
|
|
731
|
+
await workspace.write(
|
|
732
|
+
'packages/counted/package.json',
|
|
733
|
+
JSON.stringify({
|
|
734
|
+
name: 'counted',
|
|
735
|
+
nx: { targets: { 'test-a': { options: { command: 'bun test --shard=1/1', cwd: '{projectRoot}' } } } },
|
|
736
|
+
}),
|
|
737
|
+
);
|
|
738
|
+
|
|
739
|
+
const sharded = await inferProjectTargets(workspace, 'packages/sharded/package.json');
|
|
740
|
+
const counted = await inferProjectTargets(workspace, 'packages/counted/package.json');
|
|
741
|
+
|
|
742
|
+
expect(sharded['shard-timings']).toEqual({
|
|
743
|
+
executor: '@smoothbricks/nx-plugin:shard-timings',
|
|
744
|
+
cache: false,
|
|
745
|
+
outputs: [],
|
|
746
|
+
options: { cwd: 'packages/sharded', args: ['--timings=test-timings.json'] },
|
|
747
|
+
});
|
|
748
|
+
expect(sharded.lint?.dependsOn).toEqual(['shard-timings']);
|
|
749
|
+
expect(counted['shard-timings']).toBeUndefined();
|
|
750
|
+
expect(counted.lint).toBeUndefined();
|
|
751
|
+
} finally {
|
|
752
|
+
await workspace.cleanup();
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
|
|
732
756
|
it('infers aggregate build for package-local output targets without owning them', async () => {
|
|
733
757
|
const workspace = await createWorkspace();
|
|
734
758
|
try {
|
|
@@ -841,11 +865,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
841
865
|
expect(targets['cargo-fetch']?.options).toEqual({
|
|
842
866
|
commands: ['cargo fetch --locked'],
|
|
843
867
|
cwd: 'packages/ferris',
|
|
844
|
-
parallel: false,
|
|
845
868
|
});
|
|
846
|
-
// Every frozen cargo command carries the edge
|
|
847
|
-
//
|
|
848
|
-
// needs the locked graph downloaded whether or not the chain runs first.
|
|
869
|
+
// Every frozen cargo command carries the edge: offline cargo fails at
|
|
870
|
+
// resolution, so each one needs the locked graph downloaded before it runs.
|
|
849
871
|
for (const name of [
|
|
850
872
|
'cargo-test-compile',
|
|
851
873
|
'cargo-test-archive',
|
|
@@ -881,18 +903,21 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
881
903
|
// builds, re-resolves features, or writes cargo's flocked `target/`.
|
|
882
904
|
expect(targets['cargo-test-archive']?.executor).toBe('nx:run-commands');
|
|
883
905
|
expect(targets['cargo-test-archive']?.cache).toBe(true);
|
|
884
|
-
expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/
|
|
885
|
-
expect(targets['cargo-test-archive']?.options).toMatchObject({ cwd: 'packages/ferris'
|
|
906
|
+
expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/.cache/nextest/archive.tar.zst']);
|
|
907
|
+
expect(targets['cargo-test-archive']?.options).toMatchObject({ cwd: 'packages/ferris' });
|
|
886
908
|
// nextest does not create the archive's parent directory and fails the
|
|
887
909
|
// whole build if it is missing (measured: "error writing to archive").
|
|
888
|
-
|
|
910
|
+
// The directory and the archive are ONE command, in the order the archive needs.
|
|
911
|
+
expect(targets['cargo-test-archive']?.options?.commands).toBeUndefined();
|
|
889
912
|
// `--tool-config-file`, never `--config-file`: the plugin's settings must
|
|
890
913
|
// sit UNDER the repository's `.config/nextest.toml`, which is the only
|
|
891
914
|
// place an `archive.include` for a cdylib or fixture can be declared.
|
|
892
915
|
// `$PWD` because tool config paths must be absolute and an absolute path
|
|
893
|
-
// in the command text would split one cache entry per checkout
|
|
894
|
-
|
|
895
|
-
|
|
916
|
+
// in the command text would split one cache entry per checkout; through
|
|
917
|
+
// the root `node_modules` link because the plugin's real location is a
|
|
918
|
+
// different number of `../` away from each checkout.
|
|
919
|
+
expect(String(targets['cargo-test-archive']?.options?.command)).toBe(
|
|
920
|
+
'mkdir -p .cache/nextest && cargo --frozen nextest archive --workspace --archive-file .cache/nextest/archive.tar.zst --user-config-file none --tool-config-file "smoo:$PWD/../../node_modules/@smoothbricks/nx-plugin/nextest.toml"',
|
|
896
921
|
);
|
|
897
922
|
expect(targets['cargo-test-archive']?.inputs).toContain('{projectRoot}/.config/nextest.toml');
|
|
898
923
|
// Tests compile the dev profile only. Nx forwards a run's configuration
|
|
@@ -912,7 +937,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
912
937
|
// moved tree). `--workspace` is not merely redundant here, nextest
|
|
913
938
|
// rejects it beside a reused build.
|
|
914
939
|
expect(targets['cargo-test-ferris-core']?.options?.command).toMatch(
|
|
915
|
-
/^extracted="\$\(node \.\.\/\.\.\/node_modules\/@smoothbricks\/nx-plugin\/dist\/bin\/smoo-nx-nextest-extract\.js
|
|
940
|
+
/^extracted="\$\(node \.\.\/\.\.\/node_modules\/@smoothbricks\/nx-plugin\/dist\/bin\/smoo-nx-nextest-extract\.js \.cache\/nextest\/archive\.tar\.zst\)" && cargo --frozen nextest run --binaries-metadata "\$extracted\/target\/nextest\/binaries-metadata\.json" --cargo-metadata "\$extracted\/target\/nextest\/cargo-metadata\.json" --target-dir-remap "\$extracted\/target" --workspace-remap \. -E 'package\(ferris-core\)' --no-fail-fast --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/\.\.\/\.\.\/node_modules\/@smoothbricks\/nx-plugin\/nextest\.toml"$/,
|
|
916
941
|
);
|
|
917
942
|
expect(targets['cargo-test-ferris-core']?.inputs).toContain(
|
|
918
943
|
'{workspaceRoot}/packages/ferris/.config/nextest.toml',
|
|
@@ -931,7 +956,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
931
956
|
// test compile: a directory of its own compiled every host unit twice.
|
|
932
957
|
const [fmt, clippy] = targets['cargo-lint']?.options?.commands ?? [];
|
|
933
958
|
expect(fmt).toBe('cargo fmt --all --check');
|
|
934
|
-
expect(clippy).
|
|
959
|
+
expect(clippy).toBe(CARGO_LINT_CLIPPY_COMMAND);
|
|
960
|
+
expect(clippy).toMatch(/^cargo --frozen clippy --workspace --all-targets /);
|
|
935
961
|
for (const command of [clippy, targets['cargo-test-compile']?.options?.command]) {
|
|
936
962
|
expect(command).not.toContain('--target-dir');
|
|
937
963
|
}
|
|
@@ -956,6 +982,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
956
982
|
expect(targets.mutation?.cache).toBe(false);
|
|
957
983
|
expect(targets.mutation?.options).toMatchObject({ command: 'cargo --frozen mutants --workspace' });
|
|
958
984
|
expect(targets.bench?.options).toMatchObject({ command: 'cargo --frozen bench --workspace' });
|
|
985
|
+
expectNoSchedulerThrottle(targets);
|
|
959
986
|
} finally {
|
|
960
987
|
await workspace.cleanup();
|
|
961
988
|
}
|
|
@@ -979,8 +1006,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
979
1006
|
expect(targets.clean?.cache).toBe(false);
|
|
980
1007
|
expect(targets.clean?.options?.outputs).toEqual([
|
|
981
1008
|
'{projectRoot}/dist',
|
|
1009
|
+
'{workspaceRoot}/packages/ferris/.cache/nextest',
|
|
982
1010
|
'{workspaceRoot}/packages/ferris/target/cargo-lint-cross',
|
|
983
|
-
'{workspaceRoot}/packages/ferris/target/nextest',
|
|
984
1011
|
]);
|
|
985
1012
|
} finally {
|
|
986
1013
|
await workspace.cleanup();
|
|
@@ -1018,11 +1045,18 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1018
1045
|
await workspace.write(`${root}/package.json`, '{"name":"ferris"}\n');
|
|
1019
1046
|
await workspace.write(`${root}/Cargo.toml`, '[workspace]\nmembers = ["crates/core"]\n');
|
|
1020
1047
|
await workspace.write(`${root}/crates/core/Cargo.toml`, '[package]\nname = "ferris-core"\n');
|
|
1048
|
+
const biome = `biome check --files-ignore-unknown=true '${root}'`;
|
|
1021
1049
|
const rust = await inferProjectTargets(workspace, `${root}/package.json`);
|
|
1022
1050
|
const rustLint = resolveLint(rust);
|
|
1023
1051
|
expect(rustLint.executor).toBe('nx:run-commands');
|
|
1024
1052
|
expect(rustLint.dependsOn).toEqual(['cargo-lint']);
|
|
1025
|
-
expect(rustLint.options?.commands).toEqual([
|
|
1053
|
+
expect(rustLint.options?.commands).toEqual([biome]);
|
|
1054
|
+
|
|
1055
|
+
// A JavaScript source joins ESLint's file list the moment it appears, with no tsconfig to announce it.
|
|
1056
|
+
await workspace.write(`${root}/src/check.js`, 'debugger;\n');
|
|
1057
|
+
const withJavaScript = resolveLint(await inferProjectTargets(workspace, `${root}/package.json`));
|
|
1058
|
+
expect(withJavaScript.dependsOn).toEqual(['cargo-lint']);
|
|
1059
|
+
expect(withJavaScript.options?.commands).toEqual([biome, `eslint '${root}/src/check.js'`]);
|
|
1026
1060
|
|
|
1027
1061
|
const custom = { executor: 'nx:run-commands', options: { command: 'custom-linter package.json' } };
|
|
1028
1062
|
await workspace.write(
|
|
@@ -1037,9 +1071,96 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1037
1071
|
await workspace.write(`${root}/src/index.ts`, 'export const value = 1;\n');
|
|
1038
1072
|
const mixed = await inferProjectTargets(workspace, `${root}/package.json`);
|
|
1039
1073
|
expect(resolveLint(mixed).options?.commands).toEqual([
|
|
1040
|
-
|
|
1041
|
-
`eslint '${root}/src/index.ts'`,
|
|
1074
|
+
biome,
|
|
1075
|
+
`eslint '${root}/src/check.js' '${root}/src/index.ts'`,
|
|
1042
1076
|
]);
|
|
1077
|
+
expectNoSchedulerThrottle(mixed);
|
|
1078
|
+
} finally {
|
|
1079
|
+
await workspace.cleanup();
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
it('lints the declared test program outside src and keys its sources and inherited declaration', async () => {
|
|
1084
|
+
const workspace = await createWorkspace();
|
|
1085
|
+
try {
|
|
1086
|
+
await workspace.write('eslint.config.mjs', 'export default [{ files: ["**/*.ts"] }];\n');
|
|
1087
|
+
await workspace.write('packages/example/package.json', '{"name":"example"}\n');
|
|
1088
|
+
await workspace.write(
|
|
1089
|
+
'packages/test-base.json',
|
|
1090
|
+
JSON.stringify({
|
|
1091
|
+
include: ['\u0024{configDir}/tests/**/*.ts'],
|
|
1092
|
+
exclude: ['\u0024{configDir}/tests/excluded.ts'],
|
|
1093
|
+
files: ['contract/schema.d.ts'],
|
|
1094
|
+
}),
|
|
1095
|
+
);
|
|
1096
|
+
await workspace.write('packages/example/tsconfig.test.json', '{"extends":"../test-base.json"}\n');
|
|
1097
|
+
await workspace.write('packages/example/src/index.ts', 'export const value = 1;\n');
|
|
1098
|
+
await workspace.write('packages/example/tests/check.test.ts', 'export const check = 1;\n');
|
|
1099
|
+
await workspace.write('packages/example/tests/helper.ts', 'export const helper = 1;\n');
|
|
1100
|
+
await workspace.write('packages/example/tests/excluded.ts', 'export const excluded = 1;\n');
|
|
1101
|
+
await workspace.write('packages/example/other/stray.test.ts', 'export const stray = 1;\n');
|
|
1102
|
+
await workspace.write('packages/contract/schema.d.ts', 'export interface Contract { value: number }\n');
|
|
1103
|
+
|
|
1104
|
+
const { lint } = await inferProjectTargets(workspace, 'packages/example/package.json');
|
|
1105
|
+
expect(lint?.options?.commands).toEqual([
|
|
1106
|
+
"eslint 'packages/contract/schema.d.ts' 'packages/example/src/index.ts' 'packages/example/tests/check.test.ts' 'packages/example/tests/helper.ts'",
|
|
1107
|
+
]);
|
|
1108
|
+
expect(lint?.metadata?.eslintFileSet).toEqual({
|
|
1109
|
+
command: lint?.options?.commands?.[0],
|
|
1110
|
+
files: [
|
|
1111
|
+
'packages/contract/schema.d.ts',
|
|
1112
|
+
'packages/example/src/index.ts',
|
|
1113
|
+
'packages/example/tests/check.test.ts',
|
|
1114
|
+
'packages/example/tests/helper.ts',
|
|
1115
|
+
],
|
|
1116
|
+
});
|
|
1117
|
+
expect(isEslintFileSet(lint?.metadata?.eslintFileSet)).toBe(true);
|
|
1118
|
+
expect(isEslintFileSet({ command: 'eslint invalid', files: [null] })).toBe(false);
|
|
1119
|
+
expect(lint?.inputs).toEqual(
|
|
1120
|
+
expect.arrayContaining([
|
|
1121
|
+
'{projectRoot}/tsconfig.test.json',
|
|
1122
|
+
'{workspaceRoot}/packages/test-base.json',
|
|
1123
|
+
'{workspaceRoot}/packages/contract/schema.d.ts',
|
|
1124
|
+
'{workspaceRoot}/packages/example/tests/check.test.ts',
|
|
1125
|
+
'{workspaceRoot}/packages/example/tests/helper.ts',
|
|
1126
|
+
]),
|
|
1127
|
+
);
|
|
1128
|
+
expect(lint?.inputs).not.toContain('{workspaceRoot}/packages/example/tests/excluded.ts');
|
|
1129
|
+
expect(lint?.inputs).not.toContain('{workspaceRoot}/packages/example/other/stray.test.ts');
|
|
1130
|
+
} finally {
|
|
1131
|
+
await workspace.cleanup();
|
|
1132
|
+
}
|
|
1133
|
+
});
|
|
1134
|
+
|
|
1135
|
+
it('lints and keys only the sources Nx indexes, never ignored files a build left on disk', async () => {
|
|
1136
|
+
const workspace = await createWorkspace();
|
|
1137
|
+
try {
|
|
1138
|
+
await workspace.write('eslint.config.mjs', 'export default [{ files: ["**/*.ts"] }];\n');
|
|
1139
|
+
// Generated outputs one build wrote and a fresh checkout lacks: a root ignore, a
|
|
1140
|
+
// project-level one, and an .nxignore, the three ways Nx keeps a file out of its index.
|
|
1141
|
+
await workspace.write('.gitignore', 'packages/example/src/generated/\n');
|
|
1142
|
+
await workspace.write('packages/example/.gitignore', '*.generated.ts\n');
|
|
1143
|
+
await workspace.write('.nxignore', 'packages/example/tests/nx-ignored.ts\n');
|
|
1144
|
+
await workspace.write('packages/example/package.json', '{"name":"example"}\n');
|
|
1145
|
+
await workspace.write('packages/example/tsconfig.test.json', '{"include":["tests/**/*.ts"]}\n');
|
|
1146
|
+
await workspace.write('packages/example/src/index.ts', 'export const value = 1;\n');
|
|
1147
|
+
await workspace.write('packages/example/src/generated/schemas.gen.ts', 'export const schemas = 1;\n');
|
|
1148
|
+
await workspace.write('packages/example/src/catalog.generated.ts', 'export const catalog = 1;\n');
|
|
1149
|
+
await workspace.write('packages/example/tests/check.test.ts', 'export const check = 1;\n');
|
|
1150
|
+
await workspace.write('packages/example/tests/helpers/catalog.generated.ts', 'export const c = 1;\n');
|
|
1151
|
+
await workspace.write('packages/example/tests/nx-ignored.ts', 'export const ignored = 1;\n');
|
|
1152
|
+
|
|
1153
|
+
const { lint } = await inferProjectTargets(workspace, 'packages/example/package.json');
|
|
1154
|
+
const files = ['packages/example/src/index.ts', 'packages/example/tests/check.test.ts'];
|
|
1155
|
+
expect(lint?.metadata?.eslintFileSet).toEqual({
|
|
1156
|
+
command: `eslint ${files.map((file) => `'${file}'`).join(' ')}`,
|
|
1157
|
+
files,
|
|
1158
|
+
});
|
|
1159
|
+
expect(lint?.options?.commands).toEqual([lint?.metadata?.eslintFileSet.command]);
|
|
1160
|
+
const programInputs = (lint?.inputs ?? []).filter(
|
|
1161
|
+
(input): input is string => typeof input === 'string' && input.startsWith('{workspaceRoot}/packages/example/'),
|
|
1162
|
+
);
|
|
1163
|
+
expect(programInputs).toEqual(['{workspaceRoot}/packages/example/tests/check.test.ts']);
|
|
1043
1164
|
} finally {
|
|
1044
1165
|
await workspace.cleanup();
|
|
1045
1166
|
}
|
|
@@ -1070,7 +1191,6 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1070
1191
|
'',
|
|
1071
1192
|
].join('\n'),
|
|
1072
1193
|
);
|
|
1073
|
-
await workspace.write('Cargo.lock', 'version = 4\n');
|
|
1074
1194
|
await workspace.write(
|
|
1075
1195
|
'packages/runtime/crates/runtime-core/Cargo.toml',
|
|
1076
1196
|
'[package]\nname = "runtime-core"\n\n[package.metadata.smoothbricks.test]\nshards = 2\n',
|
|
@@ -1117,7 +1237,6 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1117
1237
|
expect(root['cargo-fetch']?.options).toEqual({
|
|
1118
1238
|
commands: ['cargo fetch --locked'],
|
|
1119
1239
|
cwd: '.',
|
|
1120
|
-
parallel: false,
|
|
1121
1240
|
});
|
|
1122
1241
|
expect(root['cargo-test-compile']?.options).toMatchObject({
|
|
1123
1242
|
command: 'cargo --frozen test --workspace --no-run',
|
|
@@ -1127,27 +1246,33 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1127
1246
|
expect(String(root['cargo-lint']?.options?.commands?.[1])).toContain('clippy --workspace');
|
|
1128
1247
|
expect(root['cargo-lint']?.options?.cwd).toBe(root['cargo-test-compile']?.options?.cwd);
|
|
1129
1248
|
expect(root['cargo-lint']?.dependsOn).toContain('cargo-fetch');
|
|
1130
|
-
expect(root['cargo-test']?.dependsOn).toHaveLength(
|
|
1249
|
+
expect(root['cargo-test']?.dependsOn).toHaveLength(6);
|
|
1131
1250
|
|
|
1132
1251
|
// Root mode: every piece of every project hangs off the one root archive,
|
|
1133
1252
|
// in any order. The crate is selected by filterset alone — `-p` would
|
|
1134
1253
|
// re-resolve features, and there is nothing left to build anyway.
|
|
1135
1254
|
expect(runtime['cargo-test-runtime-core-shard1']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1136
1255
|
expect(runtime['cargo-test-runtime-core-shard2']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1137
|
-
expect(runtime['cargo-test-runtime-core-exceptions']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1256
|
+
expect(runtime['cargo-test-runtime-core-exceptions-shard1']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1257
|
+
expect(runtime['cargo-test-runtime-core-exceptions-shard2']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1138
1258
|
expect(runtime['cargo-test-runtime-core-shard1']?.options).toMatchObject({ cwd: '.' });
|
|
1139
|
-
// At the root the helper
|
|
1259
|
+
// At the root the helper and the plugin's nextest config are the root's
|
|
1260
|
+
// own `node_modules` link, no `../`.
|
|
1140
1261
|
expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toStartWith(
|
|
1141
|
-
'extracted="$(node node_modules/@smoothbricks/nx-plugin/dist/bin/smoo-nx-nextest-extract.js
|
|
1262
|
+
'extracted="$(node node_modules/@smoothbricks/nx-plugin/dist/bin/smoo-nx-nextest-extract.js .cache/nextest/archive.tar.zst)" && ',
|
|
1142
1263
|
);
|
|
1143
1264
|
expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toContain(
|
|
1144
1265
|
`--target-dir-remap "$extracted/target" --workspace-remap . -E 'package(runtime-core)`,
|
|
1145
1266
|
);
|
|
1267
|
+
expect(runtime['cargo-test-runtime-core-shard1']?.options?.command).toEndWith(
|
|
1268
|
+
'--tool-config-file "smoo:$PWD/node_modules/@smoothbricks/nx-plugin/nextest.toml"',
|
|
1269
|
+
);
|
|
1146
1270
|
expect(native['cargo-test-native-napi']?.options?.command).toContain('--no-tests=pass');
|
|
1147
1271
|
expect(runtime['cargo-test']?.dependsOn).toEqual([
|
|
1148
1272
|
'cargo-test-runtime-core-shard1',
|
|
1149
1273
|
'cargo-test-runtime-core-shard2',
|
|
1150
|
-
'cargo-test-runtime-core-exceptions',
|
|
1274
|
+
'cargo-test-runtime-core-exceptions-shard1',
|
|
1275
|
+
'cargo-test-runtime-core-exceptions-shard2',
|
|
1151
1276
|
]);
|
|
1152
1277
|
// A package owning crates validates through the root's one clippy verdict.
|
|
1153
1278
|
expect(runtime['cargo-lint']?.dependsOn).toEqual([{ projects: [rootProject], target: 'cargo-lint' }]);
|
|
@@ -1156,17 +1281,24 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1156
1281
|
expect(runtime.clean).toBeUndefined();
|
|
1157
1282
|
|
|
1158
1283
|
expect(wasm['cargo-test-runtime-wasm']?.dependsOn).toEqual([rootFetch, rootArchive]);
|
|
1284
|
+
expect(wasm['cargo-wasm']?.inputs).toContain(CARGO_CLOSURE_INPUT);
|
|
1285
|
+
expect(wasm['cargo-wasm']?.inputs).not.toContain('{workspaceRoot}/**/*.rs');
|
|
1159
1286
|
expect(wasm['cargo-wasm']?.options).toMatchObject({ cwd: '.' });
|
|
1160
1287
|
// Dev by default, in the workspace's own `target/`; only the release
|
|
1161
1288
|
// configuration compiles, and binds, the release artifact.
|
|
1162
|
-
expect(wasm['cargo-wasm']?.options?.
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
])
|
|
1289
|
+
expect(wasm['cargo-wasm']?.options?.command).toBe(
|
|
1290
|
+
[
|
|
1291
|
+
'cargo --frozen build --target wasm32-unknown-unknown -p runtime-wasm',
|
|
1292
|
+
'wasm-bindgen --target web --out-dir packages/wasm/dist-wasm/web target/wasm32-unknown-unknown/debug/runtime_wasm.wasm',
|
|
1293
|
+
].join(' && '),
|
|
1294
|
+
);
|
|
1295
|
+
expect(wasm['cargo-wasm']?.options?.commands).toBeUndefined();
|
|
1296
|
+
expect(wasm['cargo-wasm']?.configurations?.[RELEASE_CONFIGURATION]).toEqual({
|
|
1297
|
+
command: [
|
|
1298
|
+
'cargo --frozen build --release --target wasm32-unknown-unknown -p runtime-wasm',
|
|
1299
|
+
'wasm-bindgen --target web --out-dir packages/wasm/dist-wasm/web target/wasm32-unknown-unknown/release/runtime_wasm.wasm',
|
|
1300
|
+
].join(' && '),
|
|
1301
|
+
});
|
|
1170
1302
|
expect(wasm['cargo-wasm']?.outputs).toEqual(['{projectRoot}/dist-wasm']);
|
|
1171
1303
|
expect(wasm['cargo-wasm']?.dependsOn).toEqual([rootFetch, '^build']);
|
|
1172
1304
|
expect(wasm.build?.dependsOn).toContainEqual(rootCompile);
|
|
@@ -1175,7 +1307,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1175
1307
|
// The crate whose project also builds the debug cdylib keeps that edge:
|
|
1176
1308
|
// its tests load the artifact `napi-debug` writes into `target/debug`.
|
|
1177
1309
|
expect(native['cargo-test-native-napi']?.dependsOn).toEqual([rootFetch, rootArchive, 'napi-debug']);
|
|
1178
|
-
|
|
1310
|
+
// The addon build consumes only its dependencies' outputs; it is not
|
|
1311
|
+
// ordered behind the test compile.
|
|
1312
|
+
expect(native['napi-debug']?.dependsOn).toEqual(['^build']);
|
|
1179
1313
|
// The addon depends on the package's napi block and the napi CLI's version,
|
|
1180
1314
|
// never on the package version or the whole lockfile: a release bumps both
|
|
1181
1315
|
// before it builds, and that must not recompile the native code.
|
|
@@ -1184,6 +1318,18 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1184
1318
|
expect(
|
|
1185
1319
|
napiInputs.some((input) => typeof input === 'object' && 'runtime' in input && input.runtime.includes('.napi')),
|
|
1186
1320
|
).toBe(true);
|
|
1321
|
+
for (const [name, target] of Object.entries(native)) {
|
|
1322
|
+
if (!name.startsWith('napi-') || target.cache !== true) continue;
|
|
1323
|
+
expect(target.inputs).toContain(CARGO_CLOSURE_INPUT);
|
|
1324
|
+
expect(target.inputs).not.toContain('{workspaceRoot}/**/*.rs');
|
|
1325
|
+
}
|
|
1326
|
+
const nativeClosure = projects.get('packages/native')?.namedInputs?.[CARGO_CLOSURE_INPUT] ?? [];
|
|
1327
|
+
expect(nativeClosure).toContain(
|
|
1328
|
+
'{workspaceRoot}/packages/native/crates/native-napi/**/{*.rs,Cargo.toml,.cargo/config,.cargo/config.toml}',
|
|
1329
|
+
);
|
|
1330
|
+
expect(nativeClosure.some((input) => typeof input === 'string' && input.includes('packages/runtime'))).toBe(
|
|
1331
|
+
false,
|
|
1332
|
+
);
|
|
1187
1333
|
expect(napiInputs).not.toContain('{workspaceRoot}/bun.lock');
|
|
1188
1334
|
expect(napiInputs.some((input) => typeof input === 'string' && input.endsWith('/package.json'))).toBe(false);
|
|
1189
1335
|
// ... and on the toolchain pin, which it must state itself: `napi build`
|
|
@@ -1204,6 +1350,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1204
1350
|
});
|
|
1205
1351
|
expect(native.build?.dependsOn).toContainEqual(rootCompile);
|
|
1206
1352
|
expect(native.clean?.executor).toBe('@smoothbricks/nx-plugin:clean-outputs');
|
|
1353
|
+
for (const inferred of [root, runtime, wasm, native]) {
|
|
1354
|
+
expectNoSchedulerThrottle(inferred);
|
|
1355
|
+
}
|
|
1207
1356
|
} finally {
|
|
1208
1357
|
await workspace.cleanup();
|
|
1209
1358
|
}
|
|
@@ -1331,6 +1480,43 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1331
1480
|
}
|
|
1332
1481
|
});
|
|
1333
1482
|
|
|
1483
|
+
// Without an `externalDependencies` input Nx keys a task whose executor is
|
|
1484
|
+
// not an `@nx/` one on every package in the lockfile, so a lockfile-only
|
|
1485
|
+
// commit re-ran every cargo verdict (measured in a consumer: every cargo-test-*
|
|
1486
|
+
// runner and the archive re-keyed on a one-integrity bun.lock edit). Here
|
|
1487
|
+
// the plugin is this repository's workspace project, which Nx refuses as an
|
|
1488
|
+
// external dependency, so each target names none.
|
|
1489
|
+
it('keys every cached cargo target on the npm packages it runs, not the lockfile', async () => {
|
|
1490
|
+
const workspace = await createWorkspace();
|
|
1491
|
+
try {
|
|
1492
|
+
await writeCargoIdentityFixture(workspace);
|
|
1493
|
+
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
1494
|
+
const cached = cachedCargoTargets(targets);
|
|
1495
|
+
expect(cached.length).toBeGreaterThan(0);
|
|
1496
|
+
for (const [name, target] of cached) {
|
|
1497
|
+
const named = (target.inputs ?? []).filter(
|
|
1498
|
+
(input) => typeof input === 'object' && 'externalDependencies' in input,
|
|
1499
|
+
);
|
|
1500
|
+
expect([name, named]).toEqual([name, [{ externalDependencies: [] }]]);
|
|
1501
|
+
}
|
|
1502
|
+
} finally {
|
|
1503
|
+
await workspace.cleanup();
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
|
|
1507
|
+
it('names the installed plugin for a cargo target that runs its executor or files, and nothing for cargo alone', () => {
|
|
1508
|
+
const plugin = 'node_modules/.bun/@smoothbricks+nx-plugin@0.4.26/node_modules/@smoothbricks/nx-plugin';
|
|
1509
|
+
const runner = { executor: '@smoothbricks/nx-plugin:bounded-exec' };
|
|
1510
|
+
const archive = `cargo --frozen nextest archive --workspace --tool-config-file "smoo:$PWD/${plugin}/nextest.toml"`;
|
|
1511
|
+
const clippy = CARGO_LINT_CLIPPY_COMMAND;
|
|
1512
|
+
expect(cargoCommandNpmPackages(runner, 'cargo --frozen nextest run', true)).toEqual(['@smoothbricks/nx-plugin']);
|
|
1513
|
+
expect(cargoCommandNpmPackages({ executor: 'nx:run-commands' }, archive, true)).toEqual([
|
|
1514
|
+
'@smoothbricks/nx-plugin',
|
|
1515
|
+
]);
|
|
1516
|
+
expect(cargoCommandNpmPackages({ executor: 'nx:run-commands' }, clippy, true)).toEqual([]);
|
|
1517
|
+
expect(cargoCommandNpmPackages(runner, archive, false)).toEqual([]);
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1334
1520
|
// The property that decides whether Rust can ever use a shared cache. A cargo
|
|
1335
1521
|
// target's identity used to include a dump of the ambient cargo environment,
|
|
1336
1522
|
// whose values are absolute `/nix/store/…` and per-checkout devenv state
|
|
@@ -1338,15 +1524,20 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1338
1524
|
// bare shell and inside a devenv profile, which made the pre-push
|
|
1339
1525
|
// cross-compile probe unsatisfiable by construction.
|
|
1340
1526
|
//
|
|
1341
|
-
//
|
|
1342
|
-
//
|
|
1343
|
-
// paths whose only difference is the spelling of a runtime command producing
|
|
1344
|
-
// identical stdout hash identically.
|
|
1527
|
+
// The runtime value AND its command declaration must be portable: Nx also
|
|
1528
|
+
// hashes the owning project's target configuration.
|
|
1345
1529
|
it('hashes no machine-local value into a cached cargo target', async () => {
|
|
1346
1530
|
const workspace = await createWorkspace();
|
|
1347
1531
|
try {
|
|
1348
1532
|
await writeCargoIdentityFixture(workspace);
|
|
1349
1533
|
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
1534
|
+
// Installed the way a consumer links it, so the inputs find the wrapper they name. After
|
|
1535
|
+
// inference, whose fixture walk would follow the link.
|
|
1536
|
+
await mkdir(join(workspace.context.workspaceRoot, 'node_modules/@smoothbricks'), { recursive: true });
|
|
1537
|
+
await symlink(
|
|
1538
|
+
fileURLToPath(new URL('..', import.meta.url)),
|
|
1539
|
+
join(workspace.context.workspaceRoot, 'node_modules/@smoothbricks/nx-plugin'),
|
|
1540
|
+
);
|
|
1350
1541
|
const offenders: string[] = [];
|
|
1351
1542
|
for (const [name, target] of cachedCargoTargets(targets)) {
|
|
1352
1543
|
for (const input of target.inputs ?? []) {
|
|
@@ -1356,6 +1547,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1356
1547
|
}
|
|
1357
1548
|
if ('env' in input) offenders.push(`${name}: environment input ${String(input.env)}`);
|
|
1358
1549
|
if (!('runtime' in input)) continue;
|
|
1550
|
+
if (input.runtime.includes(fileURLToPath(new URL('..', import.meta.url)))) {
|
|
1551
|
+
offenders.push(`${name}: runtime command names the plugin checkout`);
|
|
1552
|
+
}
|
|
1359
1553
|
const value = await runtimeInputValue(input.runtime, workspace.context.workspaceRoot);
|
|
1360
1554
|
const rooted = PATH_OUTSIDE_WORKSPACE.exec(value);
|
|
1361
1555
|
if (rooted) offenders.push(`${name}: runtime input yields ${rooted[0].trim()} — from ${input.runtime}`);
|
|
@@ -1367,6 +1561,51 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1367
1561
|
}
|
|
1368
1562
|
}, 60_000);
|
|
1369
1563
|
|
|
1564
|
+
// A consumer links the plugin from a checkout of its own, outside the
|
|
1565
|
+
// workspace, and its forks sit at different depths. Nx hashes a project's
|
|
1566
|
+
// configuration into every task of that project and of its dependents, so
|
|
1567
|
+
// the configuration must not know how deep the workspace is: measured, a
|
|
1568
|
+
// `../` count in the tool config path re-keyed 118 tasks of a fork of a warm
|
|
1569
|
+
// main.
|
|
1570
|
+
it('infers byte-identical cargo targets for a workspace at any depth', async () => {
|
|
1571
|
+
const parent = await realpath(await mkdtemp(join(tmpdir(), 'smoothbricks-nx-plugin-depth-')));
|
|
1572
|
+
const plugin = fileURLToPath(new URL('..', import.meta.url));
|
|
1573
|
+
const pluginNextestConfig = await readFile(join(plugin, 'nextest.toml'), 'utf8');
|
|
1574
|
+
try {
|
|
1575
|
+
const inferred: string[] = [];
|
|
1576
|
+
for (const dir of [parent, join(parent, 'a/b/c')]) {
|
|
1577
|
+
await mkdir(dir, { recursive: true });
|
|
1578
|
+
const workspace = await createWorkspace(dir);
|
|
1579
|
+
const root = workspace.context.workspaceRoot;
|
|
1580
|
+
await writeCargoIdentityFixture(workspace);
|
|
1581
|
+
const project = await inferProject(workspace, 'packages/ferris/package.json');
|
|
1582
|
+
// Installed the way a consumer links it: a checkout outside the
|
|
1583
|
+
// workspace. After inference, whose fixture walk would follow it.
|
|
1584
|
+
await mkdir(join(root, 'node_modules/@smoothbricks'), { recursive: true });
|
|
1585
|
+
await symlink(plugin, join(root, 'node_modules/@smoothbricks/nx-plugin'));
|
|
1586
|
+
// Stable is not enough: from where each command runs, the spelling
|
|
1587
|
+
// must name the config the plugin ships.
|
|
1588
|
+
const configured: string[] = [];
|
|
1589
|
+
for (const [name, target] of cachedCargoTargets(project?.targets ?? {})) {
|
|
1590
|
+
const named = /--tool-config-file "smoo:\$PWD\/([^"]+)"/.exec(String(target.options?.command));
|
|
1591
|
+
if (!named?.[1]) continue;
|
|
1592
|
+
configured.push(name);
|
|
1593
|
+
const config = await readFile(join(root, String(target.options?.cwd), named[1]), 'utf8');
|
|
1594
|
+
expect([name, config]).toEqual([name, pluginNextestConfig]);
|
|
1595
|
+
}
|
|
1596
|
+
expect(configured.sort()).toEqual([
|
|
1597
|
+
'cargo-cross-test-archive-aarch64-apple-darwin',
|
|
1598
|
+
'cargo-test-archive',
|
|
1599
|
+
'cargo-test-ferris-core',
|
|
1600
|
+
]);
|
|
1601
|
+
inferred.push(JSON.stringify(project, null, 2));
|
|
1602
|
+
}
|
|
1603
|
+
expect(inferred[1]).toBe(inferred[0]);
|
|
1604
|
+
} finally {
|
|
1605
|
+
await rm(parent, { recursive: true, force: true });
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
|
|
1370
1609
|
it('scopes each per-crate cargo-test command to exactly one package', async () => {
|
|
1371
1610
|
const workspace = await createWorkspace();
|
|
1372
1611
|
try {
|
|
@@ -1417,7 +1656,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1417
1656
|
// A cargo that does what nextest does with an archive, and says so: an
|
|
1418
1657
|
// `--archive-file` unpacks it (into `--extract-to`, or a private temp
|
|
1419
1658
|
// dir when a run is given the archive itself), and a run reports which
|
|
1420
|
-
// archive's binaries it executed.
|
|
1659
|
+
// archive's binaries it executed. `metadata` names the workspace's
|
|
1660
|
+
// target directory, where the extraction root lives.
|
|
1421
1661
|
const log = join(root, 'nextest.log');
|
|
1422
1662
|
await workspace.write(
|
|
1423
1663
|
'bin/cargo',
|
|
@@ -1426,6 +1666,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1426
1666
|
'archive= dest= binaries=',
|
|
1427
1667
|
'while [ $# -gt 0 ]; do',
|
|
1428
1668
|
' case "$1" in',
|
|
1669
|
+
' metadata) printf \'{"target_directory":"%s/target"}\\n\' "$PWD"; exit 0 ;;',
|
|
1429
1670
|
' --archive-file) archive=$2; shift ;;',
|
|
1430
1671
|
' --extract-to) dest=$2; shift ;;',
|
|
1431
1672
|
' --binaries-metadata) binaries=$2; shift ;;',
|
|
@@ -1461,7 +1702,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1461
1702
|
}),
|
|
1462
1703
|
);
|
|
1463
1704
|
|
|
1464
|
-
await workspace.write('packages/ferris/
|
|
1705
|
+
await workspace.write('packages/ferris/.cache/nextest/archive.tar.zst', 'first archive');
|
|
1465
1706
|
for (const run of await runAll()) {
|
|
1466
1707
|
expect(run).toMatchObject({ exitCode: 0 });
|
|
1467
1708
|
}
|
|
@@ -1474,7 +1715,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1474
1715
|
|
|
1475
1716
|
// A rebuilt archive is new bytes at the same path: the runners must not
|
|
1476
1717
|
// execute what the old one unpacked, and the old unpacking is garbage.
|
|
1477
|
-
await workspace.write('packages/ferris/
|
|
1718
|
+
await workspace.write('packages/ferris/.cache/nextest/archive.tar.zst', 'second archive');
|
|
1478
1719
|
for (const run of await runAll()) {
|
|
1479
1720
|
expect(run).toMatchObject({ exitCode: 0 });
|
|
1480
1721
|
}
|
|
@@ -1488,13 +1729,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1488
1729
|
'run second archive',
|
|
1489
1730
|
'run second archive',
|
|
1490
1731
|
]);
|
|
1491
|
-
|
|
1492
|
-
|
|
1732
|
+
// The old unpacking is gone from Cargo's build tree, and the archive's
|
|
1733
|
+
// directory holds only the archive, the declared Nx output.
|
|
1734
|
+
const extracted = join(root, 'packages/ferris/target', NEXTEST_EXTRACTION_DIRECTORY);
|
|
1735
|
+
const unpacked = (await readdir(extracted, { recursive: true })).filter((path) =>
|
|
1493
1736
|
path.endsWith('binaries-metadata.json'),
|
|
1494
1737
|
);
|
|
1495
|
-
expect(await Promise.all(unpacked.map((path) => readFile(join(
|
|
1738
|
+
expect(await Promise.all(unpacked.map((path) => readFile(join(extracted, path), 'utf8')))).toEqual([
|
|
1496
1739
|
'second archive',
|
|
1497
1740
|
]);
|
|
1741
|
+
expect(await readdir(join(root, 'packages/ferris/.cache/nextest'))).toEqual(['archive.tar.zst']);
|
|
1498
1742
|
} finally {
|
|
1499
1743
|
await workspace.cleanup();
|
|
1500
1744
|
}
|
|
@@ -1535,30 +1779,31 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1535
1779
|
inputs: expect.arrayContaining(['{projectRoot}/**/*.rs', '{projectRoot}/**/Cargo.toml']),
|
|
1536
1780
|
outputs: ['{projectRoot}/generated/wasm'],
|
|
1537
1781
|
options: {
|
|
1538
|
-
|
|
1782
|
+
command: [
|
|
1539
1783
|
'cargo --frozen build --target wasm32-unknown-unknown --manifest-path crates/git-do/Cargo.toml',
|
|
1540
1784
|
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/wasm32-unknown-unknown/debug/gitoxide_engine.wasm',
|
|
1541
1785
|
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/wasm32-unknown-unknown/debug/gitoxide_engine.wasm',
|
|
1542
|
-
],
|
|
1786
|
+
].join(' && '),
|
|
1543
1787
|
cwd: 'packages/git-do',
|
|
1544
|
-
parallel: false,
|
|
1545
1788
|
},
|
|
1546
1789
|
});
|
|
1547
1790
|
// No workspace claims the crate, so cargo's default target dir is the one
|
|
1548
1791
|
// beside its own manifest, and the release configuration reads the
|
|
1549
1792
|
// release artifact from it.
|
|
1550
|
-
expect(targets['cargo-wasm']?.
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1793
|
+
expect(targets['cargo-wasm']?.options?.commands).toBeUndefined();
|
|
1794
|
+
expect(targets['cargo-wasm']?.configurations?.[RELEASE_CONFIGURATION]).toEqual({
|
|
1795
|
+
command: [
|
|
1796
|
+
'cargo --frozen build --release --target wasm32-unknown-unknown --manifest-path crates/git-do/Cargo.toml',
|
|
1797
|
+
'wasm-bindgen --target nodejs --out-dir generated/wasm/node crates/git-do/target/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
1798
|
+
'wasm-bindgen --target web --out-dir generated/wasm/web crates/git-do/target/wasm32-unknown-unknown/release/gitoxide_engine.wasm',
|
|
1799
|
+
].join(' && '),
|
|
1800
|
+
});
|
|
1555
1801
|
// A wasm-bindgen crate in a nested Cargo workspace still needs its locked
|
|
1556
1802
|
// graph downloaded, and the project root is not a member of it, so the
|
|
1557
1803
|
// fetch names the crate manifest instead of relying on cwd.
|
|
1558
1804
|
expect(targets['cargo-fetch']?.options).toEqual({
|
|
1559
1805
|
commands: ['cargo fetch --locked --manifest-path crates/git-do/Cargo.toml'],
|
|
1560
1806
|
cwd: 'packages/git-do',
|
|
1561
|
-
parallel: false,
|
|
1562
1807
|
});
|
|
1563
1808
|
expect(targets['tsc-js']?.dependsOn).toEqual(['^*-js', 'cargo-wasm']);
|
|
1564
1809
|
expect(targets.typecheck?.dependsOn).toEqual(['^*-js', 'cargo-wasm']);
|
|
@@ -1568,6 +1813,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1568
1813
|
// workspace-wide cargo-test/lint policy.
|
|
1569
1814
|
expect(targets['cargo-test']).toBeUndefined();
|
|
1570
1815
|
expect(targets['cargo-lint']).toBeUndefined();
|
|
1816
|
+
expectNoSchedulerThrottle(targets);
|
|
1571
1817
|
} finally {
|
|
1572
1818
|
await workspace.cleanup();
|
|
1573
1819
|
}
|
|
@@ -1637,9 +1883,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1637
1883
|
expect(unservedHostTargets['cargo-napi']).toMatchObject({
|
|
1638
1884
|
executor: 'nx:run-commands',
|
|
1639
1885
|
cache: true,
|
|
1640
|
-
// The dedicated host build
|
|
1641
|
-
//
|
|
1642
|
-
dependsOn: ['^build'
|
|
1886
|
+
// The dedicated host build consumes only its dependencies' outputs; it is
|
|
1887
|
+
// not ordered behind the test compile.
|
|
1888
|
+
dependsOn: ['^build'],
|
|
1643
1889
|
outputs: ['{projectRoot}/dist/native/host'],
|
|
1644
1890
|
options: {
|
|
1645
1891
|
cwd: 'packages/cowshed',
|
|
@@ -1663,10 +1909,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1663
1909
|
command: darwinArm64Build(' --release'),
|
|
1664
1910
|
});
|
|
1665
1911
|
expect(targets['napi-arm64-macos']?.options?.env).toBeUndefined();
|
|
1666
|
-
// No cargo-test-compile edge here, on ANY host:
|
|
1667
|
-
// dependency closure may only reach
|
|
1668
|
-
// (`validatePlatformTargetDependencies`)
|
|
1669
|
-
// cargo's flock rather than on a graph edge.
|
|
1912
|
+
// No cargo-test-compile edge here, on ANY host: the platform build consumes
|
|
1913
|
+
// nothing from it, and a platform target's dependency closure may only reach
|
|
1914
|
+
// its own family (`validatePlatformTargetDependencies`).
|
|
1670
1915
|
expect(targets['napi-arm64-macos']?.dependsOn).toBeUndefined();
|
|
1671
1916
|
// A macOS triple never gets a cross toolchain: `usesNapiCross` is
|
|
1672
1917
|
// `family === 'linux' && target !== host`, so the family decides this one
|
|
@@ -1766,11 +2011,9 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1766
2011
|
.sort();
|
|
1767
2012
|
expect(hostNapiTargets.length).toBeGreaterThan(0);
|
|
1768
2013
|
expect(inferred.build?.dependsOn).toEqual(['^build', 'cargo-test-compile', 'tsc-js', ...hostNapiTargets]);
|
|
1769
|
-
// Crate `cowshed-napi` names its bounded runner
|
|
1770
|
-
//
|
|
1771
|
-
//
|
|
1772
|
-
// that single edge put the whole cargo test suite inside
|
|
1773
|
-
// `nx run-many -t build`.
|
|
2014
|
+
// Crate `cowshed-napi` names its bounded runner `cargo-test-cowshed-napi`;
|
|
2015
|
+
// the retired `*-napi` output-family glob matched it on suffix alone and
|
|
2016
|
+
// put the whole cargo test suite inside `nx run-many -t build`.
|
|
1774
2017
|
expect(inferred['cargo-test-cowshed-napi']).toBeDefined();
|
|
1775
2018
|
for (const dependency of inferred.build?.dependsOn ?? []) {
|
|
1776
2019
|
expect(String(dependency).startsWith('cargo-test-')).toBe(dependency === 'cargo-test-compile');
|
|
@@ -1789,7 +2032,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1789
2032
|
expect(targets['napi-debug']).toMatchObject({
|
|
1790
2033
|
executor: 'nx:run-commands',
|
|
1791
2034
|
cache: true,
|
|
1792
|
-
dependsOn: ['^build'
|
|
2035
|
+
dependsOn: ['^build'],
|
|
1793
2036
|
outputs: ['{projectRoot}/.cache/native-debug'],
|
|
1794
2037
|
options: {
|
|
1795
2038
|
cwd: 'packages/cowshed',
|
|
@@ -1808,7 +2051,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1808
2051
|
'napi-debug',
|
|
1809
2052
|
]);
|
|
1810
2053
|
expect(targets['cargo-test-cowshed-napi']?.options?.command).toMatch(
|
|
1811
|
-
/^extracted="\$\(node \.\.\/\.\.\/node_modules\/@smoothbricks\/nx-plugin\/dist\/bin\/smoo-nx-nextest-extract\.js
|
|
2054
|
+
/^extracted="\$\(node \.\.\/\.\.\/node_modules\/@smoothbricks\/nx-plugin\/dist\/bin\/smoo-nx-nextest-extract\.js \.cache\/nextest\/archive\.tar\.zst\)" && cargo --frozen nextest run --binaries-metadata "\$extracted\/target\/nextest\/binaries-metadata\.json" --cargo-metadata "\$extracted\/target\/nextest\/cargo-metadata\.json" --target-dir-remap "\$extracted\/target" --workspace-remap \. -E 'package\(cowshed-napi\)' --no-fail-fast --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
1812
2055
|
);
|
|
1813
2056
|
expect(targets['napi-test']).toMatchObject({
|
|
1814
2057
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
@@ -1818,10 +2061,11 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1818
2061
|
command: 'bun test --config=../bunfig.toml --timeout=30000 native.test.ts',
|
|
1819
2062
|
cwd: 'packages/cowshed/src',
|
|
1820
2063
|
env: { NAPI_DEBUG_ADDON: '1' },
|
|
1821
|
-
|
|
2064
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
1822
2065
|
killAfterMs: 10000,
|
|
1823
2066
|
},
|
|
1824
2067
|
});
|
|
2068
|
+
expectNoSchedulerThrottle(targets);
|
|
1825
2069
|
await workspace.write('packages/cowshed/bunfig.napi-test.toml', '[test]\n');
|
|
1826
2070
|
const targetsWithDedicatedBunfig = await inferProjectTargets(workspace, 'packages/cowshed/package.json');
|
|
1827
2071
|
expect(targetsWithDedicatedBunfig['napi-test']?.options?.command).toBe(
|
|
@@ -1885,16 +2129,18 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1885
2129
|
|
|
1886
2130
|
// Cargo writes a member's artifacts under its workspace root, not beside
|
|
1887
2131
|
// the member's manifest, so the bindgen input is read from there.
|
|
1888
|
-
expect(targets['cargo-wasm']?.options?.
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2132
|
+
expect(targets['cargo-wasm']?.options?.command).toBe(
|
|
2133
|
+
[
|
|
2134
|
+
'cargo --frozen build --target wasm32-unknown-unknown --manifest-path crates/columine-wasm/Cargo.toml',
|
|
2135
|
+
'wasm-bindgen --target web --out-dir dist-wasm/web target/wasm32-unknown-unknown/debug/columine_wasm.wasm',
|
|
2136
|
+
].join(' && '),
|
|
2137
|
+
);
|
|
1892
2138
|
} finally {
|
|
1893
2139
|
await workspace.cleanup();
|
|
1894
2140
|
}
|
|
1895
2141
|
});
|
|
1896
2142
|
|
|
1897
|
-
it('
|
|
2143
|
+
it('partitions ordinary and exceptional tests into disjoint hash shards of the same declared count', async () => {
|
|
1898
2144
|
const workspace = await createWorkspace();
|
|
1899
2145
|
try {
|
|
1900
2146
|
await workspace.write('packages/rusty/package.json', '{"name":"rusty"}\n');
|
|
@@ -1910,11 +2156,10 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1910
2156
|
// An unsharded crate keeps the bare name and takes no --partition, so
|
|
1911
2157
|
// declaring nothing is exactly the old single-target behaviour.
|
|
1912
2158
|
expect(targets['cargo-test-small']?.options?.command).toMatch(
|
|
1913
|
-
/--workspace-remap \. -E 'package\(small\)' --no-tests=pass --user-config-file none/,
|
|
2159
|
+
/--workspace-remap \. -E 'package\(small\)' --no-fail-fast --no-tests=pass --user-config-file none/,
|
|
1914
2160
|
);
|
|
1915
2161
|
// The shards partition the crate MINUS the classes nextest.toml singles
|
|
1916
|
-
// out, i of N. Those are lifted out because a test
|
|
1917
|
-
// within one nextest run, and because a test carrying a raised
|
|
2162
|
+
// out, i of N. Those are lifted out because a test carrying a raised
|
|
1918
2163
|
// slow-timeout costs what the suite does not — the compile-fail test
|
|
1919
2164
|
// rustc's a fixture for 25.6s on a cold target dir against 1.8s warm.
|
|
1920
2165
|
const exceptional = exceptionalTestFilter(fileURLToPath(new URL('../nextest.toml', import.meta.url)));
|
|
@@ -1923,34 +2168,44 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1923
2168
|
}
|
|
1924
2169
|
for (const index of [1, 2, 3]) {
|
|
1925
2170
|
expect(targets[`cargo-test-big-shard${index}`]?.options?.command).toContain(
|
|
1926
|
-
`-E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-tests=pass`,
|
|
2171
|
+
`-E 'package(big) and not (${exceptional})' --partition hash:${index}/3 --no-fail-fast --no-tests=pass`,
|
|
1927
2172
|
);
|
|
1928
|
-
expect(targets[`cargo-test-big-shard${index}`]?.options?.
|
|
2173
|
+
expect(targets[`cargo-test-big-shard${index}`]?.options?.idleTimeoutMs).toBe(BOUNDED_TEST_IDLE_TIMEOUT_MS);
|
|
2174
|
+
expect(targets[`cargo-test-big-shard${index}`]?.options).not.toHaveProperty('timeoutMs');
|
|
1929
2175
|
}
|
|
1930
|
-
//
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2176
|
+
// Exceptional partitions are the exact complement, hashed by the same
|
|
2177
|
+
// declared count; each keeps the full bounded window.
|
|
2178
|
+
for (const index of [1, 2, 3]) {
|
|
2179
|
+
const name = `cargo-test-big-exceptions-shard${index}`;
|
|
2180
|
+
expect(targets[name]?.options?.command).toContain(
|
|
2181
|
+
`-E 'package(big) and (${exceptional})' --partition hash:${index}/3 --no-fail-fast --no-tests=pass`,
|
|
2182
|
+
);
|
|
2183
|
+
expect(targets[name]?.options?.idleTimeoutMs).toBe(BOUNDED_TEST_IDLE_TIMEOUT_MS);
|
|
2184
|
+
expect(packageNameFromCargoTestTarget(name)).toBe('big');
|
|
2185
|
+
}
|
|
2186
|
+
expect(targets['cargo-test-big-exceptions']).toBeUndefined();
|
|
1936
2187
|
// An unsharded crate needs no pin: its whole suite is already one run.
|
|
1937
2188
|
expect(targets['cargo-test-small-exceptions']).toBeUndefined();
|
|
1938
2189
|
expect(targets['cargo-test-big']).toBeUndefined();
|
|
1939
2190
|
// Every piece reaches the aggregate, and they all hang off the one
|
|
1940
2191
|
// archive: a run extracts binaries to its own temp directory and writes
|
|
1941
|
-
// nothing to cargo's
|
|
2192
|
+
// nothing to cargo's target/, so no piece waits on another.
|
|
1942
2193
|
expect(targets['cargo-test']?.dependsOn).toEqual([
|
|
1943
2194
|
'cargo-test-big-shard1',
|
|
1944
2195
|
'cargo-test-big-shard2',
|
|
1945
2196
|
'cargo-test-big-shard3',
|
|
1946
|
-
'cargo-test-big-exceptions',
|
|
2197
|
+
'cargo-test-big-exceptions-shard1',
|
|
2198
|
+
'cargo-test-big-exceptions-shard2',
|
|
2199
|
+
'cargo-test-big-exceptions-shard3',
|
|
1947
2200
|
'cargo-test-small',
|
|
1948
2201
|
]);
|
|
1949
2202
|
for (const name of [
|
|
1950
2203
|
'cargo-test-big-shard1',
|
|
1951
2204
|
'cargo-test-big-shard2',
|
|
1952
2205
|
'cargo-test-big-shard3',
|
|
1953
|
-
'cargo-test-big-exceptions',
|
|
2206
|
+
'cargo-test-big-exceptions-shard1',
|
|
2207
|
+
'cargo-test-big-exceptions-shard2',
|
|
2208
|
+
'cargo-test-big-exceptions-shard3',
|
|
1954
2209
|
'cargo-test-small',
|
|
1955
2210
|
]) {
|
|
1956
2211
|
expect(targets[name]?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
@@ -1958,7 +2213,348 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1958
2213
|
// Pieces of one crate share its inputs: they are one suite, split only to
|
|
1959
2214
|
// fit the bound, so any change to the crate invalidates all of them.
|
|
1960
2215
|
expect(targets['cargo-test-big-shard2']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
|
|
1961
|
-
expect(targets['cargo-test-big-exceptions']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
|
|
2216
|
+
expect(targets['cargo-test-big-exceptions-shard1']?.inputs).toEqual(targets['cargo-test-big-shard1']?.inputs);
|
|
2217
|
+
// Exceptional pieces fan out like the ordinary ones: nothing is exclusive.
|
|
2218
|
+
expectNoSchedulerThrottle(targets);
|
|
2219
|
+
} finally {
|
|
2220
|
+
await workspace.cleanup();
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
|
|
2224
|
+
it('runs the serial test group once, unpartitioned, and excludes its tests from every crate piece on macOS', async () => {
|
|
2225
|
+
const workspace = await createWorkspace();
|
|
2226
|
+
try {
|
|
2227
|
+
await workspace.write('packages/rusty/package.json', '{"name":"rusty"}\n');
|
|
2228
|
+
await workspace.write('packages/rusty/Cargo.toml', '[workspace]\nmembers = ["crates/big", "crates/small"]\n');
|
|
2229
|
+
await workspace.write(
|
|
2230
|
+
'packages/rusty/crates/big/Cargo.toml',
|
|
2231
|
+
'[package]\nname = "big"\n\n[package.metadata.smoothbricks.test]\nshards = 3\n',
|
|
2232
|
+
);
|
|
2233
|
+
await workspace.write('packages/rusty/crates/small/Cargo.toml', '[package]\nname = "small"\n');
|
|
2234
|
+
await workspace.write(
|
|
2235
|
+
'packages/rusty/.config/nextest.toml',
|
|
2236
|
+
[
|
|
2237
|
+
'[test-groups.real-apfs]',
|
|
2238
|
+
'max-threads = 1',
|
|
2239
|
+
'',
|
|
2240
|
+
'[[profile.default.overrides]]',
|
|
2241
|
+
"filter = 'test(/real_apfs_/)'",
|
|
2242
|
+
`platform = 'cfg(target_os="macos")'`,
|
|
2243
|
+
"test-group = 'real-apfs'",
|
|
2244
|
+
'',
|
|
2245
|
+
].join('\n'),
|
|
2246
|
+
);
|
|
2247
|
+
|
|
2248
|
+
const macos = await inferProjectTargets(
|
|
2249
|
+
workspace,
|
|
2250
|
+
'packages/rusty/package.json',
|
|
2251
|
+
createNodesV2ForPlatform('darwin', 'arm64'),
|
|
2252
|
+
);
|
|
2253
|
+
const serial = '(test(/real_apfs_/))';
|
|
2254
|
+
const group = macos['cargo-test-group-real-apfs'];
|
|
2255
|
+
// One runner for the workspace, owned by the cargo root beside the archive it executes: a progress bound and no
|
|
2256
|
+
// ceiling like every test target, one CPU token, no partition and no thread flag. A filter that selects
|
|
2257
|
+
// nothing fails the run.
|
|
2258
|
+
expect(group?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
2259
|
+
expect(group?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
2260
|
+
expect(String(group?.options?.command)).toContain('nextest run ');
|
|
2261
|
+
expect(String(group?.options?.command)).toContain(
|
|
2262
|
+
`-E '${serial}' --no-fail-fast --no-tests=fail --user-config-file none`,
|
|
2263
|
+
);
|
|
2264
|
+
expect(group?.options).not.toHaveProperty('timeoutMs');
|
|
2265
|
+
expect(group?.options?.idleTimeoutMs).toBe(BOUNDED_TEST_IDLE_TIMEOUT_MS);
|
|
2266
|
+
expect(group?.options?.killAfterMs).toBe(BOUNDED_TEST_KILL_AFTER_MS);
|
|
2267
|
+
expect(group?.options?.parallelism).toBe(1);
|
|
2268
|
+
expect(group?.inputs).toContain('{workspaceRoot}/packages/rusty/.config/nextest.toml');
|
|
2269
|
+
expect(JSON.stringify(group?.inputs)).toContain('nextest-code-bound.ts');
|
|
2270
|
+
expect(JSON.stringify(macos['cargo-test-small']?.inputs)).not.toContain('nextest-code-bound.ts');
|
|
2271
|
+
expect(String(group?.options?.command)).not.toMatch(/--partition|test-threads|max-fail/);
|
|
2272
|
+
|
|
2273
|
+
// Every crate piece excludes the group's tests, so each test is selected by exactly one target.
|
|
2274
|
+
const exceptional = exceptionalTestFilter(fileURLToPath(new URL('../nextest.toml', import.meta.url)));
|
|
2275
|
+
if (exceptional === null) {
|
|
2276
|
+
throw new Error('nextest.toml declares no overrides; this test asserts the pin that protects them');
|
|
2277
|
+
}
|
|
2278
|
+
expect(macos['cargo-test-small']?.options?.command).toContain(
|
|
2279
|
+
`-E 'package(small) and not ((test(/real_apfs_/)))' --no-fail-fast --no-tests=pass`,
|
|
2280
|
+
);
|
|
2281
|
+
for (const index of [1, 2, 3]) {
|
|
2282
|
+
expect(macos[`cargo-test-big-shard${index}`]?.options?.command).toContain(
|
|
2283
|
+
`-E 'package(big) and not (${exceptional}) and not ((test(/real_apfs_/)))' --partition hash:${index}/3 --no-fail-fast --no-tests=pass`,
|
|
2284
|
+
);
|
|
2285
|
+
expect(macos[`cargo-test-big-exceptions-shard${index}`]?.options?.command).toContain(
|
|
2286
|
+
`-E 'package(big) and (${exceptional}) and not ((test(/real_apfs_/)))' --partition hash:${index}/3 --no-fail-fast --no-tests=pass`,
|
|
2287
|
+
);
|
|
2288
|
+
}
|
|
2289
|
+
// `cargo-test` and `test` are the ordinary suite alone: neither infers an edge to the group.
|
|
2290
|
+
expect(macos['cargo-test']?.dependsOn).not.toContain('cargo-test-group-real-apfs');
|
|
2291
|
+
expect(macos.test?.dependsOn).toEqual(['cargo-test']);
|
|
2292
|
+
|
|
2293
|
+
// Off macOS nextest applies the group nowhere, so it is not inferred and no piece excludes its tests.
|
|
2294
|
+
const linux = await inferProjectTargets(
|
|
2295
|
+
workspace,
|
|
2296
|
+
'packages/rusty/package.json',
|
|
2297
|
+
createNodesV2ForPlatform('linux', 'x64'),
|
|
2298
|
+
);
|
|
2299
|
+
expect(linux['cargo-test-group-real-apfs']).toBeUndefined();
|
|
2300
|
+
expect(linux['cargo-test-small']?.options?.command).toContain(
|
|
2301
|
+
`-E 'package(small)' --no-fail-fast --no-tests=pass`,
|
|
2302
|
+
);
|
|
2303
|
+
expect(linux['cargo-test']?.dependsOn).not.toContain('cargo-test-group-real-apfs');
|
|
2304
|
+
expect(linux.test?.dependsOn).toEqual(['cargo-test']);
|
|
2305
|
+
} finally {
|
|
2306
|
+
await workspace.cleanup();
|
|
2307
|
+
}
|
|
2308
|
+
});
|
|
2309
|
+
|
|
2310
|
+
it("scopes each serial group's runner inputs to its packages and their closure, and keeps an unscoped group workspace-wide", async () => {
|
|
2311
|
+
const workspace = await createWorkspace();
|
|
2312
|
+
try {
|
|
2313
|
+
await writeApfsSplitFixture(workspace, [
|
|
2314
|
+
...APFS_SPLIT_GROUPS,
|
|
2315
|
+
'[test-groups.wide]',
|
|
2316
|
+
'max-threads = 1',
|
|
2317
|
+
'',
|
|
2318
|
+
...serialOverride('test(/wide_/)', 'wide'),
|
|
2319
|
+
]);
|
|
2320
|
+
const root = (await inferApfsSplit(workspace)).get('.') ?? {};
|
|
2321
|
+
const device = root['cargo-test-group-real-apfs'];
|
|
2322
|
+
const host = root['cargo-test-group-real-apfs-host'];
|
|
2323
|
+
const wide = root['cargo-test-group-wide'];
|
|
2324
|
+
|
|
2325
|
+
// A group scoped to packages hashes those crates and every crate they link, and no other.
|
|
2326
|
+
expect(hashedCrates(device)).toEqual(['cowshed-apfs', 'cowshed-apfs-tests', 'cowshed-os']);
|
|
2327
|
+
expect(hashedCrates(host)).toEqual(['cowshed-apfs', 'cowshed-cli', 'cowshed-core', 'cowshed-os']);
|
|
2328
|
+
// A filter scoped to no package keeps every member's tree, as the archive hashes them.
|
|
2329
|
+
expect(hashedCrates(wide)).toEqual([
|
|
2330
|
+
'cowshed-apfs',
|
|
2331
|
+
'cowshed-apfs-tests',
|
|
2332
|
+
'cowshed-cli',
|
|
2333
|
+
'cowshed-core',
|
|
2334
|
+
'cowshed-os',
|
|
2335
|
+
'lmao-core',
|
|
2336
|
+
]);
|
|
2337
|
+
|
|
2338
|
+
// The proof as the three cases it makes. An unrelated crate reruns neither scoped group. A scenario
|
|
2339
|
+
// edit reruns the device group alone: the scenarios are a crate of their own that no host crate
|
|
2340
|
+
// depends on. A change to the production substrate, or to what it links, reruns both, because the
|
|
2341
|
+
// host crates link it too. Nothing here excludes a tests tree, and the test support every real-image
|
|
2342
|
+
// binary compiles in stays hashed for both groups.
|
|
2343
|
+
const hashedBy = (path: string) => ({
|
|
2344
|
+
device: hashes(device, path),
|
|
2345
|
+
host: hashes(host, path),
|
|
2346
|
+
wide: hashes(wide, path),
|
|
2347
|
+
});
|
|
2348
|
+
expect(hashedBy('packages/lmao/crates/lmao-core/src/lib.rs')).toEqual({ device: false, host: false, wide: true });
|
|
2349
|
+
expect(hashedBy('packages/cowshed/crates/cowshed-apfs-tests/src/tests.rs')).toEqual({
|
|
2350
|
+
device: true,
|
|
2351
|
+
host: false,
|
|
2352
|
+
wide: true,
|
|
2353
|
+
});
|
|
2354
|
+
expect(hashedBy('packages/cowshed/crates/cowshed-core/src/lib.rs')).toEqual({
|
|
2355
|
+
device: false,
|
|
2356
|
+
host: true,
|
|
2357
|
+
wide: true,
|
|
2358
|
+
});
|
|
2359
|
+
expect(hashedBy('packages/cowshed/crates/cowshed-cli/src/lib.rs')).toEqual({
|
|
2360
|
+
device: false,
|
|
2361
|
+
host: true,
|
|
2362
|
+
wide: true,
|
|
2363
|
+
});
|
|
2364
|
+
for (const shared of [
|
|
2365
|
+
'packages/cowshed/crates/cowshed-apfs/src/lib.rs',
|
|
2366
|
+
'packages/cowshed/crates/cowshed-apfs/tests/support/blank_image.rs',
|
|
2367
|
+
'packages/cowshed/crates/cowshed-os/src/lib.rs',
|
|
2368
|
+
]) {
|
|
2369
|
+
expect(hashedBy(shared), shared).toEqual({ device: true, host: true, wide: true });
|
|
2370
|
+
}
|
|
2371
|
+
for (const group of [device, host]) {
|
|
2372
|
+
const exclusions = (group?.inputs ?? []).filter(
|
|
2373
|
+
(input): input is string => typeof input === 'string' && input.startsWith('!'),
|
|
2374
|
+
);
|
|
2375
|
+
expect(exclusions.filter((input) => /\btests?\b/.test(input))).toEqual([]);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
// Every scoped group still hashes every member manifest, the repository's nextest config and the
|
|
2379
|
+
// run-wrapper its tests are bounded by: those decide a verdict whichever crates it selects.
|
|
2380
|
+
for (const group of [device, host, wide]) {
|
|
2381
|
+
expect(group?.inputs).toContain('{workspaceRoot}/packages/lmao/crates/lmao-core/Cargo.toml');
|
|
2382
|
+
expect(group?.inputs).toContain('{workspaceRoot}/.config/nextest.toml');
|
|
2383
|
+
expect(JSON.stringify(group?.inputs)).toContain('nextest-code-bound.ts');
|
|
2384
|
+
}
|
|
2385
|
+
} finally {
|
|
2386
|
+
await workspace.cleanup();
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
|
|
2390
|
+
it('refuses a serial group scoped to a package that is not a member of the Cargo workspace', async () => {
|
|
2391
|
+
const workspace = await createWorkspace();
|
|
2392
|
+
try {
|
|
2393
|
+
await writeApfsSplitFixture(workspace, [
|
|
2394
|
+
'[test-groups.real-apfs]',
|
|
2395
|
+
'max-threads = 1',
|
|
2396
|
+
'',
|
|
2397
|
+
...serialOverride('package(cowshed-missing) and test(/real_apfs_/)', 'real-apfs'),
|
|
2398
|
+
]);
|
|
2399
|
+
// Nx wraps a createNodes throw in AggregateCreateNodesError, so the reason is in the nested error.
|
|
2400
|
+
const failure = await inferApfsSplit(workspace).then(
|
|
2401
|
+
() => undefined,
|
|
2402
|
+
(error: unknown) => error,
|
|
2403
|
+
);
|
|
2404
|
+
if (!(failure instanceof AggregateCreateNodesError)) {
|
|
2405
|
+
throw new Error(`expected AggregateCreateNodesError, got ${String(failure)}`);
|
|
2406
|
+
}
|
|
2407
|
+
expect(failure.errors[0]?.[1]?.message).toMatch(
|
|
2408
|
+
/test-group "real-apfs" selects package\(cowshed-missing\), which is not a member of the Cargo workspace/,
|
|
2409
|
+
);
|
|
2410
|
+
} finally {
|
|
2411
|
+
await workspace.cleanup();
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
|
|
2415
|
+
it('keeps cargo-test and test to the ordinary suite, so no gate of the root or a member reaches a serial group', async () => {
|
|
2416
|
+
const workspace = await createWorkspace();
|
|
2417
|
+
try {
|
|
2418
|
+
await writeApfsSplitFixture(workspace, APFS_SPLIT_GROUPS);
|
|
2419
|
+
const macos = await inferApfsSplit(workspace);
|
|
2420
|
+
const root = macos.get('.') ?? {};
|
|
2421
|
+
const cowshed = macos.get('packages/cowshed') ?? {};
|
|
2422
|
+
const lmao = macos.get('packages/lmao') ?? {};
|
|
2423
|
+
|
|
2424
|
+
// `cargo-test` is the ordinary suite alone, whichever project owns the aggregate.
|
|
2425
|
+
expect(root['cargo-test']?.dependsOn).toEqual([
|
|
2426
|
+
{ projects: ['cowshed'], target: 'cargo-test-cowshed-apfs' },
|
|
2427
|
+
{ projects: ['cowshed'], target: 'cargo-test-cowshed-apfs-tests' },
|
|
2428
|
+
{ projects: ['cowshed'], target: 'cargo-test-cowshed-cli' },
|
|
2429
|
+
{ projects: ['cowshed'], target: 'cargo-test-cowshed-core' },
|
|
2430
|
+
{ projects: ['cowshed'], target: 'cargo-test-cowshed-os' },
|
|
2431
|
+
{ projects: ['lmao'], target: 'cargo-test-lmao-core' },
|
|
2432
|
+
]);
|
|
2433
|
+
expect(cowshed['cargo-test']?.dependsOn).toEqual([
|
|
2434
|
+
'cargo-test-cowshed-apfs',
|
|
2435
|
+
'cargo-test-cowshed-apfs-tests',
|
|
2436
|
+
'cargo-test-cowshed-cli',
|
|
2437
|
+
'cargo-test-cowshed-core',
|
|
2438
|
+
'cargo-test-cowshed-os',
|
|
2439
|
+
]);
|
|
2440
|
+
expect(lmao['cargo-test']?.dependsOn).toEqual(['cargo-test-lmao-core']);
|
|
2441
|
+
|
|
2442
|
+
// Ordinary test inference excludes serial groups at both the root and every member. Explicit repository
|
|
2443
|
+
// host aggregates, not inference, own those edges.
|
|
2444
|
+
for (const targets of [root, cowshed, lmao]) {
|
|
2445
|
+
expect(targets.test?.dependsOn).toEqual(['cargo-test']);
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
// Inference orders nothing between the groups: that edge is the repository's explicit config.
|
|
2449
|
+
for (const name of ['cargo-test-group-real-apfs', 'cargo-test-group-real-apfs-host']) {
|
|
2450
|
+
expect(root[name]?.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive']);
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
// Every crate piece, scoped to a package the groups hold or not, excludes both groups' tests.
|
|
2454
|
+
const exclusion =
|
|
2455
|
+
'not ((package(cowshed-apfs-tests) and test(/real_apfs_/)) or ' +
|
|
2456
|
+
'(package(cowshed-core) and (test(/real_apfs_/) or binary(apfs_native_macos))) or ' +
|
|
2457
|
+
'(package(cowshed-cli) and test(/real_apfs_/)))';
|
|
2458
|
+
const pieces: ReadonlyArray<readonly [TargetConfiguration | undefined, string]> = [
|
|
2459
|
+
[cowshed['cargo-test-cowshed-apfs'], 'cowshed-apfs'],
|
|
2460
|
+
[cowshed['cargo-test-cowshed-apfs-tests'], 'cowshed-apfs-tests'],
|
|
2461
|
+
[lmao['cargo-test-lmao-core'], 'lmao-core'],
|
|
2462
|
+
];
|
|
2463
|
+
for (const [piece, crate] of pieces) {
|
|
2464
|
+
expect(piece?.options?.command, crate).toContain(
|
|
2465
|
+
`-E 'package(${crate}) and ${exclusion}' --no-fail-fast --no-tests=pass`,
|
|
2466
|
+
);
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
// Off macOS the groups are not inferred at all, and the gate is the same ordinary suite.
|
|
2470
|
+
const linux = await inferApfsSplit(workspace, createNodesV2ForPlatform('linux', 'x64'));
|
|
2471
|
+
expect(linux.get('.')?.test?.dependsOn).toEqual(['cargo-test']);
|
|
2472
|
+
expect(linux.get('packages/cowshed')?.test?.dependsOn).toEqual(['cargo-test']);
|
|
2473
|
+
expect(linux.get('.')?.['cargo-test-group-real-apfs-host']).toBeUndefined();
|
|
2474
|
+
} finally {
|
|
2475
|
+
await workspace.cleanup();
|
|
2476
|
+
}
|
|
2477
|
+
});
|
|
2478
|
+
|
|
2479
|
+
it('runs the host group after the device group through the explicit targetDefaults edge, and no test gate runs either', async () => {
|
|
2480
|
+
const workspace = await createWorkspace();
|
|
2481
|
+
try {
|
|
2482
|
+
await writeApfsSplitFixture(workspace, APFS_SPLIT_GROUPS);
|
|
2483
|
+
const macos = await inferApfsSplit(workspace);
|
|
2484
|
+
const rootProject = '@fixture/codebase';
|
|
2485
|
+
const rootTargets = macos.get('.') ?? {};
|
|
2486
|
+
|
|
2487
|
+
// The edge as the repository's nx.json states it. Nx expands `...` to the inferred list, so the
|
|
2488
|
+
// archive and the locked fetch stay ahead of the host group beside the device group.
|
|
2489
|
+
const nxJson = {
|
|
2490
|
+
targetDefaults: { 'cargo-test-group-real-apfs-host': { dependsOn: ['...', 'cargo-test-group-real-apfs'] } },
|
|
2491
|
+
};
|
|
2492
|
+
let host = rootTargets['cargo-test-group-real-apfs-host'] ?? {};
|
|
2493
|
+
for (const [, , result] of createTargetDefaultsResults(
|
|
2494
|
+
{ '.': { root: '.', targets: rootTargets } },
|
|
2495
|
+
{},
|
|
2496
|
+
nxJson,
|
|
2497
|
+
)) {
|
|
2498
|
+
const target = result.projects?.['.']?.targets?.['cargo-test-group-real-apfs-host'];
|
|
2499
|
+
if (target) host = mergeTargetConfigurations(target, host);
|
|
2500
|
+
}
|
|
2501
|
+
expect(host.dependsOn).toEqual(['cargo-fetch', 'cargo-test-archive', 'cargo-test-group-real-apfs']);
|
|
2502
|
+
|
|
2503
|
+
const nodes: Record<string, ProjectGraphProjectNode> = {
|
|
2504
|
+
[rootProject]: {
|
|
2505
|
+
name: rootProject,
|
|
2506
|
+
type: 'app',
|
|
2507
|
+
data: { root: '.', targets: { ...rootTargets, 'cargo-test-group-real-apfs-host': host } },
|
|
2508
|
+
},
|
|
2509
|
+
cowshed: {
|
|
2510
|
+
name: 'cowshed',
|
|
2511
|
+
type: 'lib',
|
|
2512
|
+
data: { root: 'packages/cowshed', targets: macos.get('packages/cowshed') ?? {} },
|
|
2513
|
+
},
|
|
2514
|
+
lmao: {
|
|
2515
|
+
name: 'lmao',
|
|
2516
|
+
type: 'lib',
|
|
2517
|
+
data: { root: 'packages/lmao', targets: macos.get('packages/lmao') ?? {} },
|
|
2518
|
+
},
|
|
2519
|
+
};
|
|
2520
|
+
const graph: ProjectGraph = { nodes, dependencies: { [rootProject]: [], cowshed: [], lmao: [] } };
|
|
2521
|
+
const task = (project: string, target: string): string => `${project}:${target}`;
|
|
2522
|
+
// Every task `from` waits on, directly or through the tasks it waits on.
|
|
2523
|
+
const reached = (dependencies: Record<string, string[]>, from: string): string[] => {
|
|
2524
|
+
const seen = new Set<string>();
|
|
2525
|
+
const pending = [from];
|
|
2526
|
+
while (pending.length > 0) {
|
|
2527
|
+
const next = pending.pop();
|
|
2528
|
+
if (next === undefined || seen.has(next)) continue;
|
|
2529
|
+
seen.add(next);
|
|
2530
|
+
pending.push(...(dependencies[next] ?? []));
|
|
2531
|
+
}
|
|
2532
|
+
return [...seen];
|
|
2533
|
+
};
|
|
2534
|
+
const groupsReached = (dependencies: Record<string, string[]>, from: string): string[] =>
|
|
2535
|
+
reached(dependencies, from).filter((id) => id.includes(':cargo-test-group-'));
|
|
2536
|
+
const device = task(rootProject, 'cargo-test-group-real-apfs');
|
|
2537
|
+
const hosted = task(rootProject, 'cargo-test-group-real-apfs-host');
|
|
2538
|
+
|
|
2539
|
+
// The task graph `nx run-many -t test` runs reaches neither group, from the root or from a member.
|
|
2540
|
+
for (const project of [rootProject, 'cowshed']) {
|
|
2541
|
+
const gate = createTaskGraph(graph, {}, [project], ['test'], undefined, {});
|
|
2542
|
+
expect(groupsReached(gate.dependencies, task(project, 'test'))).toEqual([]);
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
// When a run selects both groups, the host starts only once the device group is done, so two real-image
|
|
2546
|
+
// runners never overlap, and the device group waits on no other group.
|
|
2547
|
+
const named = createTaskGraph(
|
|
2548
|
+
graph,
|
|
2549
|
+
{},
|
|
2550
|
+
[rootProject],
|
|
2551
|
+
['test', 'cargo-test-group-real-apfs', 'cargo-test-group-real-apfs-host'],
|
|
2552
|
+
undefined,
|
|
2553
|
+
{},
|
|
2554
|
+
);
|
|
2555
|
+
expect(named.dependencies[hosted]).toContain(device);
|
|
2556
|
+
expect(groupsReached(named.dependencies, device)).toEqual([device]);
|
|
2557
|
+
expect(groupsReached(named.dependencies, task(rootProject, 'test'))).toEqual([]);
|
|
1962
2558
|
} finally {
|
|
1963
2559
|
await workspace.cleanup();
|
|
1964
2560
|
}
|
|
@@ -2050,7 +2646,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2050
2646
|
// One added edge per target. Everything that makes each target do its job
|
|
2051
2647
|
// — executor, options, inputs, cache — must survive the declaration
|
|
2052
2648
|
// instead of being replaced wholesale by it.
|
|
2053
|
-
'cargo-test': { dependsOn: ['cargo-test-
|
|
2649
|
+
'cargo-test': { dependsOn: ['cargo-test-ferris-core', 'cargo-wasm'] },
|
|
2054
2650
|
'cargo-test-compile': { dependsOn: ['cargo-wasm'] },
|
|
2055
2651
|
'cargo-lint': { inputs: ['{projectRoot}/clippy.toml'] },
|
|
2056
2652
|
mutation: { options: { command: 'cargo mutants --in-diff' } },
|
|
@@ -2061,30 +2657,27 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2061
2657
|
'packages/ferris/package.json',
|
|
2062
2658
|
JSON.stringify({ name: 'ferris', nx: { targets: declared } }),
|
|
2063
2659
|
);
|
|
2064
|
-
await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = []\n');
|
|
2660
|
+
await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = ["crates/ferris-core"]\n');
|
|
2661
|
+
await workspace.write('packages/ferris/crates/ferris-core/Cargo.toml', '[package]\nname = "ferris-core"\n');
|
|
2065
2662
|
|
|
2066
2663
|
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
2067
2664
|
|
|
2068
|
-
//
|
|
2069
|
-
//
|
|
2070
|
-
|
|
2071
|
-
expect(targets['cargo-test']?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
2665
|
+
// The aggregate stays a no-op that reaches bounded crate runners. A
|
|
2666
|
+
// partial declaration must keep that inferred base, not erase the chain.
|
|
2667
|
+
expect(targets['cargo-test']?.executor).toBe('nx:noop');
|
|
2668
|
+
expect(targets['cargo-test-ferris-core']?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
2072
2669
|
expect(targets['cargo-test-compile']?.executor).toBe('nx:run-commands');
|
|
2073
2670
|
expect(targets['cargo-lint']?.options).toMatchObject({
|
|
2074
2671
|
commands: ['cargo fmt --all --check', CARGO_LINT_CLIPPY_COMMAND],
|
|
2075
2672
|
});
|
|
2076
2673
|
|
|
2077
2674
|
const cargoTest = resolveDeclaredOverInferred(targets, declared, 'cargo-test');
|
|
2078
|
-
expect(cargoTest?.executor).toBe('
|
|
2675
|
+
expect(cargoTest?.executor).toBe('nx:noop');
|
|
2079
2676
|
expect(cargoTest?.cache).toBe(true);
|
|
2080
|
-
expect(cargoTest?.dependsOn).toEqual(['cargo-test-
|
|
2081
|
-
expect(cargoTest?.options).
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
timeoutMs: 120000,
|
|
2085
|
-
killAfterMs: 10000,
|
|
2086
|
-
});
|
|
2087
|
-
expect(cargoTest?.inputs).toContain('{projectRoot}/**/*.rs');
|
|
2677
|
+
expect(cargoTest?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-wasm']);
|
|
2678
|
+
expect(cargoTest?.options).toBeUndefined();
|
|
2679
|
+
expect(targets['cargo-test-ferris-core']?.options?.command).toContain("-E 'package(ferris-core)'");
|
|
2680
|
+
expect(targets['cargo-test-ferris-core']?.options?.idleTimeoutMs).toBe(BOUNDED_TEST_IDLE_TIMEOUT_MS);
|
|
2088
2681
|
|
|
2089
2682
|
const cargoTestCompile = resolveDeclaredOverInferred(targets, declared, 'cargo-test-compile');
|
|
2090
2683
|
expect(cargoTestCompile?.executor).toBe('nx:run-commands');
|
|
@@ -2119,7 +2712,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2119
2712
|
it('lets a declared dependsOn spread expand the inferred cargo chain', async () => {
|
|
2120
2713
|
const workspace = await createWorkspace();
|
|
2121
2714
|
// Additive intent has Nx's own spelling: `'...'` expands the inferred list
|
|
2122
|
-
// at the token, so an added edge keeps the cargo
|
|
2715
|
+
// at the token, so an added edge keeps the inferred cargo edges.
|
|
2123
2716
|
const declared: Record<string, TargetConfiguration> = {
|
|
2124
2717
|
'cargo-test': { dependsOn: ['...', 'cargo-wasm'] },
|
|
2125
2718
|
};
|
|
@@ -2128,15 +2721,16 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2128
2721
|
'packages/ferris/package.json',
|
|
2129
2722
|
JSON.stringify({ name: 'ferris', nx: { targets: declared } }),
|
|
2130
2723
|
);
|
|
2131
|
-
await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = []\n');
|
|
2724
|
+
await workspace.write('packages/ferris/Cargo.toml', '[workspace]\nmembers = ["crates/ferris-core"]\n');
|
|
2725
|
+
await workspace.write('packages/ferris/crates/ferris-core/Cargo.toml', '[package]\nname = "ferris-core"\n');
|
|
2132
2726
|
|
|
2133
2727
|
const targets = await inferProjectTargets(workspace, 'packages/ferris/package.json');
|
|
2134
2728
|
|
|
2135
2729
|
// The spread expands exactly once, against the single inferred base this
|
|
2136
2730
|
// plugin emits — re-implementing the overlay here would double it.
|
|
2137
2731
|
const cargoTest = resolveDeclaredOverInferred(targets, declared, 'cargo-test');
|
|
2138
|
-
expect(cargoTest?.dependsOn).toEqual(['cargo-
|
|
2139
|
-
expect(cargoTest?.executor).toBe('
|
|
2732
|
+
expect(cargoTest?.dependsOn).toEqual(['cargo-test-ferris-core', 'cargo-wasm']);
|
|
2733
|
+
expect(cargoTest?.executor).toBe('nx:noop');
|
|
2140
2734
|
} finally {
|
|
2141
2735
|
await workspace.cleanup();
|
|
2142
2736
|
}
|
|
@@ -2276,83 +2870,39 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2276
2870
|
|
|
2277
2871
|
it('orders a three-project chain of INFERRED deploys through one run-many', async () => {
|
|
2278
2872
|
const workspace = await createWorkspace();
|
|
2279
|
-
|
|
2280
|
-
|
|
2873
|
+
// c is deepest: a's deploy calls into b's, b's calls into c's. No project declares a deploy
|
|
2874
|
+
// target — each only has a wrangler manifest and, where it needs ordering, the edge. Nothing
|
|
2875
|
+
// here says "round one" or "round two", and no project knows the depth.
|
|
2876
|
+
const chain: Record<string, string[]> = { a: ['b:deploy'], b: ['c:deploy'], c: [] };
|
|
2281
2877
|
try {
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
JSON.stringify({
|
|
2287
|
-
plugins: [fileURLToPath(new URL('../dist/index.js', import.meta.url))],
|
|
2288
|
-
namedInputs: { default: ['{projectRoot}/**/*'] },
|
|
2289
|
-
}),
|
|
2290
|
-
);
|
|
2291
|
-
// c is deepest: a's deploy calls into b's, b's calls into c's. No project declares a
|
|
2292
|
-
// deploy target — each only has a wrangler manifest and, where it needs ordering, the
|
|
2293
|
-
// edge. Nothing here says "round one" or "round two", and no project knows the depth.
|
|
2294
|
-
const chain: Record<string, string[]> = { a: ['b:deploy'], b: ['c:deploy'], c: [] };
|
|
2295
|
-
for (const [name, dependsOn] of Object.entries(chain)) {
|
|
2878
|
+
const nodes: Record<string, ProjectGraphProjectNode> = {};
|
|
2879
|
+
for (const [name, edges] of Object.entries(chain)) {
|
|
2880
|
+
const declared: Record<string, TargetConfiguration> =
|
|
2881
|
+
edges.length > 0 ? { deploy: { dependsOn: ['...', ...edges] } } : {};
|
|
2296
2882
|
await workspace.write(`packages/${name}/wrangler.toml`, `name = "${name}"\n`);
|
|
2297
2883
|
await workspace.write(
|
|
2298
2884
|
`packages/${name}/package.json`,
|
|
2299
|
-
JSON.stringify({
|
|
2300
|
-
name,
|
|
2301
|
-
private: true,
|
|
2302
|
-
nx: {
|
|
2303
|
-
targets: {
|
|
2304
|
-
deploy: {
|
|
2305
|
-
...(dependsOn.length > 0 ? { dependsOn: ['...', ...dependsOn] } : {}),
|
|
2306
|
-
// The real inferred command deploys to Cloudflare. Only `command` is
|
|
2307
|
-
// overridden, so this still proves the rest of the inferred target — the
|
|
2308
|
-
// executor that runs it, and the edges — is what carries the run.
|
|
2309
|
-
options: {
|
|
2310
|
-
command: `printf '%s\\n' ${name} >> ${join(root, 'deploy-order.txt')}`,
|
|
2311
|
-
forwardAllArgs: false,
|
|
2312
|
-
},
|
|
2313
|
-
},
|
|
2314
|
-
},
|
|
2315
|
-
},
|
|
2316
|
-
}),
|
|
2885
|
+
JSON.stringify({ name, private: true, nx: { targets: declared } }),
|
|
2317
2886
|
);
|
|
2887
|
+
const targets = await inferProjectTargets(workspace, `packages/${name}/package.json`);
|
|
2888
|
+
const deploy = resolveDeclaredOverInferred(targets, declared, 'deploy');
|
|
2889
|
+
// The edge rides on the inferred target: its executor and command still carry the run.
|
|
2890
|
+
expect(deploy?.executor).toBe('nx:run-commands');
|
|
2891
|
+
expect(deploy?.options?.command).toBe('smoo wrangler deploy-stage --stage {args.stage}');
|
|
2892
|
+
if (deploy === undefined) throw new Error(`${name} infers no deploy`);
|
|
2893
|
+
nodes[name] = { name, type: 'app', data: { root: `packages/${name}`, targets: { ...targets, deploy } } };
|
|
2318
2894
|
}
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
'--projects=a,b,c',
|
|
2327
|
-
'--parallel=3',
|
|
2328
|
-
'--stage=staging',
|
|
2329
|
-
],
|
|
2330
|
-
{
|
|
2331
|
-
cwd: root,
|
|
2332
|
-
env: {
|
|
2333
|
-
...process.env,
|
|
2334
|
-
PATH: `${join(repositoryRoot, 'node_modules/.bin')}:${process.env.PATH ?? ''}`,
|
|
2335
|
-
NX_DAEMON: 'false',
|
|
2336
|
-
NX_ISOLATE_PLUGINS: 'false',
|
|
2337
|
-
NX_WORKSPACE_DATA_DIRECTORY: join(root, '.nx/workspace-data'),
|
|
2338
|
-
NX_CACHE_DIRECTORY: join(root, '.nx/cache'),
|
|
2339
|
-
},
|
|
2340
|
-
stdout: 'pipe',
|
|
2341
|
-
stderr: 'pipe',
|
|
2342
|
-
},
|
|
2343
|
-
);
|
|
2344
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
2345
|
-
child.exited,
|
|
2346
|
-
new Response(child.stdout).text(),
|
|
2347
|
-
new Response(child.stderr).text(),
|
|
2348
|
-
]);
|
|
2349
|
-
expect({ exitCode, output: stdout + stderr }).toMatchObject({ exitCode: 0 });
|
|
2350
|
-
const order = (await readFile(join(root, 'deploy-order.txt'), 'utf8')).trim().split('\n');
|
|
2351
|
-
expect(order).toEqual(['c', 'b', 'a']);
|
|
2895
|
+
const graph: ProjectGraph = { nodes, dependencies: { a: [], b: [], c: [] } };
|
|
2896
|
+
|
|
2897
|
+
// The task graph `nx run-many -t deploy --projects=a,b,c` runs: Nx starts a task only once
|
|
2898
|
+
// every task it depends on has finished, so this is the order.
|
|
2899
|
+
const tasks = createTaskGraph(graph, {}, ['a', 'b', 'c'], ['deploy'], undefined, { stage: 'staging' });
|
|
2900
|
+
expect(tasks.dependencies).toEqual({ 'a:deploy': ['b:deploy'], 'b:deploy': ['c:deploy'], 'c:deploy': [] });
|
|
2901
|
+
expect(tasks.roots).toEqual(['c:deploy']);
|
|
2352
2902
|
} finally {
|
|
2353
2903
|
await workspace.cleanup();
|
|
2354
2904
|
}
|
|
2355
|
-
}
|
|
2905
|
+
});
|
|
2356
2906
|
|
|
2357
2907
|
it('archives a declared foreign triple beside the host archive, and runs it without building', async () => {
|
|
2358
2908
|
const workspace = await createWorkspace();
|
|
@@ -2373,8 +2923,8 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2373
2923
|
|
|
2374
2924
|
// A distinct archive file, declared as this target's output: the host
|
|
2375
2925
|
// archive must survive a cross build and each must be cached as itself.
|
|
2376
|
-
expect(archive?.outputs).toEqual(['{projectRoot}/
|
|
2377
|
-
expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/
|
|
2926
|
+
expect(archive?.outputs).toEqual(['{projectRoot}/.cache/nextest/archive-aarch64-apple-darwin.tar.zst']);
|
|
2927
|
+
expect(targets['cargo-test-archive']?.outputs).toEqual(['{projectRoot}/.cache/nextest/archive.tar.zst']);
|
|
2378
2928
|
expect(archive?.cache).toBe(true);
|
|
2379
2929
|
// Everything the host archive hashes, plus the declared driver: the
|
|
2380
2930
|
// script that decides how the foreign link happens is an input of the
|
|
@@ -2386,11 +2936,11 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2386
2936
|
expect(archive?.options?.env).toEqual({ CARGO: 'scripts/cargo-for-nextest.sh' });
|
|
2387
2937
|
// The runner needs no driver: it never invokes cargo at all.
|
|
2388
2938
|
expect(run?.options?.env).toBeUndefined();
|
|
2389
|
-
expect(archive?.options?.commands
|
|
2939
|
+
expect(archive?.options?.commands).toBeUndefined();
|
|
2390
2940
|
// `cargo-nextest`, not `cargo nextest`: cargo overwrites CARGO for its
|
|
2391
2941
|
// subcommands, and CARGO is the only seam a cross cargo driver has.
|
|
2392
|
-
expect(String(archive?.options?.
|
|
2393
|
-
/^cargo-nextest nextest archive --workspace --target aarch64-apple-darwin --frozen --archive-file
|
|
2942
|
+
expect(String(archive?.options?.command)).toMatch(
|
|
2943
|
+
/^mkdir -p \.cache\/nextest && cargo-nextest nextest archive --workspace --target aarch64-apple-darwin --frozen --archive-file \.cache\/nextest\/archive-aarch64-apple-darwin\.tar\.zst --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
2394
2944
|
);
|
|
2395
2945
|
expect(archive?.configurations?.[RELEASE_CONFIGURATION]).toBeUndefined();
|
|
2396
2946
|
expect(run?.configurations?.[RELEASE_CONFIGURATION]).toBeUndefined();
|
|
@@ -2399,7 +2949,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2399
2949
|
expect(archive?.dependsOn).toEqual(['cargo-fetch']);
|
|
2400
2950
|
expect(run?.dependsOn).toEqual([]);
|
|
2401
2951
|
expect(String(run?.options?.command)).toMatch(
|
|
2402
|
-
/^cargo-nextest nextest run --archive-file
|
|
2952
|
+
/^cargo-nextest nextest run --archive-file \.cache\/nextest\/archive-aarch64-apple-darwin\.tar\.zst --workspace-remap \. --no-tests=pass --user-config-file none --tool-config-file "smoo:\$PWD\/.*nextest\.toml"$/,
|
|
2403
2953
|
);
|
|
2404
2954
|
expect(run?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
2405
2955
|
// Not a crate: the per-crate coverage policy reads `cargo-test-<name>`,
|
|
@@ -2409,6 +2959,7 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2409
2959
|
expect(packageNameFromCargoTestTarget('cargo-cross-test-aarch64-apple-darwin')).toBeNull();
|
|
2410
2960
|
expect(targets['cargo-test']?.dependsOn).toEqual(['cargo-test-ferris-core']);
|
|
2411
2961
|
expect(targets.build?.dependsOn ?? []).not.toContain('cargo-cross-test-archive-aarch64-apple-darwin');
|
|
2962
|
+
expectNoSchedulerThrottle(targets);
|
|
2412
2963
|
} finally {
|
|
2413
2964
|
await workspace.cleanup();
|
|
2414
2965
|
}
|
|
@@ -2440,8 +2991,50 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2440
2991
|
//#endregion
|
|
2441
2992
|
});
|
|
2442
2993
|
|
|
2443
|
-
|
|
2444
|
-
|
|
2994
|
+
/**
|
|
2995
|
+
* Target-inference fixtures declare real Cargo workspaces. Supply their empty
|
|
2996
|
+
* Rust library and initial lock before inference, rather than relying on a
|
|
2997
|
+
* rejected Cargo query. Explicit sources and locks, including planted failures,
|
|
2998
|
+
* remain untouched.
|
|
2999
|
+
*/
|
|
3000
|
+
async function prepareCargoFixture(root: string): Promise<void> {
|
|
3001
|
+
const manifests = (await readdir(root, { recursive: true }))
|
|
3002
|
+
.filter((path) => path === 'Cargo.toml' || path.endsWith('/Cargo.toml'))
|
|
3003
|
+
.filter((path) => !path.split('/').some((part) => ['node_modules', 'target', '.nx'].includes(part)));
|
|
3004
|
+
const workspaces: string[] = [];
|
|
3005
|
+
for (const manifest of manifests) {
|
|
3006
|
+
const path = join(root, manifest);
|
|
3007
|
+
const contents = await readFile(path, 'utf8');
|
|
3008
|
+
if (/^\[package\]\s*$/m.test(contents)) {
|
|
3009
|
+
const source = join(dirname(path), 'src/lib.rs');
|
|
3010
|
+
if (!(await Bun.file(source).exists())) {
|
|
3011
|
+
await mkdir(dirname(source), { recursive: true });
|
|
3012
|
+
await writeFile(source, '// Empty Cargo fixture library.\n');
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
if (/^\[workspace\]\s*$/m.test(contents)) workspaces.push(path);
|
|
3016
|
+
}
|
|
3017
|
+
for (const manifest of workspaces) {
|
|
3018
|
+
if (await Bun.file(join(dirname(manifest), 'Cargo.lock')).exists()) continue;
|
|
3019
|
+
const child = Bun.spawn(['cargo', 'generate-lockfile', '--offline', '--manifest-path', manifest], {
|
|
3020
|
+
env: process.env,
|
|
3021
|
+
cwd: root,
|
|
3022
|
+
stdout: 'pipe',
|
|
3023
|
+
stderr: 'pipe',
|
|
3024
|
+
});
|
|
3025
|
+
const [code, stdout, stderr] = await Promise.all([
|
|
3026
|
+
child.exited,
|
|
3027
|
+
new Response(child.stdout).text(),
|
|
3028
|
+
new Response(child.stderr).text(),
|
|
3029
|
+
]);
|
|
3030
|
+
if (code !== 0) throw new Error(`Cargo fixture ${manifest} could not lock:\n${stdout}${stderr}`);
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
async function createWorkspace(parent = tmpdir()): Promise<WorkspaceFixture> {
|
|
3035
|
+
// Canonical, because macOS puts the temp directory behind a /private symlink
|
|
3036
|
+
// and a daemon never sees an edit made under a root named through one.
|
|
3037
|
+
const root = await realpath(await mkdtemp(join(parent, 'smoothbricks-nx-plugin-')));
|
|
2445
3038
|
|
|
2446
3039
|
return {
|
|
2447
3040
|
context: {
|
|
@@ -2528,24 +3121,16 @@ function cachedCargoTargets(targets: Record<string, TargetConfiguration>): [stri
|
|
|
2528
3121
|
});
|
|
2529
3122
|
}
|
|
2530
3123
|
|
|
2531
|
-
/** What Nx actually hashes for a `runtime` input: the command's stdout. */
|
|
2532
|
-
async function runtimeInputValue(command: string, cwd: string): Promise<string> {
|
|
2533
|
-
const child = Bun.spawn(['sh', '-c', command], { cwd, stdout: 'pipe', stderr: 'pipe' });
|
|
2534
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
2535
|
-
child.exited,
|
|
2536
|
-
new Response(child.stdout).text(),
|
|
2537
|
-
new Response(child.stderr).text(),
|
|
2538
|
-
]);
|
|
2539
|
-
expect({ command, exitCode, stderr }).toMatchObject({ command, exitCode: 0 });
|
|
2540
|
-
return stdout;
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
3124
|
async function inferProject(
|
|
2544
3125
|
workspace: WorkspaceFixture,
|
|
2545
3126
|
packageJsonPath: string,
|
|
2546
3127
|
createNodes: CreateNodesV2 = createNodesV2,
|
|
2547
3128
|
) {
|
|
2548
3129
|
const [, infer] = createNodes;
|
|
3130
|
+
await prepareCargoFixture(workspace.context.workspaceRoot);
|
|
3131
|
+
// Each inference indexes the tree as it is now, as a fresh Nx process would: the
|
|
3132
|
+
// in-process workspace context otherwise keeps the files of the first inference.
|
|
3133
|
+
resetWorkspaceContext();
|
|
2549
3134
|
const result = await infer([packageJsonPath], undefined, workspace.context);
|
|
2550
3135
|
return result[0]?.[1].projects?.[dirname(packageJsonPath)];
|
|
2551
3136
|
}
|
|
@@ -2561,6 +3146,8 @@ async function inferProjectWithNxJson(
|
|
|
2561
3146
|
nxJsonConfiguration: CreateNodesContextV2['nxJsonConfiguration'],
|
|
2562
3147
|
) {
|
|
2563
3148
|
const [, infer] = createNodesV2;
|
|
3149
|
+
await prepareCargoFixture(workspace.context.workspaceRoot);
|
|
3150
|
+
resetWorkspaceContext();
|
|
2564
3151
|
const result = await infer([packageJsonPath], undefined, {
|
|
2565
3152
|
workspaceRoot: workspace.context.workspaceRoot,
|
|
2566
3153
|
nxJsonConfiguration,
|
|
@@ -2629,3 +3216,126 @@ function cargoPackageSelection(command: string): {
|
|
|
2629
3216
|
),
|
|
2630
3217
|
};
|
|
2631
3218
|
}
|
|
3219
|
+
|
|
3220
|
+
/**
|
|
3221
|
+
* Inference never throttles the scheduler: no target is exclusive and no
|
|
3222
|
+
* run-commands target is run one command at a time. A pair that really is
|
|
3223
|
+
* producer and consumer is one `&&` command; everything else is left to Nx and
|
|
3224
|
+
* to the locks Cargo owns.
|
|
3225
|
+
*/
|
|
3226
|
+
function expectNoSchedulerThrottle(targets: Record<string, TargetConfiguration>): void {
|
|
3227
|
+
for (const [name, target] of Object.entries(targets)) {
|
|
3228
|
+
expect(target.parallelism, `${name} parallelism`).toBeUndefined();
|
|
3229
|
+
expect(target.options?.parallel, `${name} options.parallel`).toBeUndefined();
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
/** A default-profile override that puts the tests `filter` selects in `group`, on the platform serial groups run on. */
|
|
3234
|
+
function serialOverride(filter: string, group: string): string[] {
|
|
3235
|
+
return [
|
|
3236
|
+
'[[profile.default.overrides]]',
|
|
3237
|
+
`filter = '${filter}'`,
|
|
3238
|
+
`platform = 'cfg(target_os="macos")'`,
|
|
3239
|
+
`test-group = '${group}'`,
|
|
3240
|
+
'',
|
|
3241
|
+
];
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
/** The real-image split in miniature: a device group over one crate, a host group over the two crates above it. */
|
|
3245
|
+
const APFS_SPLIT_GROUPS: readonly string[] = [
|
|
3246
|
+
'[test-groups.real-apfs]',
|
|
3247
|
+
'max-threads = 1',
|
|
3248
|
+
'',
|
|
3249
|
+
'[test-groups.real-apfs-host]',
|
|
3250
|
+
'max-threads = 1',
|
|
3251
|
+
'',
|
|
3252
|
+
...serialOverride('package(cowshed-apfs-tests) and test(/real_apfs_/)', 'real-apfs'),
|
|
3253
|
+
...serialOverride('package(cowshed-core) and (test(/real_apfs_/) or binary(apfs_native_macos))', 'real-apfs-host'),
|
|
3254
|
+
...serialOverride('package(cowshed-cli) and test(/real_apfs_/)', 'real-apfs-host'),
|
|
3255
|
+
];
|
|
3256
|
+
|
|
3257
|
+
/**
|
|
3258
|
+
* A repository-root Cargo workspace with two projects: `cowshed` holds the production device layer (`cowshed-apfs`,
|
|
3259
|
+
* which links `cowshed-os` and carries the test support the crates above it compile in), the real-image scenarios in a
|
|
3260
|
+
* crate of their own (`cowshed-apfs-tests`, which nothing depends on) and the host crates, and `lmao` holds a crate no
|
|
3261
|
+
* group can reach. `nextest` is the repository's `.config/nextest.toml`.
|
|
3262
|
+
*/
|
|
3263
|
+
async function writeApfsSplitFixture(workspace: WorkspaceFixture, nextest: readonly string[]): Promise<void> {
|
|
3264
|
+
const crate = (
|
|
3265
|
+
project: string,
|
|
3266
|
+
name: string,
|
|
3267
|
+
dependencies: readonly string[] = [],
|
|
3268
|
+
section: 'dependencies' | 'dev-dependencies' = 'dependencies',
|
|
3269
|
+
): Promise<void> =>
|
|
3270
|
+
workspace.write(
|
|
3271
|
+
`packages/${project}/crates/${name}/Cargo.toml`,
|
|
3272
|
+
[
|
|
3273
|
+
'[package]',
|
|
3274
|
+
`name = "${name}"`,
|
|
3275
|
+
...(dependencies.length === 0
|
|
3276
|
+
? []
|
|
3277
|
+
: ['', `[${section}]`, ...dependencies.map((dependency) => `${dependency} = { path = "../${dependency}" }`)]),
|
|
3278
|
+
'',
|
|
3279
|
+
].join('\n'),
|
|
3280
|
+
);
|
|
3281
|
+
await workspace.write('package.json', '{"name":"@fixture/codebase"}\n');
|
|
3282
|
+
await workspace.write('packages/cowshed/package.json', '{"name":"@fixture/cowshed","nx":{"name":"cowshed"}}\n');
|
|
3283
|
+
await workspace.write('packages/lmao/package.json', '{"name":"@fixture/lmao","nx":{"name":"lmao"}}\n');
|
|
3284
|
+
await workspace.write('Cargo.toml', '[workspace]\nmembers = ["packages/*/crates/*"]\n');
|
|
3285
|
+
await crate('cowshed', 'cowshed-os');
|
|
3286
|
+
await crate('cowshed', 'cowshed-apfs', ['cowshed-os']);
|
|
3287
|
+
await crate('cowshed', 'cowshed-apfs-tests', ['cowshed-apfs', 'cowshed-os'], 'dev-dependencies');
|
|
3288
|
+
await crate('cowshed', 'cowshed-core', ['cowshed-apfs', 'cowshed-os']);
|
|
3289
|
+
await crate('cowshed', 'cowshed-cli', ['cowshed-core']);
|
|
3290
|
+
await crate('lmao', 'lmao-core');
|
|
3291
|
+
await workspace.write(
|
|
3292
|
+
'packages/cowshed/crates/cowshed-apfs/tests/support/blank_image.rs',
|
|
3293
|
+
'// shared test support\n',
|
|
3294
|
+
);
|
|
3295
|
+
await workspace.write('.config/nextest.toml', nextest.join('\n'));
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
/** Inference over the split fixture's three projects in the one call Nx makes: project root to inferred targets. */
|
|
3299
|
+
async function inferApfsSplit(
|
|
3300
|
+
workspace: WorkspaceFixture,
|
|
3301
|
+
createNodes: CreateNodesV2 = createNodesV2ForPlatform('darwin', 'arm64'),
|
|
3302
|
+
): Promise<Map<string, Record<string, TargetConfiguration>>> {
|
|
3303
|
+
const [, infer] = createNodes;
|
|
3304
|
+
await prepareCargoFixture(workspace.context.workspaceRoot);
|
|
3305
|
+
resetWorkspaceContext();
|
|
3306
|
+
const inferred = await infer(
|
|
3307
|
+
['package.json', 'packages/cowshed/package.json', 'packages/lmao/package.json'],
|
|
3308
|
+
undefined,
|
|
3309
|
+
workspace.context,
|
|
3310
|
+
);
|
|
3311
|
+
return new Map(
|
|
3312
|
+
inferred.flatMap(([, result]) =>
|
|
3313
|
+
Object.entries(result.projects ?? {}).map(([root, project]): [string, Record<string, TargetConfiguration>] => [
|
|
3314
|
+
root,
|
|
3315
|
+
project.targets ?? {},
|
|
3316
|
+
]),
|
|
3317
|
+
),
|
|
3318
|
+
);
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
/** The crates whose whole tree a target hashes: one `{workspaceRoot}/…/crates/<crate>/**\/*` fileset each. */
|
|
3322
|
+
function hashedCrates(target: TargetConfiguration | undefined): string[] {
|
|
3323
|
+
const crates = (target?.inputs ?? []).flatMap((input) =>
|
|
3324
|
+
typeof input === 'string'
|
|
3325
|
+
? (/^\{workspaceRoot\}\/packages\/[^/]+\/crates\/([^/]+)\/\*\*\/\*$/.exec(input)?.[1] ?? [])
|
|
3326
|
+
: [],
|
|
3327
|
+
);
|
|
3328
|
+
return [...new Set(crates)].sort((left, right) => left.localeCompare(right));
|
|
3329
|
+
}
|
|
3330
|
+
|
|
3331
|
+
/** Whether Nx would hash `path` (workspace-relative) under the `{workspaceRoot}` filesets of `target`'s inputs. */
|
|
3332
|
+
function hashes(target: TargetConfiguration | undefined, path: string): boolean {
|
|
3333
|
+
const filesets = (target?.inputs ?? []).flatMap((input) =>
|
|
3334
|
+
typeof input === 'string' && input.includes('{workspaceRoot}') ? [input] : [],
|
|
3335
|
+
);
|
|
3336
|
+
const matches = (fileset: string): boolean => new Bun.Glob(fileset.replace('{workspaceRoot}/', '')).match(path);
|
|
3337
|
+
return (
|
|
3338
|
+
filesets.some((input) => !input.startsWith('!') && matches(input)) &&
|
|
3339
|
+
!filesets.some((input) => input.startsWith('!') && matches(input.slice(1)))
|
|
3340
|
+
);
|
|
3341
|
+
}
|