@smoothbricks/nx-plugin 0.5.7 → 0.6.1
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 +1097 -360
- package/dist/.build-inputs.json +141 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts +3 -0
- package/dist/bin/smoo-nx-cargo-toolchain.d.ts.map +1 -0
- package/dist/bin/smoo-nx-cargo-toolchain.js +8 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts +3 -0
- package/dist/bin/smoo-nx-forbidden-spellings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-forbidden-spellings.js +32 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts +3 -0
- package/dist/bin/smoo-nx-nextest-timings.d.ts.map +1 -0
- package/dist/bin/smoo-nx-nextest-timings.js +28 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +14 -15
- package/dist/build-state-output-policy.d.ts +95 -1
- package/dist/build-state-output-policy.d.ts.map +1 -1
- package/dist/build-state-output-policy.js +368 -30
- package/dist/bun-lock-scope.d.ts +44 -0
- package/dist/bun-lock-scope.d.ts.map +1 -0
- package/dist/bun-lock-scope.js +97 -0
- package/dist/cargo-build-script-env.d.ts +49 -0
- package/dist/cargo-build-script-env.d.ts.map +1 -0
- package/dist/cargo-build-script-env.js +324 -0
- package/dist/cargo-closure-input.d.ts +31 -4
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +66 -6
- package/dist/cargo-retention-hook.d.ts +17 -0
- package/dist/cargo-retention-hook.d.ts.map +1 -0
- package/dist/cargo-retention-hook.js +85 -0
- package/dist/cargo-source-hash.d.ts +25 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +108 -43
- package/dist/cargo-toolchain-paths.d.ts +40 -0
- package/dist/cargo-toolchain-paths.d.ts.map +1 -0
- package/dist/cargo-toolchain-paths.js +84 -0
- package/dist/cargo-toolchain-policy.d.ts +25 -8
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +39 -5
- package/dist/cargo-workspace.d.ts +10 -4
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +65 -95
- package/dist/cross-check-policy.d.ts +9 -9
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +11 -11
- package/dist/disk-command-policy.d.ts.map +1 -1
- package/dist/disk-command-policy.js +1 -0
- package/dist/ensure-built-receipt.d.ts +22 -5
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +168 -48
- package/dist/ensure-built-witness.d.ts +27 -8
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +45 -15
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +9 -1
- package/dist/eslint-config-closure.d.ts +7 -0
- package/dist/eslint-config-closure.d.ts.map +1 -0
- package/dist/eslint-config-closure.js +346 -0
- package/dist/executors/bounded-exec/bounds.d.ts +56 -0
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -0
- package/dist/executors/bounded-exec/bounds.js +43 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +28 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.js +20 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +35 -38
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +56 -120
- package/dist/executors/bounded-exec/executor.d.ts +19 -12
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +389 -239
- package/dist/executors/bounded-exec/gateway-lease.d.ts +23 -19
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +102 -29
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +18 -1
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +148 -30
- package/dist/executors/bounded-exec/lease-wait.d.ts +64 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lease-wait.js +72 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts +51 -0
- package/dist/executors/bounded-exec/lock-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lock-wait.js +108 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +31 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/mbx-pool.js +24 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts +84 -0
- package/dist/executors/bounded-exec/owned-subtree.d.ts.map +1 -0
- package/dist/executors/bounded-exec/owned-subtree.js +178 -0
- package/dist/executors/bounded-exec/progress.d.ts +4 -1
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +5 -2
- package/dist/executors/bounded-exec/ram-attach.d.ts +19 -0
- package/dist/executors/bounded-exec/ram-attach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-attach.js +207 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts +25 -0
- package/dist/executors/bounded-exec/ram-detach.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-detach.js +207 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +76 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +296 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +388 -88
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +1213 -399
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +122 -35
- package/dist/executors/bounded-exec/runner-hook.js +14 -5
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +14 -1
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-lifecycle.js +27 -6
- package/dist/executors/bounded-exec/{cpu-tokens.d.ts → runner-sizing.d.ts} +14 -42
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -0
- package/dist/executors/bounded-exec/{cpu-tokens.js → runner-sizing.js} +5 -35
- package/dist/executors/bounded-exec/runtime-pin.d.ts +73 -0
- package/dist/executors/bounded-exec/runtime-pin.d.ts.map +1 -0
- package/dist/executors/bounded-exec/runtime-pin.js +167 -0
- package/dist/executors/bounded-exec/schema.d.ts +18 -1
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +48 -11
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +89 -20
- package/dist/executors/cargo-zigbuild/executor.d.ts +21 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +67 -12
- package/dist/executors/clean-outputs/executor.js +1 -0
- package/dist/executors/scriptc-native/executor.d.ts +79 -0
- package/dist/executors/scriptc-native/executor.d.ts.map +1 -0
- package/dist/executors/scriptc-native/executor.js +367 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts +9 -0
- package/dist/executors/scriptc-native/ffi-paths.d.ts.map +1 -0
- package/dist/executors/scriptc-native/ffi-paths.js +25 -0
- package/dist/executors/scriptc-native/schema.d.ts +34 -0
- package/dist/executors/scriptc-native/schema.d.ts.map +1 -0
- package/dist/executors/scriptc-native/schema.js +1 -0
- package/dist/executors/typescript-emit/emit-overrides.d.ts +14 -0
- package/dist/executors/typescript-emit/emit-overrides.d.ts.map +1 -0
- package/dist/executors/typescript-emit/emit-overrides.js +24 -0
- package/dist/executors/typescript-emit/executor.d.ts +3 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +146 -33
- package/dist/forbidden-spelling-policy.d.ts +56 -0
- package/dist/forbidden-spelling-policy.d.ts.map +1 -0
- package/dist/forbidden-spelling-policy.js +176 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +3 -4
- package/dist/graph-input-contract.d.ts +14 -0
- package/dist/graph-input-contract.d.ts.map +1 -1
- package/dist/graph-input-contract.js +67 -2
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +672 -214
- package/dist/managed-assets.d.ts +2 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +28 -3
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +1 -0
- package/dist/managed-files/publish-workflow.js +14 -11
- package/dist/nextest-code-bound.js +1 -0
- package/dist/nextest-timings.d.ts +35 -0
- package/dist/nextest-timings.d.ts.map +1 -0
- package/dist/nextest-timings.js +168 -0
- package/dist/owned-installation.d.ts +6 -5
- package/dist/owned-installation.d.ts.map +1 -1
- package/dist/owned-installation.js +150 -26
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +2 -3
- package/dist/process-children.d.ts +7 -0
- package/dist/process-children.d.ts.map +1 -0
- package/dist/process-children.darwin.d.ts +7 -0
- package/dist/process-children.darwin.d.ts.map +1 -0
- package/dist/process-children.darwin.js +13 -0
- package/dist/process-children.js +14 -0
- package/dist/process-children.linux.d.ts +8 -0
- package/dist/process-children.linux.d.ts.map +1 -0
- package/dist/process-children.linux.js +25 -0
- package/dist/process-group.d.ts +108 -0
- package/dist/process-group.d.ts.map +1 -0
- package/dist/process-group.js +171 -0
- package/dist/process-listing.d.ts +7 -0
- package/dist/process-listing.d.ts.map +1 -0
- package/dist/process-listing.js +51 -0
- package/dist/producer-receipts.d.ts +8 -2
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +514 -47
- package/dist/task-graph-policy.d.ts +21 -0
- package/dist/task-graph-policy.d.ts.map +1 -0
- package/dist/task-graph-policy.js +91 -0
- package/dist/test-timings.js +4 -4
- package/dist/test-walk-policy.d.ts +14 -5
- package/dist/test-walk-policy.d.ts.map +1 -1
- package/dist/test-walk-policy.js +8 -2
- package/dist/testing.d.ts +73 -28
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +217 -223
- package/dist/tool-bins.d.ts +33 -0
- package/dist/tool-bins.d.ts.map +1 -0
- package/dist/tool-bins.js +72 -0
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +3 -4
- package/dist/wait-why-policy.d.ts +28 -0
- package/dist/wait-why-policy.d.ts.map +1 -0
- package/dist/wait-why-policy.js +223 -0
- package/dist/workspace-config-policy.d.ts +14 -8
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +60 -16
- package/dist/workspace-manifest.d.ts +41 -6
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/dist/workspace-manifest.js +57 -0
- package/executors.json +16 -1
- package/loader.js +2 -0
- package/managed/raw/envrc +11 -0
- package/managed/raw/patches/nx@23.2.1.patch +2840 -199
- package/managed/raw/patches/ttsc@0.34.1.patch +119 -0
- package/managed/raw/tooling/direnv/cargo-fetch-bound.ts +245 -0
- package/managed/raw/tooling/direnv/cargo-fetch-run.ts +299 -0
- package/managed/raw/tooling/direnv/compiler-variables.sh +42 -0
- package/managed/raw/tooling/direnv/developer-links.ts +464 -25
- package/managed/raw/tooling/direnv/devenv.smoo.nix +78 -38
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -12
- package/managed/raw/tooling/direnv/installed-bun-links.ts +308 -0
- package/managed/raw/tooling/direnv/linked-snapshots.ts +62 -3
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +56 -17
- package/managed/raw/tooling/direnv/repo-path +68 -6
- package/managed/raw/tooling/direnv/secret-references.ts +13 -4
- package/managed/raw/tooling/direnv/setup-environment.ts +128 -537
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +4 -2
- package/managed/raw/tooling/direnv/ttsc-env.sh +9 -0
- package/managed/raw/tooling/direnv/uv-relocation.ts +227 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-commit.sh +2 -1
- package/managed/raw/tooling/git-hooks/pre-push.sh +2 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +85 -7
- package/managed/templates/github/actions/save-nix-devenv/action.yml +12 -2
- package/managed/templates/github/actions/setup-devenv/action.yml +2 -0
- package/package.json +95 -14
- package/src/bin/smoo-nx-cargo-toolchain.ts +11 -0
- package/src/bin/smoo-nx-forbidden-spellings.ts +33 -0
- package/src/bin/smoo-nx-nextest-timings.ts +31 -0
- package/src/bounded-test-policy.ts +12 -14
- package/src/build-state-output-policy.ts +458 -34
- package/src/bun-lock-scope.ts +108 -0
- package/src/cargo-build-script-env.ts +265 -0
- package/src/cargo-closure-input.ts +74 -7
- package/src/cargo-retention-hook.ts +94 -0
- package/src/cargo-source-hash.ts +138 -41
- package/src/cargo-toolchain-paths.ts +95 -0
- package/src/cargo-toolchain-policy.ts +49 -5
- package/src/cargo-workspace.ts +72 -123
- package/src/cross-check-policy.ts +12 -10
- package/src/disk-command-policy.ts +1 -0
- package/src/ensure-built-receipt.ts +173 -39
- package/src/ensure-built-witness.ts +62 -10
- package/src/ensure-built.ts +11 -1
- package/src/eslint-config-closure.ts +357 -0
- package/src/executors/bounded-exec/bounds.ts +76 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +43 -0
- package/src/executors/bounded-exec/cpu-pool.ts +55 -120
- package/src/executors/bounded-exec/executor.ts +442 -260
- package/src/executors/bounded-exec/gateway-lease.ts +94 -35
- package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
- package/src/executors/bounded-exec/lease-wait.ts +116 -0
- package/src/executors/bounded-exec/lock-wait.ts +141 -0
- package/src/executors/bounded-exec/mbx-pool.ts +48 -0
- package/src/executors/bounded-exec/owned-subtree.ts +235 -0
- package/src/executors/bounded-exec/progress.ts +9 -3
- package/src/executors/bounded-exec/ram-attach.ts +238 -0
- package/src/executors/bounded-exec/ram-detach.ts +226 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +358 -0
- package/src/executors/bounded-exec/ram-temp-registry.txt +440 -0
- package/src/executors/bounded-exec/ram-temp.ts +1497 -460
- package/src/executors/bounded-exec/run-cpu-pool.ts +129 -35
- package/src/executors/bounded-exec/runner-hook.ts +14 -6
- package/src/executors/bounded-exec/runner-lifecycle.ts +31 -8
- package/src/executors/bounded-exec/{cpu-tokens.ts → runner-sizing.ts} +13 -59
- package/src/executors/bounded-exec/runtime-pin.ts +232 -0
- package/src/executors/bounded-exec/schema.json +11 -2
- package/src/executors/bounded-exec/schema.ts +19 -1
- package/src/executors/bounded-exec/verdict.ts +145 -35
- package/src/executors/cargo-zigbuild/executor.ts +82 -8
- package/src/executors/clean-outputs/executor.ts +1 -0
- package/src/executors/scriptc-native/executor.ts +394 -0
- package/src/executors/scriptc-native/ffi-paths.ts +29 -0
- package/src/executors/scriptc-native/schema.json +60 -0
- package/src/executors/scriptc-native/schema.ts +34 -0
- package/src/executors/typescript-emit/emit-overrides.ts +24 -0
- package/src/executors/typescript-emit/executor.ts +186 -38
- package/src/forbidden-spelling-policy.ts +226 -0
- package/src/generators/create-package/generator.ts +7 -7
- package/src/graph-input-contract.ts +61 -2
- package/src/index.ts +788 -224
- package/src/managed-assets.ts +3 -0
- package/src/managed-files/files.ts +28 -3
- package/src/managed-files/managed-format.ts +1 -0
- package/src/managed-files/publish-workflow.ts +20 -15
- package/src/nextest-code-bound.ts +1 -0
- package/src/nextest-timings.ts +106 -0
- package/src/owned-installation.ts +150 -23
- package/src/package-target-policy.ts +2 -3
- package/src/process-children.darwin.ts +14 -0
- package/src/process-children.linux.ts +33 -0
- package/src/process-children.ts +22 -0
- package/src/process-group.ts +209 -0
- package/src/process-listing.ts +54 -0
- package/src/producer-receipts.ts +92 -41
- package/src/task-graph-policy.ts +98 -0
- package/src/test-walk-policy.ts +23 -8
- package/src/testing.ts +240 -232
- package/src/tool-bins.ts +108 -0
- package/src/typecheck-test-policy.ts +2 -3
- package/src/wait-why-policy.ts +226 -0
- package/src/workspace-config-policy.ts +63 -15
- package/src/workspace-manifest.ts +89 -6
- package/test-timings.json +124 -99
- package/dist/bin/smoo-nx-failures.d.ts +0 -3
- package/dist/bin/smoo-nx-failures.d.ts.map +0 -1
- package/dist/bin/smoo-nx-failures.js +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts +0 -3
- package/dist/bin/smoo-nx-nextest-extract.d.ts.map +0 -1
- package/dist/bin/smoo-nx-nextest-extract.js +0 -42
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +0 -1
- package/dist/failure-summary.d.ts +0 -5
- package/dist/failure-summary.d.ts.map +0 -1
- package/dist/failure-summary.js +0 -118
- package/dist/nextest-extraction.d.ts +0 -117
- package/dist/nextest-extraction.d.ts.map +0 -1
- package/dist/nextest-extraction.js +0 -303
- package/managed/raw/patches/ttsc@0.30.4.patch +0 -2255
- package/src/__tests__/cargo-closure-filesets.ts +0 -94
- package/src/__tests__/cargo-closure-fixture.ts +0 -113
- package/src/__tests__/counted-cargo-process.ts +0 -286
- package/src/__tests__/counted-cargo.ts +0 -713
- package/src/__tests__/directory-change.ts +0 -27
- package/src/__tests__/fixture-cargo-home.ts +0 -36
- package/src/__tests__/fixture-nx-env.ts +0 -193
- package/src/__tests__/owned-installation.ts +0 -13
- package/src/__tests__/past-tick.ts +0 -12
- package/src/__tests__/progress-clock.ts +0 -43
- package/src/__tests__/runtime-input.ts +0 -23
- package/src/bin/smoo-nx-bound-failures.test.ts +0 -127
- package/src/bin/smoo-nx-failures.ts +0 -4
- package/src/bin/smoo-nx-nextest-extract.ts +0 -44
- package/src/bounded-test-policy.test.ts +0 -1029
- package/src/build-state-output-policy.test.ts +0 -115
- package/src/bun-bootstrap.test.ts +0 -102
- package/src/bun-file-packages.test.ts +0 -47
- package/src/cargo-closure-filesets.test.ts +0 -63
- package/src/cargo-closure-input.property.test.ts +0 -50
- package/src/cargo-closure-input.test.ts +0 -506
- package/src/cargo-closure-key.test.ts +0 -240
- package/src/cargo-resolve-cache.test.ts +0 -1181
- package/src/cargo-source-hash.test.ts +0 -707
- package/src/cargo-workspace.test.ts +0 -615
- package/src/cross-check-policy.test.ts +0 -316
- package/src/disk-command-policy.test.ts +0 -61
- package/src/ensure-built-receipt.test.ts +0 -279
- package/src/ensure-built-witness.test.ts +0 -688
- package/src/ensure-built.test.ts +0 -1462
- package/src/executors/all-verdicts/executor.test.ts +0 -135
- package/src/executors/bounded-exec/cargo-progress-host.test.ts +0 -332
- package/src/executors/bounded-exec/cpu-pool.test.ts +0 -684
- package/src/executors/bounded-exec/cpu-tokens.test.ts +0 -519
- package/src/executors/bounded-exec/disk-lease.test.ts +0 -219
- package/src/executors/bounded-exec/executor-host.test.ts +0 -800
- package/src/executors/bounded-exec/executor.test.ts +0 -1819
- package/src/executors/bounded-exec/go-progress-host.test.ts +0 -171
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +0 -291
- package/src/executors/bounded-exec/progress.test.ts +0 -139
- package/src/executors/bounded-exec/ram-temp-held.test.ts +0 -264
- package/src/executors/bounded-exec/ram-temp-host.test.ts +0 -635
- package/src/executors/bounded-exec/ram-temp.test.ts +0 -750
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +0 -79
- package/src/executors/bounded-exec/runner-hook.test.ts +0 -193
- package/src/executors/bounded-exec/runner-lifecycle.test.ts +0 -82
- package/src/executors/bounded-exec/verdict.test.ts +0 -545
- package/src/executors/cargo-zigbuild/executor.test.ts +0 -129
- package/src/executors/clean-outputs/executor.test.ts +0 -20
- package/src/executors/typescript-emit/executor.test.ts +0 -83
- package/src/failure-summary.ts +0 -119
- package/src/generators/bounded-test-targets/generator.test.ts +0 -138
- package/src/generators/bun-test-tracing/generator.test.ts +0 -250
- package/src/generators/create-package/generator.test.ts +0 -190
- package/src/generators/make-public/generator.test.ts +0 -137
- package/src/graph-input-contract.test.ts +0 -379
- package/src/host-controller-wiring.test.ts +0 -31
- package/src/index.test.ts +0 -3321
- package/src/linked-snapshots.nx.test.ts +0 -254
- package/src/managed-files/forgejo-artifact.test.ts +0 -395
- package/src/managed-files/generator.test.ts +0 -243
- package/src/managed-files/github-host-cache-isolation.test.ts +0 -86
- package/src/managed-files/json-edit.test.ts +0 -216
- package/src/managed-files/managed-content.test.ts +0 -166
- package/src/managed-files/managed-format-json.test.ts +0 -308
- package/src/managed-files/repo-path.test.ts +0 -172
- package/src/managed-files/setup-devenv-free-disk.test.ts +0 -95
- package/src/managed-files/trace-db-artifact.test.ts +0 -7
- package/src/managed-files/tree-permissions.test.ts +0 -109
- package/src/managed-files/tree.test.ts +0 -123
- package/src/manifest-hash.test.ts +0 -219
- package/src/nextest-code-bound.test.ts +0 -161
- package/src/nextest-extraction.test.ts +0 -216
- package/src/nextest-extraction.ts +0 -371
- package/src/nextest-partitions.test.ts +0 -501
- package/src/nx-cache-bound.test.ts +0 -109
- package/src/nx-cache-restore-mtime.test.ts +0 -170
- package/src/nx-daemon-claim.test.ts +0 -279
- package/src/nx-daemon-idle-cpu.test.ts +0 -80
- package/src/nx-daemon-idle-policy.test.ts +0 -111
- package/src/nx-daemon-ignore-files.test.ts +0 -210
- package/src/nx-daemon-root-normalization.test.ts +0 -105
- package/src/nx-daemon-start-never.test.ts +0 -292
- package/src/nx-daemon-validity.test.ts +0 -1055
- package/src/nx-dot-input-policy.test.ts +0 -353
- package/src/nx-failure-life-cycles.test.ts +0 -207
- package/src/nx-files-archive-racy.test.ts +0 -97
- package/src/nx-foreign-workspace-env.test.ts +0 -329
- package/src/nx-incomplete-run-summary.test.ts +0 -70
- package/src/nx-plugin-load-errors.test.ts +0 -120
- package/src/nx-project-graph-errors.test.ts +0 -70
- package/src/nx-project-resolution-cache.test.ts +0 -176
- package/src/nx-raw-inputs.test.ts +0 -166
- package/src/nx-resident-graph-workers.test.ts +0 -112
- package/src/nx-run-information.test.ts +0 -118
- package/src/nx-skipped-task-exit.test.ts +0 -180
- package/src/nx-state-location.test.ts +0 -63
- package/src/nx-store-resolution.test.ts +0 -81
- package/src/nx-task-graph-cycles.test.ts +0 -148
- package/src/nx-task-output-lease.test.ts +0 -550
- package/src/nx-use-local.test.ts +0 -105
- package/src/owned-installation.test.ts +0 -105
- package/src/package-target-policy.test.ts +0 -1014
- package/src/producer-receipts.test.ts +0 -285
- package/src/release-config-policy.test.ts +0 -311
- package/src/runtime-input.test.ts +0 -393
- package/src/serial-group-wiring.test.ts +0 -326
- package/src/task-history-namespace.test.ts +0 -181
- package/src/task-results.test.ts +0 -228
- package/src/test-clock-policy.test.ts +0 -338
- package/src/test-program.test.ts +0 -303
- package/src/test-timings.test.ts +0 -240
- package/src/test-walk-policy.test.ts +0 -620
- package/src/testing.test.ts +0 -509
- package/src/typecheck-test-policy.test.ts +0 -1468
- package/src/typescript-resolution.test.ts +0 -76
- package/src/version-actions.test.ts +0 -80
- package/src/workspace-config-policy.test.ts +0 -737
package/src/index.ts
CHANGED
|
@@ -3,39 +3,48 @@ import { readdir, readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
6
|
import {
|
|
7
|
+
EXTRACTED_BINARIES_METADATA,
|
|
8
|
+
EXTRACTED_CARGO_METADATA,
|
|
9
|
+
EXTRACTED_TARGET_DIR,
|
|
10
|
+
NEXTEST_ARCHIVE_KEY_SUFFIX,
|
|
11
|
+
} from '@smoothbricks/nextest-extract';
|
|
12
|
+
import {
|
|
13
|
+
type CreateDependencies,
|
|
14
|
+
type CreateMetadata,
|
|
8
15
|
type CreateNodesContextV2,
|
|
9
16
|
type CreateNodesResultV2,
|
|
10
17
|
type CreateNodesV2,
|
|
11
18
|
type PostTasksExecution,
|
|
12
19
|
type PreTasksExecution,
|
|
20
|
+
type ProjectGraphExternalNode,
|
|
13
21
|
readJsonFile,
|
|
14
22
|
type TargetConfiguration,
|
|
15
23
|
} from 'nx/src/devkit-exports.js';
|
|
16
24
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
17
25
|
import { parse as parseToml } from 'smol-toml';
|
|
18
26
|
import { type ParsedCommandLine, parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
19
|
-
|
|
20
27
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
28
|
+
import { refuseOverlappingOutputs } from './build-state-output-policy.js';
|
|
29
|
+
import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
|
|
21
30
|
import {
|
|
22
31
|
CARGO_CLOSURE_INPUT,
|
|
32
|
+
CARGO_LOCK_NODE_PREFIX,
|
|
23
33
|
type CargoClosureSource,
|
|
24
34
|
cargoClosureInputs,
|
|
35
|
+
cargoLockNode,
|
|
36
|
+
cargoLockNodeName,
|
|
25
37
|
indexedCargoManifests,
|
|
38
|
+
isCargoLockInput,
|
|
26
39
|
resolveCargoClosureSource,
|
|
27
40
|
} from './cargo-closure-input.js';
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
31
|
-
cargoRuntimeInput,
|
|
32
|
-
} from './cargo-toolchain-policy.js';
|
|
41
|
+
import { CARGO_PRODUCER_METADATA, postTasksExecution as postCargoRetention } from './cargo-retention-hook.js';
|
|
42
|
+
import { CARGO_TOOLCHAIN_NAMED_INPUT, cargoRuntimeInput, cargoToolchainInputs } from './cargo-toolchain-policy.js';
|
|
33
43
|
import {
|
|
34
44
|
type AttributedCargoWorkspacePackage,
|
|
35
45
|
attributeCargoWorkspacePackages,
|
|
36
46
|
CARGO_TEST_ARCHIVE_FILE,
|
|
37
47
|
CARGO_TEST_ARCHIVE_TARGET,
|
|
38
|
-
CARGO_TEST_COMPILE_TARGET,
|
|
39
48
|
CARGO_TEST_EXCEPTIONS_SUFFIX,
|
|
40
49
|
CARGO_TEST_TARGET,
|
|
41
50
|
type CargoCrossTestTarget,
|
|
@@ -44,12 +53,14 @@ import {
|
|
|
44
53
|
cargoTestGroupTargetName,
|
|
45
54
|
cargoTestPackageTargetName,
|
|
46
55
|
createCargoInputsCache,
|
|
56
|
+
EXTERNAL_RUST_CRATES_INPUT,
|
|
47
57
|
exceptionalTestFilter,
|
|
48
58
|
listCargoCrossTestTargets,
|
|
49
59
|
listCargoWorkspacePackages,
|
|
50
60
|
NEXTEST_REPO_CONFIG_PATH,
|
|
51
61
|
nextestToolConfigArg,
|
|
52
62
|
PLUGIN_NEXTEST_CONFIG_PATH,
|
|
63
|
+
requireExternalRustCratesInput,
|
|
53
64
|
type SerialTestGroup,
|
|
54
65
|
serialTestGroups,
|
|
55
66
|
} from './cargo-workspace.js';
|
|
@@ -65,16 +76,14 @@ import {
|
|
|
65
76
|
cargoFrozen,
|
|
66
77
|
runsFrozenCargo,
|
|
67
78
|
} from './cross-check-policy.js';
|
|
79
|
+
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
68
80
|
import type { EslintFileSet } from './eslint-file-set.js';
|
|
69
81
|
import { ALL_VERDICTS_EXECUTOR } from './executors/all-verdicts/schema.js';
|
|
70
82
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
83
|
+
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
84
|
+
import type { ScriptcNativeFfi } from './executors/scriptc-native/schema.js';
|
|
71
85
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
72
|
-
import {
|
|
73
|
-
EXTRACTED_BINARIES_METADATA,
|
|
74
|
-
EXTRACTED_CARGO_METADATA,
|
|
75
|
-
EXTRACTED_TARGET_DIR,
|
|
76
|
-
NEXTEST_EXTRACT_BIN,
|
|
77
|
-
} from './nextest-extraction.js';
|
|
86
|
+
import { NEXTEST_TIMINGS_PATH, namedTestsFilter, readNextestTimings, timedShardMembers } from './nextest-timings.js';
|
|
78
87
|
import {
|
|
79
88
|
type ProducerReceiptsOptions,
|
|
80
89
|
postTasksExecution as postProducerReceipts,
|
|
@@ -82,26 +91,27 @@ import {
|
|
|
82
91
|
} from './producer-receipts.js';
|
|
83
92
|
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
84
93
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
94
|
+
import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-policy.js';
|
|
85
95
|
import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
|
|
86
96
|
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
87
97
|
import { assertUpstreamBasePrecondition } from './test-walk-policy.js';
|
|
98
|
+
import { type NativeTools, nativeToolCommand, nativeToolDependsOn, resolveNativeTools } from './tool-bins.js';
|
|
88
99
|
import {
|
|
89
100
|
isBuildOutputTargetName,
|
|
101
|
+
isTestNamespaceTargetName,
|
|
90
102
|
isTestRunnerTargetName,
|
|
91
103
|
PLATFORM_TARGET_GLOBS,
|
|
92
104
|
RELEASE_CONFIGURATION,
|
|
93
105
|
} from './workspace-config-policy.js';
|
|
94
106
|
import { globIndexedFiles } from './workspace-index.js';
|
|
95
107
|
|
|
96
|
-
export { CARGO_TEST_COMPILE_TARGET };
|
|
97
|
-
|
|
98
108
|
/** Makes a version live and proves it answers; never cached. */
|
|
99
109
|
export const DEPLOY_TARGET = 'deploy';
|
|
100
110
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
101
111
|
export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
102
112
|
|
|
103
|
-
/** The workspace-wide
|
|
104
|
-
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json'
|
|
113
|
+
/** The workspace-wide manifest a release rewrites: the version of every member. */
|
|
114
|
+
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json'];
|
|
105
115
|
/** Installed patch bytes and pins affect the compiler; Markdown explains them but is not loaded. */
|
|
106
116
|
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*', '!{workspaceRoot}/patches/**/*.md'];
|
|
107
117
|
/**
|
|
@@ -130,16 +140,16 @@ function typecheckCommand(args: string): string {
|
|
|
130
140
|
}
|
|
131
141
|
|
|
132
142
|
/**
|
|
133
|
-
* The
|
|
134
|
-
* check that only reads
|
|
143
|
+
* The release-rewritten root manifest hashed by field instead of by byte, for
|
|
144
|
+
* a check that only reads it.
|
|
135
145
|
*
|
|
136
146
|
* A `json` input is hashed by Nx's own hasher, so this costs no process. The
|
|
137
|
-
* lockfile
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
147
|
+
* lockfile is no file input at all: the packages it resolves reach a task as
|
|
148
|
+
* Nx's own lockfile nodes, the root manifest's through the bun root lock-scope
|
|
149
|
+
* node and the project's through its `^` input, so a release's rewrite of the
|
|
150
|
+
* lockfile's `workspaces` mirror re-keys nothing.
|
|
141
151
|
*
|
|
142
|
-
* The root manifest
|
|
152
|
+
* The root manifest drops `scripts`, `smoo` and `nx`. No lint or
|
|
143
153
|
* typecheck reads them: `scripts` are commands a developer runs, `smoo` holds
|
|
144
154
|
* the developer links whose linked bytes reach the hash only through their own
|
|
145
155
|
* inputs, and the root project's `nx` configuration is hashed as that
|
|
@@ -150,7 +160,6 @@ function typecheckCommand(args: string): string {
|
|
|
150
160
|
*/
|
|
151
161
|
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
152
162
|
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
153
|
-
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
154
163
|
];
|
|
155
164
|
|
|
156
165
|
/** A path segment Nx's workspace file map never carries, so a fileset naming it hashes nothing. */
|
|
@@ -273,8 +282,8 @@ function resolveTypescriptConfigExtends(specifier: string, fromConfigPath: strin
|
|
|
273
282
|
* Nx hashes workspace files that are not in node_modules, so two ancestor
|
|
274
283
|
* kinds cannot be named — and they are not the same thing:
|
|
275
284
|
*
|
|
276
|
-
* - a dependency's config:
|
|
277
|
-
* bytes are installed, and
|
|
285
|
+
* - a dependency's config: the lockfile entry of the package that holds it
|
|
286
|
+
* decides which bytes are installed, and the task is keyed on it. Where they sit is the
|
|
278
287
|
* installer's business — bun keeps them in a global store outside the
|
|
279
288
|
* workspace entirely — so this is settled by HOW the specifier resolved,
|
|
280
289
|
* not by where it landed. A workspace member reached through its package
|
|
@@ -318,6 +327,14 @@ const VERSIONLESS_PACKAGE_INPUTS = [
|
|
|
318
327
|
{ json: '{projectRoot}/package.json', excludeFields: ['version'] },
|
|
319
328
|
];
|
|
320
329
|
|
|
330
|
+
/**
|
|
331
|
+
* The root project owns the lockfiles, so its `default` fileset holds each
|
|
332
|
+
* whole, and a check keyed on it re-ran on every dependency change anywhere in
|
|
333
|
+
* the workspace. Its checks name what the lockfiles decide for it instead: the
|
|
334
|
+
* root manifest's bun lock-scope node and, for a root Cargo workspace, the
|
|
335
|
+
* Cargo nodes of its targets. No other project's fileset ever held them.
|
|
336
|
+
*/
|
|
337
|
+
const ROOT_LOCKFILE_EXCLUSIONS = ['!{projectRoot}/bun.lock', '!{projectRoot}/bun.lockb', '!{projectRoot}/Cargo.lock'];
|
|
321
338
|
/**
|
|
322
339
|
* Crate manifests, for the projects that have any.
|
|
323
340
|
*
|
|
@@ -357,9 +374,17 @@ const ESLINT_CONFIG_FILES = [
|
|
|
357
374
|
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
358
375
|
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
359
376
|
|
|
377
|
+
/** What ESLint lints in this workspace and what its configuration loads. */
|
|
378
|
+
interface EslintWorkspace {
|
|
379
|
+
/** The JavaScript and TypeScript files of Nx's workspace file index. */
|
|
380
|
+
readonly sources: ReadonlySet<string>;
|
|
381
|
+
/** The workspace modules the root configs load, transitively, workspace-relative and sorted; the configs excluded. */
|
|
382
|
+
readonly configImports: readonly string[];
|
|
383
|
+
}
|
|
384
|
+
|
|
360
385
|
/**
|
|
361
|
-
* The
|
|
362
|
-
* per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
386
|
+
* The ESLint sources and config closure of Nx's workspace file index, listed
|
|
387
|
+
* once per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
363
388
|
*
|
|
364
389
|
* The ESLint file list is part of the lint target's command, metadata and
|
|
365
390
|
* inputs, and Nx hashes the whole target configuration into every task that
|
|
@@ -369,10 +394,20 @@ const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
|
369
394
|
* and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
|
|
370
395
|
* Drawing the list from the index makes the plugin and the hasher agree on one
|
|
371
396
|
* file set.
|
|
397
|
+
*
|
|
398
|
+
* The configs key every lint target with exactly the workspace files they
|
|
399
|
+
* load (eslint-config-closure.ts): a glob over the directory holding a
|
|
400
|
+
* config's rule modules keyed every file beside them, and one test fixture
|
|
401
|
+
* there re-keyed 44 lint targets in one land.
|
|
372
402
|
*/
|
|
373
|
-
async function
|
|
374
|
-
|
|
375
|
-
|
|
403
|
+
async function eslintWorkspace(workspaceRoot: string): Promise<EslintWorkspace | null> {
|
|
404
|
+
const configs = ESLINT_CONFIG_FILES.filter((name) => existsSync(join(workspaceRoot, name)));
|
|
405
|
+
if (configs.length === 0) return null;
|
|
406
|
+
const indexed = new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB, '**/*.json']));
|
|
407
|
+
return {
|
|
408
|
+
sources: new Set([...indexed].filter((path) => !path.endsWith('.json'))),
|
|
409
|
+
configImports: eslintConfigClosure(workspaceRoot, configs, indexed),
|
|
410
|
+
};
|
|
376
411
|
}
|
|
377
412
|
|
|
378
413
|
/**
|
|
@@ -390,7 +425,7 @@ function readTestTsConfig(testConfig: string): ParsedCommandLine {
|
|
|
390
425
|
function projectLintCommands(
|
|
391
426
|
projectRoot: string,
|
|
392
427
|
workspaceRoot: string,
|
|
393
|
-
|
|
428
|
+
eslint: EslintWorkspace | null,
|
|
394
429
|
): { commands: string[]; inputs: string[]; eslintFileSet: EslintFileSet | null } {
|
|
395
430
|
const commands: string[] = [];
|
|
396
431
|
const inputs: string[] = [];
|
|
@@ -400,10 +435,10 @@ function projectLintCommands(
|
|
|
400
435
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
401
436
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
402
437
|
}
|
|
403
|
-
if (
|
|
438
|
+
if (eslint !== null) {
|
|
404
439
|
const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
|
|
405
440
|
const sourceFiles = new Set<string>();
|
|
406
|
-
for (const path of
|
|
441
|
+
for (const path of eslint.sources) {
|
|
407
442
|
if (
|
|
408
443
|
path.startsWith(sourcePrefix) &&
|
|
409
444
|
!path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)
|
|
@@ -431,7 +466,7 @@ function projectLintCommands(
|
|
|
431
466
|
}
|
|
432
467
|
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
433
468
|
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
434
|
-
if (!
|
|
469
|
+
if (!eslint.sources.has(path) || path.split('/').some(isNonSourceDirectory)) continue;
|
|
435
470
|
sourceFiles.add(path);
|
|
436
471
|
inputs.push(`{workspaceRoot}/${path}`);
|
|
437
472
|
}
|
|
@@ -448,6 +483,12 @@ function projectLintCommands(
|
|
|
448
483
|
type NapiArchitecture = 'arm64' | 'x64';
|
|
449
484
|
type NapiTargetFamily = 'linux' | 'macos';
|
|
450
485
|
|
|
486
|
+
/** A host's directory under a package's `dist/bin`, as `@smoothbricks/cowshed`'s launcher names it. */
|
|
487
|
+
const EXECUTABLE_PLATFORM_DIRECTORY: Readonly<Record<NapiTargetFamily, Readonly<Record<NapiArchitecture, string>>>> = {
|
|
488
|
+
linux: { arm64: 'linux-arm64', x64: 'linux-x64' },
|
|
489
|
+
macos: { arm64: 'darwin-arm64', x64: 'darwin-x64' },
|
|
490
|
+
};
|
|
491
|
+
|
|
451
492
|
interface NapiPlatform {
|
|
452
493
|
architecture: NapiArchitecture;
|
|
453
494
|
targetFamily: NapiTargetFamily;
|
|
@@ -501,7 +542,6 @@ const CARGO_WORKSPACE_PATTERN = /^\s*\[workspace\]/m;
|
|
|
501
542
|
const CARGO_INPUTS = [
|
|
502
543
|
'{projectRoot}/**/*.rs',
|
|
503
544
|
'{projectRoot}/**/Cargo.toml',
|
|
504
|
-
'{projectRoot}/**/Cargo.lock',
|
|
505
545
|
'{projectRoot}/**/.cargo/config.toml',
|
|
506
546
|
// Shell scripts a `.cargo/config.toml` points at — linker, runner, and rustc wrappers — decide
|
|
507
547
|
// what the compiler produces as surely as the config naming them does. Tracking the config
|
|
@@ -516,14 +556,27 @@ const CARGO_INPUTS = [
|
|
|
516
556
|
// step runs before the build), so every publish recompiled every native
|
|
517
557
|
// binary on every platform for a change to a version string. What the N-API
|
|
518
558
|
// build really reads is the package's `napi` block (binary name, targets) and
|
|
519
|
-
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
|
|
559
|
+
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs(). The
|
|
560
|
+
// locked crates are each cached cargo target's lock-scope node (below).
|
|
520
561
|
const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
|
|
562
|
+
/** The lockfiles of crates no resolved Cargo workspace claims, which have no lock-scope node. */
|
|
563
|
+
const UNRESOLVED_CARGO_LOCK_INPUT = '{projectRoot}/**/Cargo.lock';
|
|
564
|
+
/**
|
|
565
|
+
* What the uncached `cargo-fetch` reads: the manifests and the lock that name the crates, and the Cargo configuration
|
|
566
|
+
* that says where they come from. They key nothing; they are what a producer receipt binds the fetch to. Unnamed, Nx
|
|
567
|
+
* plans every file of the project, which for a repository-root project includes its symlinked managed files, and a
|
|
568
|
+
* receipt binds no symlink. That workspace's members belong to other projects, so its globs start at the repository root.
|
|
569
|
+
*/
|
|
570
|
+
function cargoFetchInputs(projectRoot: string): string[] {
|
|
571
|
+
const base = projectRoot === '.' ? '{workspaceRoot}' : '{projectRoot}';
|
|
572
|
+
return [`${base}/**/Cargo.toml`, `${base}/**/Cargo.lock`, `${base}/**/.cargo/config.toml`, `!${base}/**/target/**`];
|
|
573
|
+
}
|
|
521
574
|
/** A full cargo-mutants sweep's wall-clock backstop: a sweep takes hours, and a hung one must still end. */
|
|
522
575
|
const MUTATION_TIMEOUT_MS = 6 * 60 * 60 * 1000;
|
|
523
576
|
// The toolchain half of a cargo task's identity lives in its own module
|
|
524
|
-
// because `smoo monorepo validate` reads the same
|
|
525
|
-
// declaration that drops
|
|
526
|
-
// declared pin and not the ambient environment.
|
|
577
|
+
// because `smoo monorepo validate` reads the same entries to refuse a
|
|
578
|
+
// declaration that drops any of them. See cargo-toolchain-policy.ts for why it
|
|
579
|
+
// is the declared pin and the shell's declared programs, not the ambient environment.
|
|
527
580
|
|
|
528
581
|
/** A runtime input that changes when the file's bytes do: the runtime hashes the file itself. */
|
|
529
582
|
function fileHashInput(path: string): { runtime: string } {
|
|
@@ -560,14 +613,14 @@ function targetCommandText(target: TargetConfiguration): string {
|
|
|
560
613
|
].join('\n');
|
|
561
614
|
}
|
|
562
615
|
/**
|
|
563
|
-
* The N-API build's inputs beyond the Cargo sources: the toolchain
|
|
564
|
-
* package's `napi` block, which names the binary and the targets, and the
|
|
616
|
+
* The N-API build's inputs beyond the Cargo sources: the toolchain identity,
|
|
617
|
+
* the package's `napi` block, which names the binary and the targets, and the
|
|
565
618
|
* resolved version of the npm package that drives the build (the napi CLI on
|
|
566
619
|
* macOS; none on Linux, where devenv's zig and cargo-zigbuild are covered by
|
|
567
|
-
* the
|
|
620
|
+
* the identity). Neither the package version nor any other lockfile entry is part
|
|
568
621
|
* of the artifact.
|
|
569
622
|
*
|
|
570
|
-
* The
|
|
623
|
+
* The identity is stated here rather than inherited: neither `napi build` nor the
|
|
571
624
|
* `cargo-zigbuild` executor spells `cargo --frozen`, which is how every other
|
|
572
625
|
* cached cargo target acquires its toolchain identity. Without it a `.node`
|
|
573
626
|
* linked against one toolchain hashed equal to the same sources linked against
|
|
@@ -585,7 +638,7 @@ function napiInputs(
|
|
|
585
638
|
CARGO_CLOSURE_INPUT,
|
|
586
639
|
'{projectRoot}/scripts/*.sh',
|
|
587
640
|
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
588
|
-
...
|
|
641
|
+
...cargoToolchainInputs(),
|
|
589
642
|
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
590
643
|
{ externalDependencies: [...externalDependencies] },
|
|
591
644
|
];
|
|
@@ -638,6 +691,27 @@ const CARGO_PROFILE_FLAG: Readonly<Record<CargoProfile, string>> = { dev: '', re
|
|
|
638
691
|
/** The directory under `target/<triple>/` each profile writes. */
|
|
639
692
|
const CARGO_PROFILE_OUTPUT_DIR: Readonly<Record<CargoProfile, string>> = { dev: 'debug', release: 'release' };
|
|
640
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Where a build that ships writes, per profile. Two directories, never one: Nx restores a task's outputs as a tree, so
|
|
696
|
+
* a dev and a release build that share a path replace each other's restore and neither is a cache hit again. A release
|
|
697
|
+
* build writes where its package ships it (`dist/`, which publishes wholesale); a dev build writes under `.cache/`,
|
|
698
|
+
* which no package publishes and no loader mistakes for a release artifact.
|
|
699
|
+
*
|
|
700
|
+
* The target states each profile's directory once, as its `outputDir` option. Its declared output reads that as
|
|
701
|
+
* `{options.outputDir}` (Nx resolves it against the options of the run's configuration) and its command as
|
|
702
|
+
* `{args.outputDir}` (`nx:run-commands` fills it from the same option), so neither holds a copy that could drift.
|
|
703
|
+
*/
|
|
704
|
+
const OUTPUT_DIR_OPTION = '{options.outputDir}';
|
|
705
|
+
const OUTPUT_DIR_ARGUMENT = '{args.outputDir}';
|
|
706
|
+
/** Dev builds of N-API addons (one subdirectory per platform, beside `host`) and of wasm-bindgen's modules. */
|
|
707
|
+
const NATIVE_DEV_DIRECTORY = '.cache/native-dev';
|
|
708
|
+
const WASM_DEV_DIRECTORY = '.cache/wasm-dev';
|
|
709
|
+
|
|
710
|
+
/** An addon's directory per profile: `dist/native/<name>` ships, `.cache/native-dev/<name>` is for local builds. */
|
|
711
|
+
function nativeOutputPaths(name: string): Readonly<Record<CargoProfile, string>> {
|
|
712
|
+
return { dev: `${NATIVE_DEV_DIRECTORY}/${name}`, release: `dist/native/${name}` };
|
|
713
|
+
}
|
|
714
|
+
|
|
641
715
|
/**
|
|
642
716
|
* Cargo's default target directory for a crate, relative to the command's cwd:
|
|
643
717
|
* `target/` beside the workspace root that owns the crate, or beside the
|
|
@@ -667,7 +741,7 @@ function createCargoWasmTarget(
|
|
|
667
741
|
repoRooted: boolean,
|
|
668
742
|
cargoTargetDirectory: string,
|
|
669
743
|
): TargetConfiguration {
|
|
670
|
-
const outputDirectory = repoRooted ? posix.join(projectRoot,
|
|
744
|
+
const outputDirectory = repoRooted ? posix.join(projectRoot, OUTPUT_DIR_ARGUMENT) : OUTPUT_DIR_ARGUMENT;
|
|
671
745
|
const cargoSelection = repoRooted ? `-p ${config.cargoPackage}` : `--manifest-path ${config.manifestPath}`;
|
|
672
746
|
const buildCommand = (profile: CargoProfile): string =>
|
|
673
747
|
sequence([
|
|
@@ -680,56 +754,20 @@ function createCargoWasmTarget(
|
|
|
680
754
|
]);
|
|
681
755
|
return {
|
|
682
756
|
executor: 'nx:run-commands',
|
|
757
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
683
758
|
cache: true,
|
|
684
759
|
dependsOn: ['^build'],
|
|
685
760
|
inputs: repoRooted
|
|
686
761
|
? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
|
|
687
762
|
: CARGO_OUTPUT_INPUTS,
|
|
688
|
-
outputs: [`{projectRoot}/${
|
|
763
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
689
764
|
options: {
|
|
690
765
|
command: buildCommand('dev'),
|
|
691
766
|
cwd: repoRooted ? '.' : projectRoot,
|
|
767
|
+
outputDir: WASM_DEV_DIRECTORY,
|
|
692
768
|
},
|
|
693
|
-
configurations: {
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Compilation is excluded from the bounded test window: a cold Cargo
|
|
699
|
-
* workspace can take many minutes to compile while still making progress,
|
|
700
|
-
* which is not a property of the tests. `cargo test --no-run` pays that cost
|
|
701
|
-
* in its own unbounded target. Cargo reuses incremental compilation locally;
|
|
702
|
-
* Nx cannot cache this warming action without restoring shared mutable state.
|
|
703
|
-
*
|
|
704
|
-
* Cargo flocks one `target/` per invocation and owns that lock: a second cargo
|
|
705
|
-
* process on the same directory waits inside cargo ("Blocking waiting for file
|
|
706
|
-
* lock"). Inference adds no edge to keep writers apart — an edge says one
|
|
707
|
-
* target consumes another's output, and none of these do. These are unbounded
|
|
708
|
-
* `nx:run-commands` targets, so a wait is not charged against a test budget.
|
|
709
|
-
*
|
|
710
|
-
* Clippy runs ONCE over the whole workspace, in that same `target/`, rather
|
|
711
|
-
* than once per crate. Clippy of a crate is a check build of its whole
|
|
712
|
-
* closure, so 49 crates meant 49 closure rebuilds and 11 GiB of target
|
|
713
|
-
* directories on one repository, and no per-crate cache hit ever repaid that.
|
|
714
|
-
* Sharing the build's directory costs nothing: cargo's own lock serializes
|
|
715
|
-
* the invocations that use it, and the host units a dev build compiled are
|
|
716
|
-
* reused instead of compiled again.
|
|
717
|
-
*
|
|
718
|
-
* Tests compile the dev profile only, so no test target carries a
|
|
719
|
-
* RELEASE_CONFIGURATION: Nx forwards a run's configuration down every
|
|
720
|
-
* `dependsOn` edge to each target that has it, and a release `build` must
|
|
721
|
-
* warm the dev test binaries the test run will use, not release ones nobody
|
|
722
|
-
* runs.
|
|
723
|
-
*/
|
|
724
|
-
function createCargoTestCompileTarget(projectRoot: string): TargetConfiguration {
|
|
725
|
-
return {
|
|
726
|
-
executor: 'nx:run-commands',
|
|
727
|
-
cache: false,
|
|
728
|
-
inputs: CARGO_INPUTS,
|
|
729
|
-
outputs: [],
|
|
730
|
-
options: {
|
|
731
|
-
command: cargoFrozen('test --workspace --no-run'),
|
|
732
|
-
cwd: projectRoot,
|
|
769
|
+
configurations: {
|
|
770
|
+
[RELEASE_CONFIGURATION]: { command: buildCommand('release'), outputDir: config.outputDirectory },
|
|
733
771
|
},
|
|
734
772
|
};
|
|
735
773
|
}
|
|
@@ -746,25 +784,47 @@ function createCargoTestCompileTarget(projectRoot: string): TargetConfiguration
|
|
|
746
784
|
* entirely — the runners execute one extraction of it and never write cargo's
|
|
747
785
|
* `target/` build tree — which is what lets the runners fan out.
|
|
748
786
|
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
787
|
+
* It is also the step that keeps compilation out of the bounded test window: a
|
|
788
|
+
* cold workspace can take many minutes to compile while still making progress,
|
|
789
|
+
* which is not a property of the tests, and the runners start after it. It is
|
|
790
|
+
* test work, so no `build` depends on it (a build never consumes test binaries)
|
|
791
|
+
* and each target that executes them names the edge itself. There is no separate
|
|
792
|
+
* uncached `cargo test --no-run` warm-up: it compiled the same dev units a
|
|
793
|
+
* second time, queued on the same `target/` lock.
|
|
794
|
+
*
|
|
795
|
+
* Cached because it produces a VALUE: one file, not a mutable build tree Nx
|
|
796
|
+
* would have to restore. `--workspace` matches the clippy selection exactly, so
|
|
797
|
+
* both gates unify features the same way.
|
|
798
|
+
*
|
|
799
|
+
* Tests compile the dev profile only, so no test target carries a
|
|
800
|
+
* RELEASE_CONFIGURATION: Nx forwards a run's configuration down every
|
|
801
|
+
* `dependsOn` edge to each target that has it, and a release configuration
|
|
802
|
+
* must never turn the test binaries into release ones nobody runs.
|
|
752
803
|
*
|
|
753
804
|
* The directory and the archive are ONE command: nextest does not create the
|
|
754
805
|
* archive's parent, so the archive step consumes what the `mkdir` produced.
|
|
806
|
+
* The same command writes the task's hash beside the archive, the key every
|
|
807
|
+
* runner's extraction is looked up by (smoo-nx-nextest-extract), and declares it
|
|
808
|
+
* an output, so a cache hit restores the key with the archive it names.
|
|
755
809
|
*/
|
|
810
|
+
const CARGO_TEST_ARCHIVE_KEY_FILE = `${CARGO_TEST_ARCHIVE_FILE}${NEXTEST_ARCHIVE_KEY_SUFFIX}`;
|
|
811
|
+
|
|
756
812
|
function createCargoTestArchiveTarget(projectRoot: string, toolConfig: string): TargetConfiguration {
|
|
757
813
|
return {
|
|
758
814
|
executor: 'nx:run-commands',
|
|
815
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
759
816
|
cache: true,
|
|
760
817
|
inputs: CARGO_INPUTS,
|
|
761
|
-
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`],
|
|
818
|
+
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`, `{projectRoot}/${CARGO_TEST_ARCHIVE_KEY_FILE}`],
|
|
762
819
|
options: {
|
|
763
820
|
command: sequence([
|
|
764
821
|
`mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`,
|
|
765
822
|
cargoFrozen(
|
|
766
823
|
`nextest archive --workspace --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`,
|
|
767
824
|
),
|
|
825
|
+
// Outside Nx there is no task hash, and an archive no task names is refused here, not by every runner.
|
|
826
|
+
'test -n "$NX_TASK_HASH"',
|
|
827
|
+
`printf '%s\\n' "$NX_TASK_HASH" > ${CARGO_TEST_ARCHIVE_KEY_FILE}`,
|
|
768
828
|
]),
|
|
769
829
|
cwd: projectRoot,
|
|
770
830
|
},
|
|
@@ -806,6 +866,7 @@ function createCargoCrossTestTargets(
|
|
|
806
866
|
toolConfig: string,
|
|
807
867
|
crossTarget: CargoCrossTestTarget,
|
|
808
868
|
archiveInputs: NonNullable<TargetConfiguration['inputs']>,
|
|
869
|
+
pluginInstalled: boolean,
|
|
809
870
|
): Record<string, TargetConfiguration> {
|
|
810
871
|
const { target: triple, cargo } = crossTarget;
|
|
811
872
|
const archiveFile = cargoCrossTestArchiveFile(triple);
|
|
@@ -818,6 +879,7 @@ function createCargoCrossTestTargets(
|
|
|
818
879
|
return {
|
|
819
880
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
820
881
|
executor: archiveExecutor,
|
|
882
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
821
883
|
cache: true,
|
|
822
884
|
// The toolchain inputs every cached cargo target carries, plus the
|
|
823
885
|
// declared driver's own bytes. Those toolchain inputs are attached
|
|
@@ -832,10 +894,14 @@ function createCargoCrossTestTargets(
|
|
|
832
894
|
// the cross profile. For the same reason it names its npm packages here.
|
|
833
895
|
inputs: [
|
|
834
896
|
...archiveInputs,
|
|
835
|
-
...
|
|
897
|
+
...cargoToolchainInputs(),
|
|
836
898
|
...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
|
|
837
899
|
cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
|
|
838
|
-
{
|
|
900
|
+
{
|
|
901
|
+
externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand, pluginInstalled),
|
|
902
|
+
},
|
|
903
|
+
// The Cargo.lock entries the whole workspace reaches, for the same reason.
|
|
904
|
+
{ externalDependencies: [cargoLockNodeName(projectRoot)] },
|
|
839
905
|
],
|
|
840
906
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
841
907
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
@@ -872,9 +938,10 @@ function createCargoCrossTestTargets(
|
|
|
872
938
|
function createCargoTestTarget(projectRoot: string): TargetConfiguration {
|
|
873
939
|
return {
|
|
874
940
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
941
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
875
942
|
cache: true,
|
|
876
943
|
inputs: CARGO_INPUTS,
|
|
877
|
-
dependsOn: [
|
|
944
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
878
945
|
options: {
|
|
879
946
|
command: cargoFrozen('test --workspace'),
|
|
880
947
|
cwd: projectRoot,
|
|
@@ -893,14 +960,49 @@ const PLUGIN_NEXTEST_CODE_BOUND = fileURLToPath(new URL('../src/nextest-code-bou
|
|
|
893
960
|
|
|
894
961
|
const PLUGIN_PACKAGE = '@smoothbricks/nx-plugin';
|
|
895
962
|
/**
|
|
896
|
-
* Whether this plugin
|
|
897
|
-
*
|
|
898
|
-
*
|
|
963
|
+
* Whether this plugin's code was loaded from an installed npm package: a path
|
|
964
|
+
* through `node_modules`. Not enough alone to name it as an
|
|
965
|
+
* `externalDependencies` entry ({@link pluginInstalledIn}).
|
|
899
966
|
*/
|
|
900
|
-
const
|
|
967
|
+
const PLUGIN_LOADED_FROM_NODE_MODULES = fileURLToPath(new URL('..', import.meta.url))
|
|
901
968
|
.split(sep)
|
|
902
969
|
.includes('node_modules');
|
|
903
970
|
|
|
971
|
+
const workspaceProjectPlugins = new Map<string, boolean>();
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Whether the workspace at `workspaceRoot` runs this plugin as an installed npm package, whose lockfile node an
|
|
975
|
+
* `externalDependencies` entry can name. In the repository that develops it the plugin is a workspace project: the
|
|
976
|
+
* workspace's own `node_modules/@smoothbricks/nx-plugin` resolves to a directory of the workspace outside every
|
|
977
|
+
* `node_modules`, and Nx refuses a workspace project named as an `externalDependencies` entry ("could not be
|
|
978
|
+
* found"), whatever path this process loaded the plugin's code through. A daemon of that repository did load it
|
|
979
|
+
* through one with `node_modules` in it, and every cargo target it inferred afterwards named the plugin, so a gate
|
|
980
|
+
* refused the graph.
|
|
981
|
+
*/
|
|
982
|
+
export function pluginInstalledIn(
|
|
983
|
+
workspaceRoot: string,
|
|
984
|
+
loadedFromNodeModules = PLUGIN_LOADED_FROM_NODE_MODULES,
|
|
985
|
+
): boolean {
|
|
986
|
+
if (!loadedFromNodeModules) return false;
|
|
987
|
+
let workspaceProject = workspaceProjectPlugins.get(workspaceRoot);
|
|
988
|
+
if (workspaceProject === undefined) {
|
|
989
|
+
let linked: string | null = null;
|
|
990
|
+
try {
|
|
991
|
+
linked = relative(realpathSync(workspaceRoot), realpathSync(join(workspaceRoot, 'node_modules', PLUGIN_PACKAGE)));
|
|
992
|
+
} catch {
|
|
993
|
+
// No such package in the workspace: whatever runs the plugin, it is not a project of this workspace.
|
|
994
|
+
}
|
|
995
|
+
workspaceProject =
|
|
996
|
+
linked !== null &&
|
|
997
|
+
linked !== '' &&
|
|
998
|
+
!isAbsolute(linked) &&
|
|
999
|
+
linked !== '..' &&
|
|
1000
|
+
!linked.startsWith(`..${sep}`) &&
|
|
1001
|
+
!linked.split(sep).includes('node_modules');
|
|
1002
|
+
workspaceProjectPlugins.set(workspaceRoot, workspaceProject);
|
|
1003
|
+
}
|
|
1004
|
+
return !workspaceProject;
|
|
1005
|
+
}
|
|
904
1006
|
/**
|
|
905
1007
|
* The npm packages a cached cargo target runs, for its `externalDependencies`.
|
|
906
1008
|
* Cargo runs none. A target this plugin's executor runs, or whose command reads
|
|
@@ -912,7 +1014,7 @@ const PLUGIN_IS_INSTALLED = fileURLToPath(new URL('..', import.meta.url))
|
|
|
912
1014
|
export function cargoCommandNpmPackages(
|
|
913
1015
|
target: TargetConfiguration,
|
|
914
1016
|
commandText: string,
|
|
915
|
-
installed
|
|
1017
|
+
installed: boolean,
|
|
916
1018
|
): string[] {
|
|
917
1019
|
const runsPlugin =
|
|
918
1020
|
target.executor?.startsWith(`${PLUGIN_PACKAGE}:`) === true ||
|
|
@@ -1001,10 +1103,20 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
|
|
|
1001
1103
|
const results: CreateNodesResultV2 = [];
|
|
1002
1104
|
const errors: Array<[file: string | null, error: Error]> = [];
|
|
1003
1105
|
let cargoWorkspaces: CargoWorkspace[];
|
|
1004
|
-
let
|
|
1106
|
+
let eslint: EslintWorkspace | null;
|
|
1107
|
+
let nativeTools: NativeTools | null;
|
|
1005
1108
|
try {
|
|
1006
1109
|
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
|
|
1007
|
-
|
|
1110
|
+
eslint = await eslintWorkspace(context.workspaceRoot);
|
|
1111
|
+
nativeTools =
|
|
1112
|
+
hostPlatform === null
|
|
1113
|
+
? null
|
|
1114
|
+
: await resolveNativeTools(
|
|
1115
|
+
context.workspaceRoot,
|
|
1116
|
+
projectConfigurationFiles,
|
|
1117
|
+
EXECUTABLE_PLATFORM_DIRECTORY[hostPlatform.targetFamily][hostPlatform.architecture],
|
|
1118
|
+
scriptcTargetName(hostPlatform),
|
|
1119
|
+
);
|
|
1008
1120
|
} catch (error) {
|
|
1009
1121
|
throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
|
|
1010
1122
|
}
|
|
@@ -1029,8 +1141,9 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
|
|
|
1029
1141
|
packageJsonPath,
|
|
1030
1142
|
context.workspaceRoot,
|
|
1031
1143
|
hostPlatform,
|
|
1144
|
+
nativeTools,
|
|
1032
1145
|
cargoWorkspaces,
|
|
1033
|
-
|
|
1146
|
+
eslint,
|
|
1034
1147
|
versionless,
|
|
1035
1148
|
),
|
|
1036
1149
|
]);
|
|
@@ -1074,8 +1187,9 @@ function isBuildOutputPackageJson(packageJsonPath: string): boolean {
|
|
|
1074
1187
|
* Nx accepts one pre/post task-hook pair per plugin. Two independent observers share it: the controller's task-results
|
|
1075
1188
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
1076
1189
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
1077
|
-
* pair also serves a run
|
|
1078
|
-
*
|
|
1190
|
+
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
1191
|
+
* it when the run ends. Last, once every task has finished, the post hook reclaims the
|
|
1192
|
+
* superseded Cargo unit generations of each Cargo workspace the run built into (`@smoothbricks/cargo-retain`).
|
|
1079
1193
|
*/
|
|
1080
1194
|
export const preTasksExecution: PreTasksExecution<ProducerReceiptsOptions> = async (options, context) => {
|
|
1081
1195
|
// Before any task is hashed: a workspace that declares the test-walk check
|
|
@@ -1089,16 +1203,30 @@ export const postTasksExecution: PostTasksExecution<ProducerReceiptsOptions> = a
|
|
|
1089
1203
|
await postTaskResults(options, context);
|
|
1090
1204
|
await postProducerReceipts(options, context);
|
|
1091
1205
|
await closeRunCpuPool(context);
|
|
1206
|
+
await postCargoRetention(options, context);
|
|
1092
1207
|
};
|
|
1093
1208
|
|
|
1094
|
-
|
|
1209
|
+
/** The lock-scope nodes' edges: each bun node's to the packages and members its manifest resolves. */
|
|
1210
|
+
export const createDependencies: CreateDependencies = (_options, context) => bunLockDependencies(context);
|
|
1211
|
+
|
|
1212
|
+
/** Nx invokes this only after merging inferred/declarative targets and every plugin's project dependencies. */
|
|
1213
|
+
export const createMetadata: CreateMetadata = (graph, _options, context) => {
|
|
1214
|
+
refuseOverlappingOutputs(graph, context.workspaceRoot);
|
|
1215
|
+
refuseBuildTestDependencies(graph, context.workspaceRoot);
|
|
1216
|
+
return {};
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
export default { createNodesV2, createDependencies, createMetadata, postTasksExecution, preTasksExecution };
|
|
1095
1220
|
|
|
1096
1221
|
interface PackageJson {
|
|
1097
1222
|
bin?: unknown;
|
|
1223
|
+
devDependencies?: Record<string, unknown>;
|
|
1098
1224
|
name?: string;
|
|
1099
1225
|
napi?: Record<string, unknown>;
|
|
1100
1226
|
/** npm's own "never published" flag, which is what makes a package a deployable target rather than a library. */
|
|
1101
1227
|
private?: boolean;
|
|
1228
|
+
/** Native entry overrides (`entries`) and the C the executables call (`ffi`). */
|
|
1229
|
+
scriptc?: unknown;
|
|
1102
1230
|
scripts?: Record<string, unknown>;
|
|
1103
1231
|
nx?: {
|
|
1104
1232
|
name?: string;
|
|
@@ -1107,26 +1235,237 @@ interface PackageJson {
|
|
|
1107
1235
|
}
|
|
1108
1236
|
|
|
1109
1237
|
function packageBinOutputs(packageJson: PackageJson, packageJsonPath: string): string[] {
|
|
1238
|
+
return [...new Set(packageBinEntries(packageJson, packageJsonPath).values())];
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/** `package.json#bin` as npm links it: each command's name and executable path; a lone path is the unscoped package's. */
|
|
1242
|
+
function packageBinEntries(packageJson: PackageJson, packageJsonPath: string): Map<string, string> {
|
|
1110
1243
|
if (packageJson.bin === undefined) {
|
|
1111
|
-
return
|
|
1244
|
+
return new Map();
|
|
1112
1245
|
}
|
|
1113
1246
|
if (typeof packageJson.bin === 'string') {
|
|
1114
1247
|
if (packageJson.bin.length === 0) {
|
|
1115
1248
|
throw new Error(`${packageJsonPath}: bin must not be empty`);
|
|
1116
1249
|
}
|
|
1117
|
-
return [packageJson.bin];
|
|
1250
|
+
return new Map([[(packageJson.name ?? '').replace(/^@[^/]*\//, ''), packageJson.bin]]);
|
|
1118
1251
|
}
|
|
1119
1252
|
if (!isRecord(packageJson.bin)) {
|
|
1120
1253
|
throw new Error(`${packageJsonPath}: bin must be a string or an object of executable paths`);
|
|
1121
1254
|
}
|
|
1122
|
-
const
|
|
1255
|
+
const entries = new Map<string, string>();
|
|
1123
1256
|
for (const [name, output] of Object.entries(packageJson.bin)) {
|
|
1124
1257
|
if (typeof output !== 'string' || output.length === 0) {
|
|
1125
1258
|
throw new Error(`${packageJsonPath}: bin.${name} must be a non-empty executable path`);
|
|
1126
1259
|
}
|
|
1127
|
-
|
|
1260
|
+
entries.set(name, output);
|
|
1261
|
+
}
|
|
1262
|
+
return entries;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/** Resolve declared bins and optional package-root-relative native overrides to emit-root-relative modules. */
|
|
1266
|
+
export function scriptcBinModules(
|
|
1267
|
+
bins: ReadonlyMap<string, string>,
|
|
1268
|
+
scriptc: unknown,
|
|
1269
|
+
packageJsonPath: string,
|
|
1270
|
+
javascriptRoot: string,
|
|
1271
|
+
): Record<string, string> {
|
|
1272
|
+
const modulePath = (name: string, entry: string, field: string): string => {
|
|
1273
|
+
const emitted = posix.normalize(entry);
|
|
1274
|
+
if (!/^[\w.-]+$/.test(name) || !emitted.startsWith(`${javascriptRoot}/`) || !emitted.endsWith('.js')) {
|
|
1275
|
+
throw new Error(
|
|
1276
|
+
`${packageJsonPath}: ${field} must name JavaScript tsc-js emits under ${javascriptRoot}/ (it is ${entry})`,
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
return emitted.slice(javascriptRoot.length + 1);
|
|
1280
|
+
};
|
|
1281
|
+
const modules: Record<string, string> = Object.fromEntries(bins);
|
|
1282
|
+
for (const [name, entry] of bins) {
|
|
1283
|
+
modules[name] = modulePath(name, entry, `bin.${name}`);
|
|
1284
|
+
}
|
|
1285
|
+
if (scriptc === undefined) return modules;
|
|
1286
|
+
if (!isRecord(scriptc) || Array.isArray(scriptc)) {
|
|
1287
|
+
throw new Error(`${packageJsonPath}: scriptc must be an object`);
|
|
1288
|
+
}
|
|
1289
|
+
const overrides = scriptc.entries;
|
|
1290
|
+
if (overrides === undefined) return modules;
|
|
1291
|
+
if (!isRecord(overrides) || Array.isArray(overrides)) {
|
|
1292
|
+
throw new Error(`${packageJsonPath}: scriptc.entries must be an object mapping declared bin names to module paths`);
|
|
1293
|
+
}
|
|
1294
|
+
for (const [name, entry] of Object.entries(overrides)) {
|
|
1295
|
+
if (!bins.has(name)) {
|
|
1296
|
+
throw new Error(
|
|
1297
|
+
`${packageJsonPath}: scriptc.entries.${name} is not declared in bin; entries cannot add executables`,
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
if (typeof entry !== 'string' || entry.length === 0) {
|
|
1301
|
+
throw new Error(`${packageJsonPath}: scriptc.entries.${name} must be a non-empty module path`);
|
|
1302
|
+
}
|
|
1303
|
+
modules[name] = modulePath(name, entry, `scriptc.entries.${name}`);
|
|
1304
|
+
}
|
|
1305
|
+
return modules;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Every platform a scriptc package ships an executable for, with the triple `SCRIPTC_TARGET` names for it and the
|
|
1310
|
+
* runtime pack scriptc links that triple against. Linux executables are static musl, as cowshed's CLI is, so one file
|
|
1311
|
+
* runs on every distribution.
|
|
1312
|
+
*/
|
|
1313
|
+
const SCRIPTC_PLATFORMS: readonly (NapiPlatform & { readonly triple: string; readonly runtimePack: string })[] = [
|
|
1314
|
+
{
|
|
1315
|
+
architecture: 'arm64',
|
|
1316
|
+
targetFamily: 'macos',
|
|
1317
|
+
triple: 'aarch64-macos',
|
|
1318
|
+
runtimePack: '@scriptc/runtime-darwin-arm64',
|
|
1319
|
+
},
|
|
1320
|
+
{ architecture: 'x64', targetFamily: 'macos', triple: 'x86_64-macos', runtimePack: '@scriptc/runtime-darwin-x64' },
|
|
1321
|
+
{
|
|
1322
|
+
architecture: 'arm64',
|
|
1323
|
+
targetFamily: 'linux',
|
|
1324
|
+
triple: 'aarch64-linux-musl',
|
|
1325
|
+
runtimePack: '@scriptc/runtime-linux-arm64-musl',
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
architecture: 'x64',
|
|
1329
|
+
targetFamily: 'linux',
|
|
1330
|
+
triple: 'x86_64-linux-musl',
|
|
1331
|
+
runtimePack: '@scriptc/runtime-linux-x64-musl',
|
|
1332
|
+
},
|
|
1333
|
+
];
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* `package.json#scriptc.ffi`: the C a package's executables call through scriptc's FFI, which every platform run stages
|
|
1337
|
+
* beside the emitted JavaScript and builds for its triple. Absent for a package that calls no C.
|
|
1338
|
+
*/
|
|
1339
|
+
function scriptcFfi(packageJson: PackageJson, packageJsonPath: string): ScriptcNativeFfi | undefined {
|
|
1340
|
+
if (packageJson.scriptc === undefined || (isRecord(packageJson.scriptc) && packageJson.scriptc.ffi === undefined)) {
|
|
1341
|
+
return undefined;
|
|
1342
|
+
}
|
|
1343
|
+
const refusal = (what: string): Error =>
|
|
1344
|
+
new Error(
|
|
1345
|
+
`${packageJsonPath}: scriptc.ffi ${what}; it is { "manifest": "<ffi.json>", "declarations": ` +
|
|
1346
|
+
'{ "<source .d.ts>": "<path beside the emitted JavaScript>" }, "sources": ["<C file>"] }',
|
|
1347
|
+
);
|
|
1348
|
+
const ffi = isRecord(packageJson.scriptc) ? packageJson.scriptc.ffi : undefined;
|
|
1349
|
+
if (!isRecord(ffi)) {
|
|
1350
|
+
throw refusal('must be an object');
|
|
1351
|
+
}
|
|
1352
|
+
const { manifest, declarations, sources } = ffi;
|
|
1353
|
+
if (typeof manifest !== 'string' || manifest.length === 0) {
|
|
1354
|
+
throw refusal('needs a manifest path');
|
|
1355
|
+
}
|
|
1356
|
+
if (!isRecord(declarations)) {
|
|
1357
|
+
throw refusal('needs declarations mapping each source file to its staged path');
|
|
1358
|
+
}
|
|
1359
|
+
const staged: Record<string, string> = {};
|
|
1360
|
+
for (const [source, destination] of Object.entries(declarations)) {
|
|
1361
|
+
if (typeof destination !== 'string') {
|
|
1362
|
+
throw refusal(`needs declarations mapping each source file to its staged path (${source} is not)`);
|
|
1363
|
+
}
|
|
1364
|
+
staged[source] = destination;
|
|
1128
1365
|
}
|
|
1129
|
-
|
|
1366
|
+
if (!Array.isArray(sources)) {
|
|
1367
|
+
throw refusal('needs sources, a list of C files');
|
|
1368
|
+
}
|
|
1369
|
+
const files: string[] = [];
|
|
1370
|
+
for (const source of sources) {
|
|
1371
|
+
if (typeof source !== 'string') {
|
|
1372
|
+
throw refusal('needs sources, a list of C files');
|
|
1373
|
+
}
|
|
1374
|
+
files.push(source);
|
|
1375
|
+
}
|
|
1376
|
+
const declared = { manifest, declarations: staged, sources: files };
|
|
1377
|
+
const problem = ffiPathProblem(declared);
|
|
1378
|
+
if (problem !== undefined) {
|
|
1379
|
+
throw refusal(problem);
|
|
1380
|
+
}
|
|
1381
|
+
return declared;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/** The files a target's FFI is built from: change one and every platform's executable is stale. */
|
|
1385
|
+
function scriptcFfiInputs(ffi: ScriptcNativeFfi | undefined): string[] {
|
|
1386
|
+
return ffi === undefined
|
|
1387
|
+
? []
|
|
1388
|
+
: [ffi.manifest, ...Object.keys(ffi.declarations), ...ffi.sources].map((path) => `{projectRoot}/${path}`);
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/** The scriptc target writing `platform`'s executables; its suffix is the platform family the publish legs select. */
|
|
1392
|
+
function scriptcTargetName(platform: NapiPlatform): string {
|
|
1393
|
+
return `scriptc-${platform.architecture}-${platform.targetFamily}`;
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* `scriptc-<arch>-<family>`, one per platform in SCRIPTC_PLATFORMS: each `package.json#bin` entry compiled by scriptc
|
|
1398
|
+
* to the executable `dist/bin/<platform>/<name>`, from the transformed JavaScript the run itself emits from
|
|
1399
|
+
* `tsconfig.lib.json` into private staging, never from `tsc-js`'s output: a platform target's closure stays in its
|
|
1400
|
+
* family (package-target-policy.ts) and the four are collected on different hosts, so none depends on a sibling or
|
|
1401
|
+
* shares an output with another. A package opts in by depending on `scriptc`, which also pins the compiler the targets
|
|
1402
|
+
* run, and lists each platform's runtime pack at that same version. Every host builds every platform the same way,
|
|
1403
|
+
* `SCRIPTC_TARGET=<triple>` with zig as the C compiler, so a target's output does not depend on the host that built
|
|
1404
|
+
* it, and like every platform target the host's own joins `build` while the publish legs build the rest. The bins
|
|
1405
|
+
* name JavaScript below `dist/` beside `bin/` (`dist/ts`), so `tsc-js`'s output and the executables are disjoint.
|
|
1406
|
+
*/
|
|
1407
|
+
function scriptcPlatformTargets(
|
|
1408
|
+
packageJson: PackageJson,
|
|
1409
|
+
packageJsonPath: string,
|
|
1410
|
+
projectRoot: string,
|
|
1411
|
+
libTsconfigPath: string,
|
|
1412
|
+
toolchainInputs: NonNullable<TargetConfiguration['inputs']>,
|
|
1413
|
+
): Record<string, TargetConfiguration> {
|
|
1414
|
+
const compiler = packageJson.devDependencies?.scriptc;
|
|
1415
|
+
if (compiler === undefined) {
|
|
1416
|
+
return {};
|
|
1417
|
+
}
|
|
1418
|
+
const missingPacks = SCRIPTC_PLATFORMS.filter(
|
|
1419
|
+
(platform) => packageJson.devDependencies?.[platform.runtimePack] !== compiler,
|
|
1420
|
+
).map((platform) => `${platform.runtimePack}@${String(compiler)}`);
|
|
1421
|
+
if (missingPacks.length > 0) {
|
|
1422
|
+
throw new Error(
|
|
1423
|
+
`${packageJsonPath}: a scriptc package builds every platform's executable, each linked against its runtime pack at ` +
|
|
1424
|
+
`the compiler's version; list ${missingPacks.join(', ')} in devDependencies beside scriptc`,
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
const javascriptRoot = typescriptOutDir(libTsconfigPath, packageJsonPath);
|
|
1428
|
+
const [outputRoot, below] = javascriptRoot?.split('/') ?? [];
|
|
1429
|
+
if (javascriptRoot === null || outputRoot !== 'dist' || below === undefined || below === 'bin') {
|
|
1430
|
+
throw new Error(
|
|
1431
|
+
`${packageJsonPath}: a scriptc package emits its JavaScript below dist/ beside dist/bin; ` +
|
|
1432
|
+
`set tsconfig.lib.json compilerOptions.outDir to "dist/ts" (it is ${JSON.stringify(javascriptRoot)})`,
|
|
1433
|
+
);
|
|
1434
|
+
}
|
|
1435
|
+
const entries = packageBinEntries(packageJson, packageJsonPath);
|
|
1436
|
+
if (entries.size === 0) {
|
|
1437
|
+
throw new Error(`${packageJsonPath}: a scriptc package names the executables it compiles in bin`);
|
|
1438
|
+
}
|
|
1439
|
+
const modules = scriptcBinModules(entries, packageJson.scriptc, packageJsonPath, javascriptRoot);
|
|
1440
|
+
const ffi = scriptcFfi(packageJson, packageJsonPath);
|
|
1441
|
+
const targets: Record<string, TargetConfiguration> = {};
|
|
1442
|
+
for (const platform of SCRIPTC_PLATFORMS) {
|
|
1443
|
+
const outputDirectory = `dist/bin/${EXECUTABLE_PLATFORM_DIRECTORY[platform.targetFamily][platform.architecture]}`;
|
|
1444
|
+
targets[scriptcTargetName(platform)] = {
|
|
1445
|
+
executor: '@smoothbricks/nx-plugin:scriptc-native',
|
|
1446
|
+
cache: true,
|
|
1447
|
+
inputs: [
|
|
1448
|
+
'production',
|
|
1449
|
+
'^production',
|
|
1450
|
+
...toolchainInputs,
|
|
1451
|
+
'{projectRoot}/tsconfig.lib.json',
|
|
1452
|
+
{ externalDependencies: ['scriptc', platform.runtimePack] },
|
|
1453
|
+
...scriptcFfiInputs(ffi),
|
|
1454
|
+
],
|
|
1455
|
+
outputs: [...entries.keys()].map((name) => `{projectRoot}/${outputDirectory}/${name}`),
|
|
1456
|
+
// The emit type-checks against its dependencies' emitted JavaScript, as tsc-js does.
|
|
1457
|
+
dependsOn: ['^*-js'],
|
|
1458
|
+
options: {
|
|
1459
|
+
cwd: projectRoot,
|
|
1460
|
+
tsConfig: 'tsconfig.lib.json',
|
|
1461
|
+
triple: platform.triple,
|
|
1462
|
+
outputDirectory,
|
|
1463
|
+
entries: modules,
|
|
1464
|
+
...(ffi === undefined ? {} : { ffi }),
|
|
1465
|
+
},
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
return targets;
|
|
1130
1469
|
}
|
|
1131
1470
|
|
|
1132
1471
|
/**
|
|
@@ -1174,8 +1513,9 @@ async function createProjectTargets(
|
|
|
1174
1513
|
packageJsonPath: string,
|
|
1175
1514
|
workspaceRoot: string,
|
|
1176
1515
|
hostPlatform: NapiPlatform | null,
|
|
1516
|
+
nativeTools: NativeTools | null,
|
|
1177
1517
|
cargoWorkspaces: readonly CargoWorkspace[],
|
|
1178
|
-
|
|
1518
|
+
eslint: EslintWorkspace | null,
|
|
1179
1519
|
versionless: VersionlessManifestPolicy | null,
|
|
1180
1520
|
) {
|
|
1181
1521
|
const projectRoot = dirname(packageJsonPath);
|
|
@@ -1210,7 +1550,10 @@ async function createProjectTargets(
|
|
|
1210
1550
|
const hasCrateManifests = isCargoProject || existsSync(cargoTomlPath);
|
|
1211
1551
|
const crateInputs =
|
|
1212
1552
|
versionless !== null && hasCrateManifests ? await versionlessCrateInputs(projectRoot, workspaceRoot) : [];
|
|
1213
|
-
const versionlessProjectInputs =
|
|
1553
|
+
const versionlessProjectInputs =
|
|
1554
|
+
versionless === null
|
|
1555
|
+
? []
|
|
1556
|
+
: [...VERSIONLESS_PACKAGE_INPUTS, ...crateInputs, ...(projectRoot === '.' ? ROOT_LOCKFILE_EXCLUSIONS : [])];
|
|
1214
1557
|
// The options a TypeScript task's answer really depends on, which is the
|
|
1215
1558
|
// whole `extends` chain of the configs its commands name and not just those
|
|
1216
1559
|
// two files. Resolved once per project: every target below shares it.
|
|
@@ -1218,11 +1561,21 @@ async function createProjectTargets(
|
|
|
1218
1561
|
[...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])],
|
|
1219
1562
|
workspaceRoot,
|
|
1220
1563
|
);
|
|
1221
|
-
const toolchainInputs = [
|
|
1564
|
+
const toolchainInputs = [
|
|
1565
|
+
...RELEASE_REWRITTEN_WORKSPACE_INPUTS,
|
|
1566
|
+
bunLockInput(projectRoot),
|
|
1567
|
+
...TYPESCRIPT_PATCH_INPUTS,
|
|
1568
|
+
...typescriptConfigChain,
|
|
1569
|
+
];
|
|
1222
1570
|
const checkInputs =
|
|
1223
1571
|
versionless === null
|
|
1224
1572
|
? toolchainInputs
|
|
1225
|
-
: [
|
|
1573
|
+
: [
|
|
1574
|
+
...TYPESCRIPT_PATCH_INPUTS,
|
|
1575
|
+
...typescriptConfigChain,
|
|
1576
|
+
...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS,
|
|
1577
|
+
bunLockInput(projectRoot),
|
|
1578
|
+
];
|
|
1226
1579
|
const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
|
|
1227
1580
|
const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
|
|
1228
1581
|
const dependencyProduction =
|
|
@@ -1287,6 +1640,10 @@ async function createProjectTargets(
|
|
|
1287
1640
|
cwd: projectRoot,
|
|
1288
1641
|
},
|
|
1289
1642
|
};
|
|
1643
|
+
Object.assign(
|
|
1644
|
+
targets,
|
|
1645
|
+
scriptcPlatformTargets(packageJson, packageJsonPath, projectRoot, libTsconfigPath, toolchainInputs),
|
|
1646
|
+
);
|
|
1290
1647
|
}
|
|
1291
1648
|
|
|
1292
1649
|
if (hasTestTsconfig) {
|
|
@@ -1341,7 +1698,10 @@ async function createProjectTargets(
|
|
|
1341
1698
|
}
|
|
1342
1699
|
|
|
1343
1700
|
if (napiConfig) {
|
|
1344
|
-
Object.assign(
|
|
1701
|
+
Object.assign(
|
|
1702
|
+
targets,
|
|
1703
|
+
createNapiTargets(projectRoot, napiConfig, hostPlatform, nativeTools, isRepoRootedCargoProject),
|
|
1704
|
+
);
|
|
1345
1705
|
if (
|
|
1346
1706
|
!('napi-test' in (packageJson.nx?.targets ?? {})) &&
|
|
1347
1707
|
existsSync(join(absoluteProjectRoot, 'src/native.test.ts'))
|
|
@@ -1388,7 +1748,7 @@ async function createProjectTargets(
|
|
|
1388
1748
|
// `dependsOn` REPLACES rather than unions. These lists state what each target
|
|
1389
1749
|
// consumes — the fetched registry, the archive, the debug addon — and a
|
|
1390
1750
|
// package that must re-route one (build its artifact ahead of the test run,
|
|
1391
|
-
// or drop `cargo-test-
|
|
1751
|
+
// or drop `cargo-test-archive` because it compiles differently) can only say
|
|
1392
1752
|
// so by replacing the list; a union would make every inferred edge
|
|
1393
1753
|
// unremovable and a corrected order unrepresentable.
|
|
1394
1754
|
// Additive intent already has a spelling (`"..."` above), so a plugin-local
|
|
@@ -1403,7 +1763,6 @@ async function createProjectTargets(
|
|
|
1403
1763
|
const ownsCargoWorkspaceTargets = isCargoWorkspaceRoot;
|
|
1404
1764
|
if (ownsCargoWorkspaceTargets && cargoWorkspace) {
|
|
1405
1765
|
const cargoWorkspaceRoot = cargoWorkspace.projectRoot;
|
|
1406
|
-
targets[CARGO_TEST_COMPILE_TARGET] = createCargoTestCompileTarget(cargoWorkspaceRoot);
|
|
1407
1766
|
const workspaceInputs = [
|
|
1408
1767
|
...new Set(
|
|
1409
1768
|
(
|
|
@@ -1414,6 +1773,7 @@ async function createProjectTargets(
|
|
|
1414
1773
|
absoluteProjectRoot: join(workspaceRoot, cargoWorkspaceRoot),
|
|
1415
1774
|
memberDir: plan.package.dir,
|
|
1416
1775
|
cache: cargoWorkspace.inputsCache,
|
|
1776
|
+
cargo: cargoWorkspace.closureSource.cargo,
|
|
1417
1777
|
}),
|
|
1418
1778
|
),
|
|
1419
1779
|
)
|
|
@@ -1432,7 +1792,6 @@ async function createProjectTargets(
|
|
|
1432
1792
|
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
1433
1793
|
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
1434
1794
|
];
|
|
1435
|
-
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
1436
1795
|
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(
|
|
1437
1796
|
cargoWorkspaceRoot,
|
|
1438
1797
|
nextestToolConfigArg(cargoWorkspaceRoot),
|
|
@@ -1447,10 +1806,13 @@ async function createProjectTargets(
|
|
|
1447
1806
|
for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
|
|
1448
1807
|
Object.assign(
|
|
1449
1808
|
targets,
|
|
1450
|
-
createCargoCrossTestTargets(
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1809
|
+
createCargoCrossTestTargets(
|
|
1810
|
+
cargoWorkspaceRoot,
|
|
1811
|
+
nextestToolConfigArg(cargoWorkspaceRoot),
|
|
1812
|
+
crossTarget,
|
|
1813
|
+
[...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`],
|
|
1814
|
+
pluginInstalledIn(workspaceRoot),
|
|
1815
|
+
),
|
|
1454
1816
|
);
|
|
1455
1817
|
}
|
|
1456
1818
|
// A serial group's filter can span members, so no single crate owns it. The root
|
|
@@ -1461,6 +1823,7 @@ async function createProjectTargets(
|
|
|
1461
1823
|
for (const group of cargoWorkspace.serialGroups) {
|
|
1462
1824
|
targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(
|
|
1463
1825
|
cargoWorkspace,
|
|
1826
|
+
nativeTools,
|
|
1464
1827
|
await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)),
|
|
1465
1828
|
group,
|
|
1466
1829
|
);
|
|
@@ -1479,15 +1842,18 @@ async function createProjectTargets(
|
|
|
1479
1842
|
aggregateDependencies.length > 0
|
|
1480
1843
|
? { executor: 'nx:noop', cache: true, outputs: [], dependsOn: aggregateDependencies }
|
|
1481
1844
|
: createCargoTestTarget(cargoWorkspaceRoot);
|
|
1482
|
-
// One clippy over the whole workspace
|
|
1483
|
-
// of
|
|
1484
|
-
//
|
|
1485
|
-
//
|
|
1486
|
-
//
|
|
1487
|
-
//
|
|
1488
|
-
//
|
|
1845
|
+
// One clippy over the whole workspace. Clippy of a crate is a check build
|
|
1846
|
+
// of its closure; a target dir per crate compiled every shared dependency
|
|
1847
|
+
// once per crate (49 closures, 11 GiB on one repository) and no per-crate
|
|
1848
|
+
// cache hit ever repaid that. The workspace inputs are exactly the union of
|
|
1849
|
+
// every crate's, so the verdict caches on the same key set the archive
|
|
1850
|
+
// does. Non-root packages depend on this target. Its target dir is its own
|
|
1851
|
+
// (CARGO_LINT_CLIPPY_COMMAND, ./cross-check-policy.ts): Cargo flocks one
|
|
1852
|
+
// directory per invocation, and a workspace clippy holding the dev build's
|
|
1853
|
+
// `target/` queued the archive and every dev build behind it.
|
|
1489
1854
|
targets['cargo-lint'] = {
|
|
1490
1855
|
executor: 'nx:run-commands',
|
|
1856
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1491
1857
|
cache: true,
|
|
1492
1858
|
inputs: workspaceCargoInputs,
|
|
1493
1859
|
outputs: [],
|
|
@@ -1526,6 +1892,7 @@ async function createProjectTargets(
|
|
|
1526
1892
|
// macOS host demand the zig toolchain that the devenv profile keeps opt-in.
|
|
1527
1893
|
targets[CARGO_CROSS_LINT_TARGET] = {
|
|
1528
1894
|
executor: 'nx:run-commands',
|
|
1895
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1529
1896
|
cache: true,
|
|
1530
1897
|
inputs: workspaceCargoInputs,
|
|
1531
1898
|
outputs: [],
|
|
@@ -1541,23 +1908,29 @@ async function createProjectTargets(
|
|
|
1541
1908
|
// progress, so its bound is a wall-clock backstop, not a performance budget.
|
|
1542
1909
|
targets.mutation = {
|
|
1543
1910
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
1911
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1544
1912
|
cache: false,
|
|
1545
1913
|
options: { command: cargoFrozen('mutants --workspace'), cwd: cargoWorkspaceRoot, timeoutMs: MUTATION_TIMEOUT_MS },
|
|
1546
1914
|
};
|
|
1547
1915
|
targets.bench = {
|
|
1548
1916
|
executor: 'nx:run-commands',
|
|
1917
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1549
1918
|
cache: false,
|
|
1550
1919
|
options: { command: cargoFrozen('bench --workspace'), cwd: cargoWorkspaceRoot },
|
|
1551
1920
|
};
|
|
1552
|
-
//
|
|
1553
|
-
//
|
|
1554
|
-
//
|
|
1555
|
-
//
|
|
1556
|
-
|
|
1557
|
-
targets['cargo-
|
|
1921
|
+
// A read-only preview of the retention pass the plugin's postTasksExecution
|
|
1922
|
+
// schedules after runs that built (@smoothbricks/cargo-retain): the superseded unit
|
|
1923
|
+
// generations it would reclaim and why everything else stays. Never cached:
|
|
1924
|
+
// the verdict is about this machine's disk, not the commit.
|
|
1925
|
+
const retainTool = nativeToolDependsOn(nativeTools, 'cargo-retain');
|
|
1926
|
+
targets['cargo-retention'] = {
|
|
1558
1927
|
executor: 'nx:run-commands',
|
|
1559
1928
|
cache: false,
|
|
1560
|
-
|
|
1929
|
+
...(retainTool.length > 0 ? { dependsOn: retainTool } : {}),
|
|
1930
|
+
options: {
|
|
1931
|
+
command: nativeToolCommand(nativeTools, cargoWorkspaceRoot, 'cargo-retain', 'smoo-nx-cargo-retain'),
|
|
1932
|
+
cwd: cargoWorkspaceRoot,
|
|
1933
|
+
},
|
|
1561
1934
|
};
|
|
1562
1935
|
}
|
|
1563
1936
|
|
|
@@ -1568,6 +1941,7 @@ async function createProjectTargets(
|
|
|
1568
1941
|
projectRoot,
|
|
1569
1942
|
workspaceRoot,
|
|
1570
1943
|
cargoWorkspace,
|
|
1944
|
+
nativeTools,
|
|
1571
1945
|
);
|
|
1572
1946
|
// Serial-group runners belong to the workspace root, outside inferred ordinary tests. Explicit repository
|
|
1573
1947
|
// aggregates can reach them; their own inputs decide whether each runner executes or replays from cache.
|
|
@@ -1617,7 +1991,7 @@ async function createProjectTargets(
|
|
|
1617
1991
|
};
|
|
1618
1992
|
}
|
|
1619
1993
|
for (const name of Object.keys(declaredTargets)) {
|
|
1620
|
-
if (name === 'test' || !
|
|
1994
|
+
if (name === 'test' || !isTestNamespaceTargetName(name) || targets[name] !== undefined) continue;
|
|
1621
1995
|
targets[name] = { dependsOn: ['^build', 'build'] };
|
|
1622
1996
|
}
|
|
1623
1997
|
|
|
@@ -1655,6 +2029,7 @@ async function createProjectTargets(
|
|
|
1655
2029
|
// would skip work a cold registry still needs. Nothing here is a
|
|
1656
2030
|
// workspace output, so there is nothing for Nx to restore in its place.
|
|
1657
2031
|
cache: false,
|
|
2032
|
+
inputs: cargoFetchInputs(projectRoot),
|
|
1658
2033
|
options: {
|
|
1659
2034
|
// One fetch per manifest, independent of the others: Cargo's own
|
|
1660
2035
|
// package-cache lock arbitrates the CARGO_HOME they share.
|
|
@@ -1693,7 +2068,8 @@ async function createProjectTargets(
|
|
|
1693
2068
|
// Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
|
|
1694
2069
|
// directories. Resolve tool versions from the command's actual directory.
|
|
1695
2070
|
// Name the npm packages the command runs (cargoCommandNpmPackages) unless
|
|
1696
|
-
// the target already does.
|
|
2071
|
+
// the target already does, and the Cargo.lock entries its crates reach (the
|
|
2072
|
+
// lock-scope node of the directory it runs in) unless its inputs already do.
|
|
1697
2073
|
for (const [name, target] of Object.entries(targets)) {
|
|
1698
2074
|
const text = targetCommandText(target);
|
|
1699
2075
|
if (!runsFrozenCargo(text)) continue;
|
|
@@ -1706,25 +2082,27 @@ async function createProjectTargets(
|
|
|
1706
2082
|
? ' && cargo nextest --version'
|
|
1707
2083
|
: '';
|
|
1708
2084
|
const inputs = target.inputs ?? CARGO_INPUTS;
|
|
1709
|
-
const namesPackages = inputs.some(
|
|
2085
|
+
const namesPackages = inputs.some(
|
|
2086
|
+
(input) => typeof input === 'object' && 'externalDependencies' in input && !isCargoLockInput(input),
|
|
2087
|
+
);
|
|
2088
|
+
const namesLock = inputs.some((input) => input === CARGO_CLOSURE_INPUT || isCargoLockInput(input));
|
|
2089
|
+
const lockDirectory = typeof cwd === 'string' ? cwd : projectRoot;
|
|
1710
2090
|
target.inputs = [
|
|
1711
2091
|
...inputs,
|
|
1712
|
-
...
|
|
2092
|
+
...cargoToolchainInputs(),
|
|
1713
2093
|
cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
|
|
1714
|
-
...(namesPackages
|
|
2094
|
+
...(namesPackages
|
|
2095
|
+
? []
|
|
2096
|
+
: [{ externalDependencies: cargoCommandNpmPackages(target, text, pluginInstalledIn(workspaceRoot)) }]),
|
|
2097
|
+
...(namesLock
|
|
2098
|
+
? []
|
|
2099
|
+
: cargoSourcesUnder(lockDirectory, cargoWorkspaces).length > 0
|
|
2100
|
+
? [{ externalDependencies: [cargoLockNodeName(lockDirectory)] }]
|
|
2101
|
+
: // No project-rooted Cargo workspace claims these crates, so the plugin holds no resolve to scope.
|
|
2102
|
+
[UNRESOLVED_CARGO_LOCK_INPUT]),
|
|
1715
2103
|
];
|
|
1716
2104
|
}
|
|
1717
2105
|
|
|
1718
|
-
// `build` warms the test executables' compile; in a nested package that names
|
|
1719
|
-
// the root workspace's one compile.
|
|
1720
|
-
const cargoTestCompileDependency: CargoTargetDependency | null = targets[CARGO_TEST_COMPILE_TARGET]
|
|
1721
|
-
? CARGO_TEST_COMPILE_TARGET
|
|
1722
|
-
: isCargoProject && cargoWorkspace
|
|
1723
|
-
? cargoTargetDependency(projectName, {
|
|
1724
|
-
projectName: cargoWorkspace.rootProjectName,
|
|
1725
|
-
targetName: CARGO_TEST_COMPILE_TARGET,
|
|
1726
|
-
})
|
|
1727
|
-
: null;
|
|
1728
2106
|
const napiDebug = targets['napi-debug'];
|
|
1729
2107
|
if (napiDebug && cargoWorkspace) {
|
|
1730
2108
|
// A crate whose project also builds the debug cdylib runs its tests after
|
|
@@ -1744,15 +2122,6 @@ async function createProjectTargets(
|
|
|
1744
2122
|
}
|
|
1745
2123
|
}
|
|
1746
2124
|
} else if (napiDebug) {
|
|
1747
|
-
for (const [name, target] of Object.entries(targets)) {
|
|
1748
|
-
if (!name.startsWith('cargo-test-') || name === CARGO_TEST_COMPILE_TARGET) {
|
|
1749
|
-
continue;
|
|
1750
|
-
}
|
|
1751
|
-
const dependsOn = target.dependsOn ?? [];
|
|
1752
|
-
if (dependsOn.includes(CARGO_TEST_COMPILE_TARGET) && !dependsOn.includes('napi-debug')) {
|
|
1753
|
-
target.dependsOn = [...dependsOn, 'napi-debug'];
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
2125
|
const cargoTest = targets[CARGO_TEST_TARGET];
|
|
1757
2126
|
if (
|
|
1758
2127
|
cargoTest?.options &&
|
|
@@ -1773,6 +2142,32 @@ async function createProjectTargets(
|
|
|
1773
2142
|
hostPlatform,
|
|
1774
2143
|
);
|
|
1775
2144
|
|
|
2145
|
+
// `<tool>-native` is the host's own build of one tool, so a test that runs it names one edge: `cli-native` is the
|
|
2146
|
+
// declared `cli-<arch>-<family>` build for this machine, `napi-native` the addon (this host's platform target, or
|
|
2147
|
+
// cargo-napi where no configured triple is this machine's), and scriptc-native its host executable producer.
|
|
2148
|
+
// Each is picked from hostPlatformBinaries by the same
|
|
2149
|
+
// suffix rule, its family name `-native` joins it to `build`, and it states no outputs. It runs nothing, so it
|
|
2150
|
+
// states `cache: false`; a cached aggregate would need inputs of its own. A host with no such producer gets no
|
|
2151
|
+
// aggregate, and inference makes no test depend on one.
|
|
2152
|
+
const hostBuilds: Record<string, string[]> = {
|
|
2153
|
+
'scriptc-native': hostPlatformBinaries.filter((name) => name.startsWith('scriptc-')),
|
|
2154
|
+
'cli-native': hostPlatformBinaries.filter((name) => name.startsWith('cli-')),
|
|
2155
|
+
'napi-native': targets['cargo-napi']
|
|
2156
|
+
? ['cargo-napi']
|
|
2157
|
+
: hostPlatformBinaries.filter((name) => name.startsWith('napi-')),
|
|
2158
|
+
};
|
|
2159
|
+
for (const [name, dependsOn] of Object.entries(hostBuilds)) {
|
|
2160
|
+
if (dependsOn.length > 0) {
|
|
2161
|
+
targets[name] = {
|
|
2162
|
+
executor: 'nx:noop',
|
|
2163
|
+
cache: false,
|
|
2164
|
+
outputs: [],
|
|
2165
|
+
dependsOn,
|
|
2166
|
+
configurations: { production: {} },
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
|
|
1776
2171
|
// A deploy is never cached; the build half beside it always is.
|
|
1777
2172
|
//
|
|
1778
2173
|
// Nx's cache answers "did this exact input set already produce an output". A deploy's real
|
|
@@ -1857,9 +2252,6 @@ async function createProjectTargets(
|
|
|
1857
2252
|
dependsOn: [
|
|
1858
2253
|
...new Set([
|
|
1859
2254
|
'^build',
|
|
1860
|
-
// Compiling the test executables is unbounded preparation. Cargo
|
|
1861
|
-
// reuses its incremental state; Nx never restores that shared state.
|
|
1862
|
-
...(cargoTestCompileDependency ? [cargoTestCompileDependency] : []),
|
|
1863
2255
|
...buildOutputTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)]),
|
|
1864
2256
|
...hostPlatformBinaries,
|
|
1865
2257
|
]),
|
|
@@ -1939,7 +2331,7 @@ async function createProjectTargets(
|
|
|
1939
2331
|
commands: lintCommands,
|
|
1940
2332
|
inputs: lintProgramInputs,
|
|
1941
2333
|
eslintFileSet,
|
|
1942
|
-
} = projectLintCommands(projectRoot, workspaceRoot,
|
|
2334
|
+
} = projectLintCommands(projectRoot, workspaceRoot, eslint);
|
|
1943
2335
|
// Every lint tool reaches its own verdict in one run: run-commands would end the
|
|
1944
2336
|
// other tools once one fails, and their findings would surface a run later.
|
|
1945
2337
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
@@ -1958,7 +2350,7 @@ async function createProjectTargets(
|
|
|
1958
2350
|
`{workspaceRoot}/${name}`,
|
|
1959
2351
|
`{projectRoot}/${name}`,
|
|
1960
2352
|
]),
|
|
1961
|
-
|
|
2353
|
+
...(eslint?.configImports ?? []).map((path) => `{workspaceRoot}/${path}`),
|
|
1962
2354
|
],
|
|
1963
2355
|
...(lintCommands.length > 0
|
|
1964
2356
|
? {
|
|
@@ -1968,12 +2360,22 @@ async function createProjectTargets(
|
|
|
1968
2360
|
};
|
|
1969
2361
|
}
|
|
1970
2362
|
|
|
2363
|
+
// Publish each inferred target's semantic kind (`inferredTaskKind`) as metadata. Nx merges metadata beneath a
|
|
2364
|
+
// declaration, so the final graph still says which tasks are build and which are test work after a package rewrites
|
|
2365
|
+
// one. Fresh objects: `CARGO_PRODUCER_METADATA` is shared by every producer.
|
|
2366
|
+
for (const [name, target] of Object.entries(targets)) {
|
|
2367
|
+
const kind = inferredTaskKind(name);
|
|
2368
|
+
if (kind !== undefined) {
|
|
2369
|
+
target.metadata = { ...target.metadata, smooTaskKind: kind };
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
|
|
1971
2373
|
// A declared target REPLACES the inferred input list, pin included, so a
|
|
1972
2374
|
// repository that hand-writes `inputs` for a cargo target silently loses its
|
|
1973
|
-
// toolchain identity. Name the
|
|
1974
|
-
// reference it as `cargoToolchain` instead of restating
|
|
2375
|
+
// toolchain identity. Name the identity once here so such a declaration can
|
|
2376
|
+
// reference it as `cargoToolchain` instead of restating entries that could
|
|
1975
2377
|
// drift from the plugin; `smoo monorepo validate` refuses a cached cargo
|
|
1976
|
-
// target
|
|
2378
|
+
// target that does not reach it. Defined only for projects that
|
|
1977
2379
|
// HAVE cargo targets: a project's namedInputs definitions are hashed into
|
|
1978
2380
|
// its configuration hash, so defining it everywhere would invalidate every
|
|
1979
2381
|
// task in the repository to serve projects that can never reference it.
|
|
@@ -1985,7 +2387,7 @@ async function createProjectTargets(
|
|
|
1985
2387
|
[VERSIONLESS_DEFAULT_INPUT]: ['default', ...versionlessProjectInputs],
|
|
1986
2388
|
}),
|
|
1987
2389
|
...(Object.keys(targets).some((name) => name.startsWith('cargo-') || name.startsWith('napi-'))
|
|
1988
|
-
? { [CARGO_TOOLCHAIN_NAMED_INPUT]:
|
|
2390
|
+
? { [CARGO_TOOLCHAIN_NAMED_INPUT]: cargoToolchainInputs() }
|
|
1989
2391
|
: {}),
|
|
1990
2392
|
};
|
|
1991
2393
|
// A custom Cargo target names this instead of a hand-kept crate list or a
|
|
@@ -1993,19 +2395,21 @@ async function createProjectTargets(
|
|
|
1993
2395
|
// computation and Nx hashes its files from its own index. Defined for a
|
|
1994
2396
|
// project with a workspace crate under its root — the same projects the
|
|
1995
2397
|
// `--closure <projectRoot>` command could describe.
|
|
1996
|
-
const closureSources = cargoWorkspaces
|
|
1997
|
-
workspace.packages.some(({ package: pkg }) => {
|
|
1998
|
-
const crate = posix.join(workspace.projectRoot, pkg.dir);
|
|
1999
|
-
return projectRoot === '.' || crate === projectRoot || crate.startsWith(`${projectRoot}/`);
|
|
2000
|
-
}),
|
|
2001
|
-
);
|
|
2398
|
+
const closureSources = cargoSourcesUnder(projectRoot, cargoWorkspaces);
|
|
2002
2399
|
if (closureSources.length > 0) {
|
|
2003
|
-
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(
|
|
2004
|
-
projectRoot,
|
|
2005
|
-
closureSources.map((workspace) => workspace.closureSource),
|
|
2006
|
-
);
|
|
2400
|
+
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot, closureSources);
|
|
2007
2401
|
}
|
|
2402
|
+
const externalNodes = await lockScopeNodes(
|
|
2403
|
+
projectRoot,
|
|
2404
|
+
[
|
|
2405
|
+
...Object.values(targets).map((target) => target.inputs),
|
|
2406
|
+
...Object.values(declaredTargets).map((target) => (isRecord(target) ? target.inputs : undefined)),
|
|
2407
|
+
...Object.values(namedInputs),
|
|
2408
|
+
],
|
|
2409
|
+
cargoWorkspaces,
|
|
2410
|
+
);
|
|
2008
2411
|
return {
|
|
2412
|
+
...(Object.keys(externalNodes).length === 0 ? {} : { externalNodes }),
|
|
2009
2413
|
projects: {
|
|
2010
2414
|
[projectRoot]: {
|
|
2011
2415
|
name: projectName,
|
|
@@ -2024,6 +2428,51 @@ async function createProjectTargets(
|
|
|
2024
2428
|
};
|
|
2025
2429
|
}
|
|
2026
2430
|
|
|
2431
|
+
/** The Cargo resolves with a workspace crate under `directory`: the ones its crates' closure and lock scope cover. */
|
|
2432
|
+
function cargoSourcesUnder(directory: string, cargoWorkspaces: readonly CargoWorkspace[]): CargoClosureSource[] {
|
|
2433
|
+
return cargoWorkspaces
|
|
2434
|
+
.filter((workspace) =>
|
|
2435
|
+
workspace.packages.some(({ package: pkg }) => {
|
|
2436
|
+
const crate = posix.join(workspace.projectRoot, pkg.dir);
|
|
2437
|
+
return directory === '.' || crate === directory || crate.startsWith(`${directory}/`);
|
|
2438
|
+
}),
|
|
2439
|
+
)
|
|
2440
|
+
.map((workspace) => workspace.closureSource);
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
/**
|
|
2444
|
+
* The lock-scope nodes a project publishes: its own bun node, and one Cargo
|
|
2445
|
+
* node per directory its inputs name, computed from the resolves that cover
|
|
2446
|
+
* it. A project names only nodes its own crates' resolves define, so two
|
|
2447
|
+
* projects publishing the same node publish the same value.
|
|
2448
|
+
*/
|
|
2449
|
+
async function lockScopeNodes(
|
|
2450
|
+
projectRoot: string,
|
|
2451
|
+
inputLists: readonly unknown[],
|
|
2452
|
+
cargoWorkspaces: readonly CargoWorkspace[],
|
|
2453
|
+
): Promise<Record<string, ProjectGraphExternalNode>> {
|
|
2454
|
+
const directories = new Set<string>();
|
|
2455
|
+
for (const inputs of inputLists) {
|
|
2456
|
+
if (!Array.isArray(inputs)) continue;
|
|
2457
|
+
for (const input of inputs) {
|
|
2458
|
+
if (!isRecord(input) || !Array.isArray(input.externalDependencies)) continue;
|
|
2459
|
+
for (const name of input.externalDependencies) {
|
|
2460
|
+
if (typeof name === 'string' && name.startsWith(CARGO_LOCK_NODE_PREFIX)) {
|
|
2461
|
+
directories.add(name.slice(CARGO_LOCK_NODE_PREFIX.length));
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
const own = bunLockNode(projectRoot);
|
|
2467
|
+
const nodes: Record<string, ProjectGraphExternalNode> = { [own.name]: own };
|
|
2468
|
+
for (const node of await Promise.all(
|
|
2469
|
+
[...directories].map((directory) => cargoLockNode(directory, cargoSourcesUnder(directory, cargoWorkspaces))),
|
|
2470
|
+
)) {
|
|
2471
|
+
nodes[node.name] = node;
|
|
2472
|
+
}
|
|
2473
|
+
return nodes;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2027
2476
|
interface ResolvedCargoWasmConfig {
|
|
2028
2477
|
cargoPackage: string;
|
|
2029
2478
|
libraryName: string;
|
|
@@ -2154,21 +2603,28 @@ interface ResolvedNapiConfig {
|
|
|
2154
2603
|
}
|
|
2155
2604
|
|
|
2156
2605
|
function inferTypescriptOutputs(tsconfigPath: string, packageJsonPath: string): string[] {
|
|
2606
|
+
const outDir = typescriptOutDir(tsconfigPath, packageJsonPath);
|
|
2607
|
+
// No .tsbuildinfo here: the emit executor overlays incremental: false, so
|
|
2608
|
+
// tsc-js never writes one and a declared-but-absent output fails the
|
|
2609
|
+
// release-candidate output inspection.
|
|
2610
|
+
return outDir === null
|
|
2611
|
+
? ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}']
|
|
2612
|
+
: [`{projectRoot}/${outDir}/`];
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
/** The project-relative `compilerOptions.outDir` the config itself states, or null when it states none. */
|
|
2616
|
+
function typescriptOutDir(tsconfigPath: string, packageJsonPath: string): string | null {
|
|
2157
2617
|
const tsconfig: unknown = readJsonFile(tsconfigPath);
|
|
2158
2618
|
const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
|
|
2159
2619
|
const outDir = compilerOptions?.outDir;
|
|
2160
2620
|
if (typeof outDir !== 'string' || outDir.length === 0) {
|
|
2161
|
-
|
|
2162
|
-
// tsc-js never writes one and a declared-but-absent output fails the
|
|
2163
|
-
// release-candidate output inspection.
|
|
2164
|
-
return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
|
|
2621
|
+
return null;
|
|
2165
2622
|
}
|
|
2166
|
-
|
|
2167
2623
|
const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
|
|
2168
2624
|
if (normalized === '.' || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('/')) {
|
|
2169
2625
|
throw new Error(`${packageJsonPath}: tsconfig.lib.json compilerOptions.outDir must stay inside the project`);
|
|
2170
2626
|
}
|
|
2171
|
-
return
|
|
2627
|
+
return normalized.replace(/\/$/, '');
|
|
2172
2628
|
}
|
|
2173
2629
|
|
|
2174
2630
|
function resolveNapiConfig(
|
|
@@ -2220,6 +2676,7 @@ function createNapiTargets(
|
|
|
2220
2676
|
projectRoot: string,
|
|
2221
2677
|
config: ResolvedNapiConfig,
|
|
2222
2678
|
hostPlatform: NapiPlatform | null,
|
|
2679
|
+
nativeTools: NativeTools | null,
|
|
2223
2680
|
repoRooted: boolean,
|
|
2224
2681
|
): Record<string, TargetConfiguration> {
|
|
2225
2682
|
// napi derives the addon filename ([name]) from the nearest package.json `napi`
|
|
@@ -2234,7 +2691,24 @@ function createNapiTargets(
|
|
|
2234
2691
|
// A repository-root Cargo invocation runs outside the owning npm package, so
|
|
2235
2692
|
// Nx's root-only PATH cannot resolve that package's napi CLI.
|
|
2236
2693
|
const napiCommand = repoRooted ? posix.join(projectRoot, 'node_modules/.bin/napi') : 'napi';
|
|
2237
|
-
const
|
|
2694
|
+
const outputDir = (projectOutput: string) => (repoRooted ? posix.join(projectRoot, projectOutput) : projectOutput);
|
|
2695
|
+
// The directory a run writes into, as its `outputDir` option states it for the run's profile.
|
|
2696
|
+
const runOutputDirectory = outputDir(OUTPUT_DIR_ARGUMENT);
|
|
2697
|
+
// After a build, the step that writes its input record (build-inputs.ts) into the output directory from the dep-info
|
|
2698
|
+
// rustc wrote for the addon (`target/[<triple>/]<profile>/lib<crate>.d`). The record is inside the target's
|
|
2699
|
+
// outputs, so Nx restores it with the addon it describes. Relative to the runner's cwd, so the hashed command is
|
|
2700
|
+
// the same in every checkout.
|
|
2701
|
+
const recordInputs = (triple: string | null, profile: CargoProfile, outputDirectory: string): string => {
|
|
2702
|
+
const depInfo = posix.join(
|
|
2703
|
+
...(triple === null ? [] : [triple]),
|
|
2704
|
+
CARGO_PROFILE_OUTPUT_DIR[profile],
|
|
2705
|
+
`lib${config.cargoPackage.replaceAll('-', '_')}.d`,
|
|
2706
|
+
);
|
|
2707
|
+
const bin = nativeToolCommand(nativeTools, cargoCwd, 'build-inputs', 'smoo-nx-build-inputs');
|
|
2708
|
+
return ` && ${bin} --manifest-path ${config.manifestPath} --dep-info ${depInfo} --output ${outputDirectory}`;
|
|
2709
|
+
};
|
|
2710
|
+
// The task that builds the executable recordInputs runs, when this workspace builds it.
|
|
2711
|
+
const buildInputsTool = nativeToolDependsOn(nativeTools, 'build-inputs');
|
|
2238
2712
|
const hasHostPlatformTarget = config.targets.some((triple) => {
|
|
2239
2713
|
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
2240
2714
|
return convention !== undefined && sameNapiPlatform(convention, hostPlatform);
|
|
@@ -2251,13 +2725,14 @@ function createNapiTargets(
|
|
|
2251
2725
|
// production loads never see it.
|
|
2252
2726
|
targets['napi-debug'] = {
|
|
2253
2727
|
executor: 'nx:run-commands',
|
|
2728
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
2254
2729
|
cache: true,
|
|
2255
2730
|
dependsOn: ['^build'],
|
|
2256
2731
|
inputs: cargoInputs,
|
|
2257
|
-
outputs: ['{projectRoot}/.cache/native-debug'],
|
|
2732
|
+
outputs: ['{projectRoot}/.cache/native-debug/'],
|
|
2258
2733
|
options: {
|
|
2259
2734
|
cwd: cargoCwd,
|
|
2260
|
-
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${
|
|
2735
|
+
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir('.cache/native-debug')}`,
|
|
2261
2736
|
},
|
|
2262
2737
|
};
|
|
2263
2738
|
|
|
@@ -2266,21 +2741,27 @@ function createNapiTargets(
|
|
|
2266
2741
|
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
2267
2742
|
// (a plain build and a `--target` build write different target/
|
|
2268
2743
|
// subdirectories); native.ts already resolves the identical
|
|
2269
|
-
// platform-suffixed filename from
|
|
2270
|
-
//
|
|
2744
|
+
// platform-suffixed filename from <tree>/<platform-dir> after <tree>/host,
|
|
2745
|
+
// in the one tree its package's source authority selects (.cache/native-dev
|
|
2746
|
+
// in a checkout, dist/native installed).
|
|
2271
2747
|
const hostBuild = (profile: CargoProfile): string =>
|
|
2272
|
-
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${
|
|
2748
|
+
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
|
|
2749
|
+
const hostOutputs = nativeOutputPaths('host');
|
|
2273
2750
|
targets['cargo-napi'] = {
|
|
2274
2751
|
executor: 'nx:run-commands',
|
|
2752
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
2275
2753
|
cache: true,
|
|
2276
|
-
dependsOn: ['^build'],
|
|
2754
|
+
dependsOn: ['^build', ...buildInputsTool],
|
|
2277
2755
|
inputs: cargoInputs,
|
|
2278
|
-
outputs: [
|
|
2756
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
2279
2757
|
options: {
|
|
2280
2758
|
cwd: cargoCwd,
|
|
2281
2759
|
command: hostBuild('dev'),
|
|
2760
|
+
outputDir: hostOutputs.dev,
|
|
2761
|
+
},
|
|
2762
|
+
configurations: {
|
|
2763
|
+
[RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
|
|
2282
2764
|
},
|
|
2283
|
-
configurations: { [RELEASE_CONFIGURATION]: { command: hostBuild('release') } },
|
|
2284
2765
|
};
|
|
2285
2766
|
}
|
|
2286
2767
|
|
|
@@ -2290,41 +2771,52 @@ function createNapiTargets(
|
|
|
2290
2771
|
throw new Error(`Missing N-API target convention for ${triple}`);
|
|
2291
2772
|
}
|
|
2292
2773
|
const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
|
|
2293
|
-
const
|
|
2774
|
+
const outputs = nativeOutputPaths(convention.outputName);
|
|
2294
2775
|
if (convention.targetFamily === 'linux') {
|
|
2295
2776
|
// Every host builds a Linux addon the same way: devenv's zig through
|
|
2296
2777
|
// cargo-zigbuild, glibc pinned by the triple suffix. The napi CLI cannot
|
|
2297
2778
|
// carry that suffix (it looks for the artifact under
|
|
2298
2779
|
// target/<triple>.2.17/), so the executor names the `.node` itself.
|
|
2780
|
+
const nodeFile = (directory: string): string =>
|
|
2781
|
+
`{projectRoot}/${directory}/${config.binaryName}.${convention.outputName}.node`;
|
|
2299
2782
|
targets[targetName] = {
|
|
2300
2783
|
executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
|
|
2784
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
2301
2785
|
cache: true,
|
|
2302
2786
|
inputs: napiInputs(projectRoot, repoRooted, []),
|
|
2303
|
-
|
|
2787
|
+
// The executor takes no `outputDir`: its `output` file is the one place each profile states where it
|
|
2788
|
+
// writes, and the declared output reads the directory holding it from there (`/../`, which Nx's interpolation
|
|
2789
|
+
// joins to the parent). The build-input record stamped beside the `.node` file is restored with it.
|
|
2790
|
+
outputs: ['{options.output}/../'],
|
|
2304
2791
|
options: {
|
|
2305
2792
|
target: `${triple}.${LINUX_GLIBC_FLOOR}`,
|
|
2306
2793
|
manifestPath: posix.join(cargoCwd, config.manifestPath),
|
|
2307
2794
|
package: config.cargoPackage,
|
|
2308
|
-
output:
|
|
2795
|
+
output: nodeFile(outputs.dev),
|
|
2309
2796
|
},
|
|
2310
|
-
configurations: { [RELEASE_CONFIGURATION]: { release: true } },
|
|
2797
|
+
configurations: { [RELEASE_CONFIGURATION]: { release: true, output: nodeFile(outputs.release) } },
|
|
2311
2798
|
};
|
|
2312
2799
|
continue;
|
|
2313
2800
|
}
|
|
2314
2801
|
// macOS addons need Apple's SDK, which zig does not carry: the napi CLI
|
|
2315
2802
|
// drives the host's own toolchain and writes the platform `.d.ts`.
|
|
2316
2803
|
const platformBuild = (profile: CargoProfile): string =>
|
|
2317
|
-
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple} ${commonCommand} --output-dir ${
|
|
2804
|
+
`${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple} ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(triple, profile, runOutputDirectory)}`;
|
|
2318
2805
|
targets[targetName] = {
|
|
2319
2806
|
executor: 'nx:run-commands',
|
|
2807
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
2320
2808
|
cache: true,
|
|
2809
|
+
...(buildInputsTool.length > 0 ? { dependsOn: buildInputsTool } : {}),
|
|
2321
2810
|
inputs: cargoInputs,
|
|
2322
|
-
outputs: [`{projectRoot}/${
|
|
2811
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
2323
2812
|
options: {
|
|
2324
2813
|
cwd: cargoCwd,
|
|
2325
2814
|
command: platformBuild('dev'),
|
|
2815
|
+
outputDir: outputs.dev,
|
|
2816
|
+
},
|
|
2817
|
+
configurations: {
|
|
2818
|
+
[RELEASE_CONFIGURATION]: { command: platformBuild('release'), outputDir: outputs.release },
|
|
2326
2819
|
},
|
|
2327
|
-
configurations: { [RELEASE_CONFIGURATION]: { command: platformBuild('release') } },
|
|
2328
2820
|
};
|
|
2329
2821
|
}
|
|
2330
2822
|
return targets;
|
|
@@ -2366,9 +2858,11 @@ async function readPackageJson(packageJsonPath: string): Promise<PackageJson> {
|
|
|
2366
2858
|
const rawNx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
2367
2859
|
return {
|
|
2368
2860
|
...('bin' in parsed ? { bin: parsed.bin } : {}),
|
|
2861
|
+
...(isRecord(parsed.devDependencies) ? { devDependencies: parsed.devDependencies } : {}),
|
|
2369
2862
|
...(typeof parsed.name === 'string' ? { name: parsed.name } : {}),
|
|
2370
2863
|
...(isRecord(parsed.napi) ? { napi: parsed.napi } : {}),
|
|
2371
2864
|
...(typeof parsed.private === 'boolean' ? { private: parsed.private } : {}),
|
|
2865
|
+
...('scriptc' in parsed ? { scriptc: parsed.scriptc } : {}),
|
|
2372
2866
|
...(isRecord(parsed.scripts) ? { scripts: parsed.scripts } : {}),
|
|
2373
2867
|
...(rawNx
|
|
2374
2868
|
? {
|
|
@@ -2525,10 +3019,28 @@ async function resolveCargoWorkspaces(
|
|
|
2525
3019
|
// piece excludes them: each test is selected by exactly one target.
|
|
2526
3020
|
const serialExclusion = serialGroups.length === 0 ? null : serialGroups.map((group) => group.filter).join(' or ');
|
|
2527
3021
|
const notSerial = serialExclusion === null ? [] : [`not (${serialExclusion})`];
|
|
3022
|
+
const timings = readNextestTimings(join(absoluteRoot, NEXTEST_TIMINGS_PATH));
|
|
3023
|
+
for (const crate of Object.keys(timings)) {
|
|
3024
|
+
if (!attributed.some((pkg) => pkg.name === crate && pkg.testShards > 1)) {
|
|
3025
|
+
throw new Error(
|
|
3026
|
+
`${posix.join(rootProject.root, NEXTEST_TIMINGS_PATH)} times ${crate}, which is no member of this Cargo ` +
|
|
3027
|
+
'workspace that declares smoothbricks.test.shards above 1',
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
2528
3031
|
for (const pkg of attributed) {
|
|
2529
3032
|
const pieces: CargoTestPiece[] = [];
|
|
2530
3033
|
const sharded = pkg.testShards > 1;
|
|
2531
|
-
const
|
|
3034
|
+
const timed = timings[pkg.name] ?? {};
|
|
3035
|
+
const named = Object.keys(timed);
|
|
3036
|
+
const exceptionalHere = sharded ? exceptional : null;
|
|
3037
|
+
// The tests the hash does not place: nextest.toml's exceptional class and the measured slow tests.
|
|
3038
|
+
const pin =
|
|
3039
|
+
named.length === 0
|
|
3040
|
+
? exceptionalHere
|
|
3041
|
+
: exceptionalHere === null
|
|
3042
|
+
? namedTestsFilter(named)
|
|
3043
|
+
: `(${exceptionalHere}) or (${namedTestsFilter(named)})`;
|
|
2532
3044
|
const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
|
|
2533
3045
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2534
3046
|
const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
|
|
@@ -2539,10 +3051,23 @@ async function resolveCargoWorkspaces(
|
|
|
2539
3051
|
});
|
|
2540
3052
|
}
|
|
2541
3053
|
if (pin !== null) {
|
|
3054
|
+
// Measured tests are dealt by time; the last shard also takes every exceptional test the
|
|
3055
|
+
// manifest does not name, so the exception shards stay an exact cover of the pin.
|
|
3056
|
+
const members = named.length === 0 ? null : timedShardMembers(timed, pkg.testShards);
|
|
2542
3057
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
3058
|
+
const own = members?.[index - 1];
|
|
3059
|
+
const unnamed =
|
|
3060
|
+
own !== undefined && exceptionalHere !== null && index === pkg.testShards
|
|
3061
|
+
? ` or ((${exceptionalHere}) and not (${namedTestsFilter(named)}))`
|
|
3062
|
+
: '';
|
|
2543
3063
|
pieces.push({
|
|
2544
|
-
extra: ` --partition hash:${index}/${pkg.testShards}
|
|
2545
|
-
selector: [
|
|
3064
|
+
extra: own === undefined ? ` --partition hash:${index}/${pkg.testShards}` : '',
|
|
3065
|
+
selector: [
|
|
3066
|
+
own === undefined
|
|
3067
|
+
? `package(${pkg.name}) and (${pin})`
|
|
3068
|
+
: `package(${pkg.name}) and ((${namedTestsFilter(own)})${unnamed})`,
|
|
3069
|
+
...notSerial,
|
|
3070
|
+
].join(' and '),
|
|
2546
3071
|
targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
|
|
2547
3072
|
});
|
|
2548
3073
|
}
|
|
@@ -2595,12 +3120,13 @@ async function resolveCargoWorkspaces(
|
|
|
2595
3120
|
* own on every run, so N pieces paid N extractions of every binary in the
|
|
2596
3121
|
* workspace to run 1/N of the tests each: on a workspace with ~200 test
|
|
2597
3122
|
* binaries, ~25 runners extracting side by side on a loaded host all hit the
|
|
2598
|
-
* 120s bound still "Extracting". `smoo-nx-nextest-extract`
|
|
2599
|
-
*
|
|
3123
|
+
* 120s bound still "Extracting". `smoo-nx-nextest-extract` reads the archive's
|
|
3124
|
+
* key, the hash of the task that produced it (createCargoTestArchiveTarget),
|
|
3125
|
+
* unpacks it under that key unless a previous runner already did — one
|
|
2600
3126
|
* extracts while the rest wait — and prints the directory; the run then reuses
|
|
2601
3127
|
* it through nextest's own reuse-build flags, which is what `--archive-file`
|
|
2602
|
-
* does after unpacking. Keyed by the
|
|
2603
|
-
* archive can never run an older extraction's binaries. The one difference
|
|
3128
|
+
* does after unpacking. Keyed by the producing task's inputs, so a rebuilt or
|
|
3129
|
+
* restored archive of other inputs can never run an older extraction's binaries. The one difference
|
|
2604
3130
|
* from `--archive-file` is the Rust standard library directory: nextest has no
|
|
2605
3131
|
* flag to remap it, so a run uses the producing toolchain's own sysroot rather
|
|
2606
3132
|
* than the archived copy of it — the same toolchain, because the archive's hash
|
|
@@ -2649,6 +3175,7 @@ async function addCargoTestTargets(
|
|
|
2649
3175
|
projectRoot: string,
|
|
2650
3176
|
workspaceRoot: string,
|
|
2651
3177
|
workspace: CargoWorkspace,
|
|
3178
|
+
nativeTools: NativeTools | null,
|
|
2652
3179
|
): Promise<string[]> {
|
|
2653
3180
|
const targetNames: string[] = [];
|
|
2654
3181
|
for (const plan of workspace.packages) {
|
|
@@ -2662,7 +3189,7 @@ async function addCargoTestTargets(
|
|
|
2662
3189
|
});
|
|
2663
3190
|
for (const piece of plan.pieces) {
|
|
2664
3191
|
targetNames.push(piece.targetName);
|
|
2665
|
-
targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
|
|
3192
|
+
targets[piece.targetName] = cargoTestRunnerTarget(workspace, nativeTools, archive, inputs, piece);
|
|
2666
3193
|
}
|
|
2667
3194
|
}
|
|
2668
3195
|
return targetNames;
|
|
@@ -2691,15 +3218,16 @@ function serialGroupMemberDirs(workspace: CargoWorkspace, group: SerialTestGroup
|
|
|
2691
3218
|
|
|
2692
3219
|
/**
|
|
2693
3220
|
* The inputs of the runners that select crates from one cargo workspace: the
|
|
2694
|
-
* sources of the crates they select,
|
|
2695
|
-
* nextest config.
|
|
3221
|
+
* sources of the crates they select, the manifest of every package the workspace
|
|
3222
|
+
* builds, and the repository's nextest config.
|
|
2696
3223
|
*
|
|
2697
3224
|
* Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
|
|
2698
3225
|
* `{projectRoot}` glob hashes only files this project owns, and sibling manifests
|
|
2699
3226
|
* belong to whichever nested project holds them. A workspace nextest build unifies
|
|
2700
|
-
* features across every
|
|
2701
|
-
* tests without being a path dependency:
|
|
2702
|
-
*
|
|
3227
|
+
* features across every package it compiles, so a sibling manifest can change a
|
|
3228
|
+
* crate's tests without being a path dependency: a member's, and a path package's
|
|
3229
|
+
* that reaches the build only as another crate's dev-dependency. Track those
|
|
3230
|
+
* manifests, not unrelated sibling sources.
|
|
2703
3231
|
*
|
|
2704
3232
|
* The repository's own nextest config layers OVER the plugin's tool config, so it
|
|
2705
3233
|
* decides timeouts, groups and archive contents: a cached verdict that ignored it
|
|
@@ -2718,16 +3246,40 @@ async function cargoTestRunnerInputs(
|
|
|
2718
3246
|
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2719
3247
|
memberDir,
|
|
2720
3248
|
cache: workspace.inputsCache,
|
|
3249
|
+
cargo: workspace.closureSource.cargo,
|
|
2721
3250
|
}),
|
|
2722
3251
|
),
|
|
2723
3252
|
);
|
|
3253
|
+
// The archive unifies every built package's manifest into every test binary, and a runner's key does not follow the
|
|
3254
|
+
// archive's outputs, so each runner names them all: the ones Nx holds as files, the rest through the repository's
|
|
3255
|
+
// runtime hash of external sources.
|
|
3256
|
+
const manifests: string[] = [];
|
|
3257
|
+
const external = new Map<string, string>();
|
|
3258
|
+
for (const pkg of workspace.closureSource.cargo.local) {
|
|
3259
|
+
const manifest = relative(workspace.closureSource.root, pkg.manifest);
|
|
3260
|
+
if (manifest === '..' || manifest.startsWith(`..${sep}`) || isAbsolute(manifest)) {
|
|
3261
|
+
external.set(pkg.name, pkg.directory);
|
|
3262
|
+
} else {
|
|
3263
|
+
manifests.push(posix.join('{workspaceRoot}', manifest.split(sep).join('/')));
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
if (external.size > 0) {
|
|
3267
|
+
requireExternalRustCratesInput(workspaceRoot, posix.join(workspace.projectRoot, 'Cargo.toml'), external);
|
|
3268
|
+
}
|
|
2724
3269
|
return [
|
|
2725
3270
|
...new Set([
|
|
2726
3271
|
...sources.flat(),
|
|
2727
|
-
...
|
|
3272
|
+
...manifests,
|
|
3273
|
+
...(external.size > 0 ? [EXTERNAL_RUST_CRATES_INPUT] : []),
|
|
2728
3274
|
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2729
3275
|
]),
|
|
2730
3276
|
fileHashInput(PLUGIN_NEXTEST_CONFIG_PATH),
|
|
3277
|
+
// The Cargo.lock entries each selected crate's closure reaches.
|
|
3278
|
+
{
|
|
3279
|
+
externalDependencies: [
|
|
3280
|
+
...new Set(memberDirs.map((memberDir) => cargoLockNodeName(posix.join(workspace.projectRoot, memberDir)))),
|
|
3281
|
+
],
|
|
3282
|
+
},
|
|
2731
3283
|
];
|
|
2732
3284
|
}
|
|
2733
3285
|
|
|
@@ -2736,16 +3288,21 @@ async function cargoTestRunnerInputs(
|
|
|
2736
3288
|
* workspace builds its command here, so the extraction, reuse-build, tool config and cwd cannot
|
|
2737
3289
|
* drift between the per-crate pieces and the serial groups.
|
|
2738
3290
|
*/
|
|
2739
|
-
function nextestRunnerCommand(
|
|
3291
|
+
function nextestRunnerCommand(
|
|
3292
|
+
workspace: CargoWorkspace,
|
|
3293
|
+
nativeTools: NativeTools | null,
|
|
3294
|
+
selector: string,
|
|
3295
|
+
flags: string,
|
|
3296
|
+
): string {
|
|
2740
3297
|
const toolConfig = nextestToolConfigArg(workspace.projectRoot);
|
|
2741
3298
|
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2742
|
-
const
|
|
3299
|
+
const extract = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', 'smoo-nx-nextest-extract');
|
|
2743
3300
|
const reuseExtraction =
|
|
2744
3301
|
`--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2745
3302
|
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2746
3303
|
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2747
3304
|
return (
|
|
2748
|
-
`extracted="$(
|
|
3305
|
+
`extracted="$(${extract} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2749
3306
|
cargoFrozen(
|
|
2750
3307
|
`nextest run ${reuseExtraction} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`,
|
|
2751
3308
|
)
|
|
@@ -2755,6 +3312,7 @@ function nextestRunnerCommand(workspace: CargoWorkspace, selector: string, flags
|
|
|
2755
3312
|
/** One per-crate piece: a bounded run of its partition of the archive's tests. */
|
|
2756
3313
|
function cargoTestRunnerTarget(
|
|
2757
3314
|
workspace: CargoWorkspace,
|
|
3315
|
+
nativeTools: NativeTools | null,
|
|
2758
3316
|
archive: CargoTargetDependency,
|
|
2759
3317
|
inputs: NonNullable<TargetConfiguration['inputs']>,
|
|
2760
3318
|
piece: CargoTestPiece,
|
|
@@ -2763,9 +3321,14 @@ function cargoTestRunnerTarget(
|
|
|
2763
3321
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2764
3322
|
cache: true,
|
|
2765
3323
|
inputs,
|
|
2766
|
-
dependsOn: [archive],
|
|
3324
|
+
dependsOn: [archive, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
2767
3325
|
options: {
|
|
2768
|
-
command: nextestRunnerCommand(
|
|
3326
|
+
command: nextestRunnerCommand(
|
|
3327
|
+
workspace,
|
|
3328
|
+
nativeTools,
|
|
3329
|
+
piece.selector,
|
|
3330
|
+
`${piece.extra} --no-fail-fast --no-tests=pass`,
|
|
3331
|
+
),
|
|
2769
3332
|
cwd: workspace.projectRoot,
|
|
2770
3333
|
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2771
3334
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
@@ -2783,6 +3346,7 @@ function cargoTestRunnerTarget(
|
|
|
2783
3346
|
*/
|
|
2784
3347
|
function cargoTestGroupTarget(
|
|
2785
3348
|
workspace: CargoWorkspace,
|
|
3349
|
+
nativeTools: NativeTools | null,
|
|
2786
3350
|
inputs: NonNullable<TargetConfiguration['inputs']>,
|
|
2787
3351
|
group: SerialTestGroup,
|
|
2788
3352
|
): TargetConfiguration {
|
|
@@ -2790,9 +3354,9 @@ function cargoTestGroupTarget(
|
|
|
2790
3354
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2791
3355
|
cache: true,
|
|
2792
3356
|
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
|
|
2793
|
-
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
3357
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
2794
3358
|
options: {
|
|
2795
|
-
command: nextestRunnerCommand(workspace, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
3359
|
+
command: nextestRunnerCommand(workspace, nativeTools, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
2796
3360
|
cwd: workspace.projectRoot,
|
|
2797
3361
|
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2798
3362
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|