@smoothbricks/nx-plugin 0.5.6 → 0.6.0
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 +1095 -360
- package/dist/.build-inputs.json +138 -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 +13 -5
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +126 -47
- 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/all-verdicts/executor.d.ts +35 -0
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -0
- package/dist/executors/all-verdicts/executor.js +133 -0
- package/dist/executors/all-verdicts/schema.d.ts +10 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -0
- package/dist/executors/all-verdicts/schema.js +2 -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.d.ts +33 -36
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +54 -119
- 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 +371 -239
- package/dist/executors/bounded-exec/gateway-lease.d.ts +22 -19
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +81 -28
- 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 +43 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -0
- package/dist/executors/bounded-exec/lease-wait.js +68 -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/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 +4 -4
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +20 -30
- 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 +40 -11
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +88 -19
- 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/executor.d.ts +3 -1
- package/dist/executors/typescript-emit/executor.d.ts.map +1 -1
- package/dist/executors/typescript-emit/executor.js +164 -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 +676 -215
- 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/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 +75 -48
- 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 +21 -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 +77 -13
- 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 +132 -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/all-verdicts/executor.ts +164 -0
- package/src/executors/all-verdicts/schema.json +22 -0
- package/src/executors/all-verdicts/schema.ts +10 -0
- package/src/executors/bounded-exec/bounds.ts +76 -0
- package/src/executors/bounded-exec/cpu-pool.ts +51 -117
- package/src/executors/bounded-exec/executor.ts +423 -259
- package/src/executors/bounded-exec/gateway-lease.ts +82 -33
- package/src/executors/bounded-exec/hang-diagnostics.ts +173 -31
- package/src/executors/bounded-exec/lease-wait.ts +89 -0
- package/src/executors/bounded-exec/lock-wait.ts +141 -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 +22 -30
- 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 +137 -34
- 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/executor.ts +205 -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 +792 -225
- 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/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 +68 -45
- 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 +123 -98
- 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/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 -3319
- 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/dist/index.js
CHANGED
|
@@ -3,33 +3,41 @@ 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
|
+
import { EXTRACTED_BINARIES_METADATA, EXTRACTED_CARGO_METADATA, EXTRACTED_TARGET_DIR, NEXTEST_ARCHIVE_KEY_SUFFIX, } from '@smoothbricks/nextest-extract';
|
|
6
7
|
import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
7
8
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
8
9
|
import { parse as parseToml } from 'smol-toml';
|
|
9
10
|
import { parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
10
11
|
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { refuseOverlappingOutputs } from './build-state-output-policy.js';
|
|
13
|
+
import { bunLockDependencies, bunLockInput, bunLockNode } from './bun-lock-scope.js';
|
|
14
|
+
import { CARGO_CLOSURE_INPUT, CARGO_LOCK_NODE_PREFIX, cargoClosureInputs, cargoLockNode, cargoLockNodeName, indexedCargoManifests, isCargoLockInput, resolveCargoClosureSource, } from './cargo-closure-input.js';
|
|
15
|
+
import { CARGO_PRODUCER_METADATA, postTasksExecution as postCargoRetention } from './cargo-retention-hook.js';
|
|
16
|
+
import { CARGO_TOOLCHAIN_NAMED_INPUT, cargoRuntimeInput, cargoToolchainInputs } from './cargo-toolchain-policy.js';
|
|
17
|
+
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, EXTERNAL_RUST_CRATES_INPUT, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, requireExternalRustCratesInput, serialTestGroups, } from './cargo-workspace.js';
|
|
14
18
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, runsFrozenCargo, } from './cross-check-policy.js';
|
|
19
|
+
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
20
|
+
import { ALL_VERDICTS_EXECUTOR } from './executors/all-verdicts/schema.js';
|
|
15
21
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
22
|
+
import { ffiPathProblem } from './executors/scriptc-native/ffi-paths.js';
|
|
16
23
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
17
|
-
import {
|
|
24
|
+
import { NEXTEST_TIMINGS_PATH, namedTestsFilter, readNextestTimings, timedShardMembers } from './nextest-timings.js';
|
|
18
25
|
import { postTasksExecution as postProducerReceipts, preTasksExecution as preProducerReceipts, } from './producer-receipts.js';
|
|
19
26
|
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
20
27
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
28
|
+
import { inferredTaskKind, refuseBuildTestDependencies } from './task-graph-policy.js';
|
|
21
29
|
import { postTasksExecution as postTaskResults, preTasksExecution as preTaskResults } from './task-results.js';
|
|
22
30
|
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
23
31
|
import { assertUpstreamBasePrecondition } from './test-walk-policy.js';
|
|
24
|
-
import {
|
|
32
|
+
import { nativeToolCommand, nativeToolDependsOn, resolveNativeTools } from './tool-bins.js';
|
|
33
|
+
import { isBuildOutputTargetName, isTestNamespaceTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from './workspace-config-policy.js';
|
|
25
34
|
import { globIndexedFiles } from './workspace-index.js';
|
|
26
|
-
export { CARGO_TEST_COMPILE_TARGET };
|
|
27
35
|
/** Makes a version live and proves it answers; never cached. */
|
|
28
36
|
export const DEPLOY_TARGET = 'deploy';
|
|
29
37
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
30
38
|
export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
31
|
-
/** The workspace-wide
|
|
32
|
-
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json'
|
|
39
|
+
/** The workspace-wide manifest a release rewrites: the version of every member. */
|
|
40
|
+
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json'];
|
|
33
41
|
/** Installed patch bytes and pins affect the compiler; Markdown explains them but is not loaded. */
|
|
34
42
|
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*', '!{workspaceRoot}/patches/**/*.md'];
|
|
35
43
|
/**
|
|
@@ -56,16 +64,16 @@ function typecheckCommand(args) {
|
|
|
56
64
|
return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
|
|
57
65
|
}
|
|
58
66
|
/**
|
|
59
|
-
* The
|
|
60
|
-
* check that only reads
|
|
67
|
+
* The release-rewritten root manifest hashed by field instead of by byte, for
|
|
68
|
+
* a check that only reads it.
|
|
61
69
|
*
|
|
62
70
|
* A `json` input is hashed by Nx's own hasher, so this costs no process. The
|
|
63
|
-
* lockfile
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
71
|
+
* lockfile is no file input at all: the packages it resolves reach a task as
|
|
72
|
+
* Nx's own lockfile nodes, the root manifest's through the bun root lock-scope
|
|
73
|
+
* node and the project's through its `^` input, so a release's rewrite of the
|
|
74
|
+
* lockfile's `workspaces` mirror re-keys nothing.
|
|
67
75
|
*
|
|
68
|
-
* The root manifest
|
|
76
|
+
* The root manifest drops `scripts`, `smoo` and `nx`. No lint or
|
|
69
77
|
* typecheck reads them: `scripts` are commands a developer runs, `smoo` holds
|
|
70
78
|
* the developer links whose linked bytes reach the hash only through their own
|
|
71
79
|
* inputs, and the root project's `nx` configuration is hashed as that
|
|
@@ -76,7 +84,6 @@ function typecheckCommand(args) {
|
|
|
76
84
|
*/
|
|
77
85
|
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
78
86
|
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
79
|
-
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
80
87
|
];
|
|
81
88
|
/** A path segment Nx's workspace file map never carries, so a fileset naming it hashes nothing. */
|
|
82
89
|
const NODE_MODULES_SEGMENT = /(?:^|\/)node_modules(?:\/|$)/;
|
|
@@ -178,8 +185,8 @@ function resolveTypescriptConfigExtends(specifier, fromConfigPath) {
|
|
|
178
185
|
* Nx hashes workspace files that are not in node_modules, so two ancestor
|
|
179
186
|
* kinds cannot be named — and they are not the same thing:
|
|
180
187
|
*
|
|
181
|
-
* - a dependency's config:
|
|
182
|
-
* bytes are installed, and
|
|
188
|
+
* - a dependency's config: the lockfile entry of the package that holds it
|
|
189
|
+
* decides which bytes are installed, and the task is keyed on it. Where they sit is the
|
|
183
190
|
* installer's business — bun keeps them in a global store outside the
|
|
184
191
|
* workspace entirely — so this is settled by HOW the specifier resolved,
|
|
185
192
|
* not by where it landed. A workspace member reached through its package
|
|
@@ -220,6 +227,14 @@ const VERSIONLESS_PACKAGE_INPUTS = [
|
|
|
220
227
|
'!{projectRoot}/package.json',
|
|
221
228
|
{ json: '{projectRoot}/package.json', excludeFields: ['version'] },
|
|
222
229
|
];
|
|
230
|
+
/**
|
|
231
|
+
* The root project owns the lockfiles, so its `default` fileset holds each
|
|
232
|
+
* whole, and a check keyed on it re-ran on every dependency change anywhere in
|
|
233
|
+
* the workspace. Its checks name what the lockfiles decide for it instead: the
|
|
234
|
+
* root manifest's bun lock-scope node and, for a root Cargo workspace, the
|
|
235
|
+
* Cargo nodes of its targets. No other project's fileset ever held them.
|
|
236
|
+
*/
|
|
237
|
+
const ROOT_LOCKFILE_EXCLUSIONS = ['!{projectRoot}/bun.lock', '!{projectRoot}/bun.lockb', '!{projectRoot}/Cargo.lock'];
|
|
223
238
|
/**
|
|
224
239
|
* Crate manifests, for the projects that have any.
|
|
225
240
|
*
|
|
@@ -256,8 +271,8 @@ const ESLINT_CONFIG_FILES = [
|
|
|
256
271
|
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
257
272
|
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
258
273
|
/**
|
|
259
|
-
* The
|
|
260
|
-
* per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
274
|
+
* The ESLint sources and config closure of Nx's workspace file index, listed
|
|
275
|
+
* once per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
261
276
|
*
|
|
262
277
|
* The ESLint file list is part of the lint target's command, metadata and
|
|
263
278
|
* inputs, and Nx hashes the whole target configuration into every task that
|
|
@@ -267,11 +282,21 @@ const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
|
267
282
|
* and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
|
|
268
283
|
* Drawing the list from the index makes the plugin and the hasher agree on one
|
|
269
284
|
* file set.
|
|
285
|
+
*
|
|
286
|
+
* The configs key every lint target with exactly the workspace files they
|
|
287
|
+
* load (eslint-config-closure.ts): a glob over the directory holding a
|
|
288
|
+
* config's rule modules keyed every file beside them, and one test fixture
|
|
289
|
+
* there re-keyed 44 lint targets in one land.
|
|
270
290
|
*/
|
|
271
|
-
async function
|
|
272
|
-
|
|
291
|
+
async function eslintWorkspace(workspaceRoot) {
|
|
292
|
+
const configs = ESLINT_CONFIG_FILES.filter((name) => existsSync(join(workspaceRoot, name)));
|
|
293
|
+
if (configs.length === 0)
|
|
273
294
|
return null;
|
|
274
|
-
|
|
295
|
+
const indexed = new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB, '**/*.json']));
|
|
296
|
+
return {
|
|
297
|
+
sources: new Set([...indexed].filter((path) => !path.endsWith('.json'))),
|
|
298
|
+
configImports: eslintConfigClosure(workspaceRoot, configs, indexed),
|
|
299
|
+
};
|
|
275
300
|
}
|
|
276
301
|
/**
|
|
277
302
|
* Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
|
|
@@ -284,7 +309,7 @@ function readTestTsConfig(testConfig) {
|
|
|
284
309
|
const readResult = readConfigFile(testConfig, typescriptSys.readFile);
|
|
285
310
|
return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
|
|
286
311
|
}
|
|
287
|
-
function projectLintCommands(projectRoot, workspaceRoot,
|
|
312
|
+
function projectLintCommands(projectRoot, workspaceRoot, eslint) {
|
|
288
313
|
const commands = [];
|
|
289
314
|
const inputs = [];
|
|
290
315
|
let eslintFileSet = null;
|
|
@@ -293,10 +318,10 @@ function projectLintCommands(projectRoot, workspaceRoot, eslintSources) {
|
|
|
293
318
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
294
319
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
295
320
|
}
|
|
296
|
-
if (
|
|
321
|
+
if (eslint !== null) {
|
|
297
322
|
const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
|
|
298
323
|
const sourceFiles = new Set();
|
|
299
|
-
for (const path of
|
|
324
|
+
for (const path of eslint.sources) {
|
|
300
325
|
if (path.startsWith(sourcePrefix) &&
|
|
301
326
|
!path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)) {
|
|
302
327
|
sourceFiles.add(path);
|
|
@@ -320,7 +345,7 @@ function projectLintCommands(projectRoot, workspaceRoot, eslintSources) {
|
|
|
320
345
|
}
|
|
321
346
|
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
322
347
|
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
323
|
-
if (!
|
|
348
|
+
if (!eslint.sources.has(path) || path.split('/').some(isNonSourceDirectory))
|
|
324
349
|
continue;
|
|
325
350
|
sourceFiles.add(path);
|
|
326
351
|
inputs.push(`{workspaceRoot}/${path}`);
|
|
@@ -334,6 +359,11 @@ function projectLintCommands(projectRoot, workspaceRoot, eslintSources) {
|
|
|
334
359
|
}
|
|
335
360
|
return { commands, inputs: [...new Set(inputs)], eslintFileSet };
|
|
336
361
|
}
|
|
362
|
+
/** A host's directory under a package's `dist/bin`, as `@smoothbricks/cowshed`'s launcher names it. */
|
|
363
|
+
const EXECUTABLE_PLATFORM_DIRECTORY = {
|
|
364
|
+
linux: { arm64: 'linux-arm64', x64: 'linux-x64' },
|
|
365
|
+
macos: { arm64: 'darwin-arm64', x64: 'darwin-x64' },
|
|
366
|
+
};
|
|
337
367
|
function napiPlatform(platform, architecture) {
|
|
338
368
|
const targetFamily = platform === 'darwin' ? 'macos' : platform === 'linux' ? 'linux' : null;
|
|
339
369
|
const targetArchitecture = architecture === 'arm64' ? 'arm64' : architecture === 'x64' ? 'x64' : null;
|
|
@@ -379,7 +409,6 @@ const CARGO_WORKSPACE_PATTERN = /^\s*\[workspace\]/m;
|
|
|
379
409
|
const CARGO_INPUTS = [
|
|
380
410
|
'{projectRoot}/**/*.rs',
|
|
381
411
|
'{projectRoot}/**/Cargo.toml',
|
|
382
|
-
'{projectRoot}/**/Cargo.lock',
|
|
383
412
|
'{projectRoot}/**/.cargo/config.toml',
|
|
384
413
|
// Shell scripts a `.cargo/config.toml` points at — linker, runner, and rustc wrappers — decide
|
|
385
414
|
// what the compiler produces as surely as the config naming them does. Tracking the config
|
|
@@ -394,14 +423,27 @@ const CARGO_INPUTS = [
|
|
|
394
423
|
// step runs before the build), so every publish recompiled every native
|
|
395
424
|
// binary on every platform for a change to a version string. What the N-API
|
|
396
425
|
// build really reads is the package's `napi` block (binary name, targets) and
|
|
397
|
-
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
|
|
426
|
+
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs(). The
|
|
427
|
+
// locked crates are each cached cargo target's lock-scope node (below).
|
|
398
428
|
const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
|
|
429
|
+
/** The lockfiles of crates no resolved Cargo workspace claims, which have no lock-scope node. */
|
|
430
|
+
const UNRESOLVED_CARGO_LOCK_INPUT = '{projectRoot}/**/Cargo.lock';
|
|
431
|
+
/**
|
|
432
|
+
* What the uncached `cargo-fetch` reads: the manifests and the lock that name the crates, and the Cargo configuration
|
|
433
|
+
* that says where they come from. They key nothing; they are what a producer receipt binds the fetch to. Unnamed, Nx
|
|
434
|
+
* plans every file of the project, which for a repository-root project includes its symlinked managed files, and a
|
|
435
|
+
* receipt binds no symlink. That workspace's members belong to other projects, so its globs start at the repository root.
|
|
436
|
+
*/
|
|
437
|
+
function cargoFetchInputs(projectRoot) {
|
|
438
|
+
const base = projectRoot === '.' ? '{workspaceRoot}' : '{projectRoot}';
|
|
439
|
+
return [`${base}/**/Cargo.toml`, `${base}/**/Cargo.lock`, `${base}/**/.cargo/config.toml`, `!${base}/**/target/**`];
|
|
440
|
+
}
|
|
399
441
|
/** A full cargo-mutants sweep's wall-clock backstop: a sweep takes hours, and a hung one must still end. */
|
|
400
442
|
const MUTATION_TIMEOUT_MS = 6 * 60 * 60 * 1000;
|
|
401
443
|
// The toolchain half of a cargo task's identity lives in its own module
|
|
402
|
-
// because `smoo monorepo validate` reads the same
|
|
403
|
-
// declaration that drops
|
|
404
|
-
// declared pin and not the ambient environment.
|
|
444
|
+
// because `smoo monorepo validate` reads the same entries to refuse a
|
|
445
|
+
// declaration that drops any of them. See cargo-toolchain-policy.ts for why it
|
|
446
|
+
// is the declared pin and the shell's declared programs, not the ambient environment.
|
|
405
447
|
/** A runtime input that changes when the file's bytes do: the runtime hashes the file itself. */
|
|
406
448
|
function fileHashInput(path) {
|
|
407
449
|
return runtimeInput(`bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' ${shellWord(path)}`);
|
|
@@ -433,14 +475,14 @@ function targetCommandText(target) {
|
|
|
433
475
|
].join('\n');
|
|
434
476
|
}
|
|
435
477
|
/**
|
|
436
|
-
* The N-API build's inputs beyond the Cargo sources: the toolchain
|
|
437
|
-
* package's `napi` block, which names the binary and the targets, and the
|
|
478
|
+
* The N-API build's inputs beyond the Cargo sources: the toolchain identity,
|
|
479
|
+
* the package's `napi` block, which names the binary and the targets, and the
|
|
438
480
|
* resolved version of the npm package that drives the build (the napi CLI on
|
|
439
481
|
* macOS; none on Linux, where devenv's zig and cargo-zigbuild are covered by
|
|
440
|
-
* the
|
|
482
|
+
* the identity). Neither the package version nor any other lockfile entry is part
|
|
441
483
|
* of the artifact.
|
|
442
484
|
*
|
|
443
|
-
* The
|
|
485
|
+
* The identity is stated here rather than inherited: neither `napi build` nor the
|
|
444
486
|
* `cargo-zigbuild` executor spells `cargo --frozen`, which is how every other
|
|
445
487
|
* cached cargo target acquires its toolchain identity. Without it a `.node`
|
|
446
488
|
* linked against one toolchain hashed equal to the same sources linked against
|
|
@@ -454,7 +496,7 @@ function napiInputs(projectRoot, repoRooted, externalDependencies) {
|
|
|
454
496
|
CARGO_CLOSURE_INPUT,
|
|
455
497
|
'{projectRoot}/scripts/*.sh',
|
|
456
498
|
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
457
|
-
...
|
|
499
|
+
...cargoToolchainInputs(),
|
|
458
500
|
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
459
501
|
{ externalDependencies: [...externalDependencies] },
|
|
460
502
|
];
|
|
@@ -492,6 +534,25 @@ const LINUX_GLIBC_FLOOR = '2.17';
|
|
|
492
534
|
const CARGO_PROFILE_FLAG = { dev: '', release: ' --release' };
|
|
493
535
|
/** The directory under `target/<triple>/` each profile writes. */
|
|
494
536
|
const CARGO_PROFILE_OUTPUT_DIR = { dev: 'debug', release: 'release' };
|
|
537
|
+
/**
|
|
538
|
+
* Where a build that ships writes, per profile. Two directories, never one: Nx restores a task's outputs as a tree, so
|
|
539
|
+
* a dev and a release build that share a path replace each other's restore and neither is a cache hit again. A release
|
|
540
|
+
* build writes where its package ships it (`dist/`, which publishes wholesale); a dev build writes under `.cache/`,
|
|
541
|
+
* which no package publishes and no loader mistakes for a release artifact.
|
|
542
|
+
*
|
|
543
|
+
* The target states each profile's directory once, as its `outputDir` option. Its declared output reads that as
|
|
544
|
+
* `{options.outputDir}` (Nx resolves it against the options of the run's configuration) and its command as
|
|
545
|
+
* `{args.outputDir}` (`nx:run-commands` fills it from the same option), so neither holds a copy that could drift.
|
|
546
|
+
*/
|
|
547
|
+
const OUTPUT_DIR_OPTION = '{options.outputDir}';
|
|
548
|
+
const OUTPUT_DIR_ARGUMENT = '{args.outputDir}';
|
|
549
|
+
/** Dev builds of N-API addons (one subdirectory per platform, beside `host`) and of wasm-bindgen's modules. */
|
|
550
|
+
const NATIVE_DEV_DIRECTORY = '.cache/native-dev';
|
|
551
|
+
const WASM_DEV_DIRECTORY = '.cache/wasm-dev';
|
|
552
|
+
/** An addon's directory per profile: `dist/native/<name>` ships, `.cache/native-dev/<name>` is for local builds. */
|
|
553
|
+
function nativeOutputPaths(name) {
|
|
554
|
+
return { dev: `${NATIVE_DEV_DIRECTORY}/${name}`, release: `dist/native/${name}` };
|
|
555
|
+
}
|
|
495
556
|
/**
|
|
496
557
|
* Cargo's default target directory for a crate, relative to the command's cwd:
|
|
497
558
|
* `target/` beside the workspace root that owns the crate, or beside the
|
|
@@ -508,7 +569,7 @@ function cargoWasmTargetDirectory(projectRoot, config, repoRooted, cargoWorkspac
|
|
|
508
569
|
return posix.relative(cwd, posix.join(owner, 'target'));
|
|
509
570
|
}
|
|
510
571
|
function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirectory) {
|
|
511
|
-
const outputDirectory = repoRooted ? posix.join(projectRoot,
|
|
572
|
+
const outputDirectory = repoRooted ? posix.join(projectRoot, OUTPUT_DIR_ARGUMENT) : OUTPUT_DIR_ARGUMENT;
|
|
512
573
|
const cargoSelection = repoRooted ? `-p ${config.cargoPackage}` : `--manifest-path ${config.manifestPath}`;
|
|
513
574
|
const buildCommand = (profile) => sequence([
|
|
514
575
|
cargoFrozen(`build${CARGO_PROFILE_FLAG[profile]} --target wasm32-unknown-unknown ${cargoSelection}`),
|
|
@@ -517,55 +578,20 @@ function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirec
|
|
|
517
578
|
]);
|
|
518
579
|
return {
|
|
519
580
|
executor: 'nx:run-commands',
|
|
581
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
520
582
|
cache: true,
|
|
521
583
|
dependsOn: ['^build'],
|
|
522
584
|
inputs: repoRooted
|
|
523
585
|
? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
|
|
524
586
|
: CARGO_OUTPUT_INPUTS,
|
|
525
|
-
outputs: [`{projectRoot}/${
|
|
587
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
526
588
|
options: {
|
|
527
589
|
command: buildCommand('dev'),
|
|
528
590
|
cwd: repoRooted ? '.' : projectRoot,
|
|
591
|
+
outputDir: WASM_DEV_DIRECTORY,
|
|
529
592
|
},
|
|
530
|
-
configurations: {
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Compilation is excluded from the bounded test window: a cold Cargo
|
|
535
|
-
* workspace can take many minutes to compile while still making progress,
|
|
536
|
-
* which is not a property of the tests. `cargo test --no-run` pays that cost
|
|
537
|
-
* in its own unbounded target. Cargo reuses incremental compilation locally;
|
|
538
|
-
* Nx cannot cache this warming action without restoring shared mutable state.
|
|
539
|
-
*
|
|
540
|
-
* Cargo flocks one `target/` per invocation and owns that lock: a second cargo
|
|
541
|
-
* process on the same directory waits inside cargo ("Blocking waiting for file
|
|
542
|
-
* lock"). Inference adds no edge to keep writers apart — an edge says one
|
|
543
|
-
* target consumes another's output, and none of these do. These are unbounded
|
|
544
|
-
* `nx:run-commands` targets, so a wait is not charged against a test budget.
|
|
545
|
-
*
|
|
546
|
-
* Clippy runs ONCE over the whole workspace, in that same `target/`, rather
|
|
547
|
-
* than once per crate. Clippy of a crate is a check build of its whole
|
|
548
|
-
* closure, so 49 crates meant 49 closure rebuilds and 11 GiB of target
|
|
549
|
-
* directories on one repository, and no per-crate cache hit ever repaid that.
|
|
550
|
-
* Sharing the build's directory costs nothing: cargo's own lock serializes
|
|
551
|
-
* the invocations that use it, and the host units a dev build compiled are
|
|
552
|
-
* reused instead of compiled again.
|
|
553
|
-
*
|
|
554
|
-
* Tests compile the dev profile only, so no test target carries a
|
|
555
|
-
* RELEASE_CONFIGURATION: Nx forwards a run's configuration down every
|
|
556
|
-
* `dependsOn` edge to each target that has it, and a release `build` must
|
|
557
|
-
* warm the dev test binaries the test run will use, not release ones nobody
|
|
558
|
-
* runs.
|
|
559
|
-
*/
|
|
560
|
-
function createCargoTestCompileTarget(projectRoot) {
|
|
561
|
-
return {
|
|
562
|
-
executor: 'nx:run-commands',
|
|
563
|
-
cache: false,
|
|
564
|
-
inputs: CARGO_INPUTS,
|
|
565
|
-
outputs: [],
|
|
566
|
-
options: {
|
|
567
|
-
command: cargoFrozen('test --workspace --no-run'),
|
|
568
|
-
cwd: projectRoot,
|
|
593
|
+
configurations: {
|
|
594
|
+
[RELEASE_CONFIGURATION]: { command: buildCommand('release'), outputDir: config.outputDirectory },
|
|
569
595
|
},
|
|
570
596
|
};
|
|
571
597
|
}
|
|
@@ -581,23 +607,44 @@ function createCargoTestCompileTarget(projectRoot) {
|
|
|
581
607
|
* entirely — the runners execute one extraction of it and never write cargo's
|
|
582
608
|
* `target/` build tree — which is what lets the runners fan out.
|
|
583
609
|
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
610
|
+
* It is also the step that keeps compilation out of the bounded test window: a
|
|
611
|
+
* cold workspace can take many minutes to compile while still making progress,
|
|
612
|
+
* which is not a property of the tests, and the runners start after it. It is
|
|
613
|
+
* test work, so no `build` depends on it (a build never consumes test binaries)
|
|
614
|
+
* and each target that executes them names the edge itself. There is no separate
|
|
615
|
+
* uncached `cargo test --no-run` warm-up: it compiled the same dev units a
|
|
616
|
+
* second time, queued on the same `target/` lock.
|
|
617
|
+
*
|
|
618
|
+
* Cached because it produces a VALUE: one file, not a mutable build tree Nx
|
|
619
|
+
* would have to restore. `--workspace` matches the clippy selection exactly, so
|
|
620
|
+
* both gates unify features the same way.
|
|
621
|
+
*
|
|
622
|
+
* Tests compile the dev profile only, so no test target carries a
|
|
623
|
+
* RELEASE_CONFIGURATION: Nx forwards a run's configuration down every
|
|
624
|
+
* `dependsOn` edge to each target that has it, and a release configuration
|
|
625
|
+
* must never turn the test binaries into release ones nobody runs.
|
|
587
626
|
*
|
|
588
627
|
* The directory and the archive are ONE command: nextest does not create the
|
|
589
628
|
* archive's parent, so the archive step consumes what the `mkdir` produced.
|
|
629
|
+
* The same command writes the task's hash beside the archive, the key every
|
|
630
|
+
* runner's extraction is looked up by (smoo-nx-nextest-extract), and declares it
|
|
631
|
+
* an output, so a cache hit restores the key with the archive it names.
|
|
590
632
|
*/
|
|
633
|
+
const CARGO_TEST_ARCHIVE_KEY_FILE = `${CARGO_TEST_ARCHIVE_FILE}${NEXTEST_ARCHIVE_KEY_SUFFIX}`;
|
|
591
634
|
function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
592
635
|
return {
|
|
593
636
|
executor: 'nx:run-commands',
|
|
637
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
594
638
|
cache: true,
|
|
595
639
|
inputs: CARGO_INPUTS,
|
|
596
|
-
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`],
|
|
640
|
+
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`, `{projectRoot}/${CARGO_TEST_ARCHIVE_KEY_FILE}`],
|
|
597
641
|
options: {
|
|
598
642
|
command: sequence([
|
|
599
643
|
`mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`,
|
|
600
644
|
cargoFrozen(`nextest archive --workspace --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`),
|
|
645
|
+
// Outside Nx there is no task hash, and an archive no task names is refused here, not by every runner.
|
|
646
|
+
'test -n "$NX_TASK_HASH"',
|
|
647
|
+
`printf '%s\\n' "$NX_TASK_HASH" > ${CARGO_TEST_ARCHIVE_KEY_FILE}`,
|
|
601
648
|
]),
|
|
602
649
|
cwd: projectRoot,
|
|
603
650
|
},
|
|
@@ -633,7 +680,7 @@ function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
|
633
680
|
* target that needs no cargo: `nextest run --archive-file` extracts prebuilt
|
|
634
681
|
* binaries and never invokes cargo (measured, zero invocations).
|
|
635
682
|
*/
|
|
636
|
-
function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archiveInputs) {
|
|
683
|
+
function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archiveInputs, pluginInstalled) {
|
|
637
684
|
const { target: triple, cargo } = crossTarget;
|
|
638
685
|
const archiveFile = cargoCrossTestArchiveFile(triple);
|
|
639
686
|
const archiveCommand = sequence([
|
|
@@ -645,6 +692,7 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
645
692
|
return {
|
|
646
693
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
647
694
|
executor: archiveExecutor,
|
|
695
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
648
696
|
cache: true,
|
|
649
697
|
// The toolchain inputs every cached cargo target carries, plus the
|
|
650
698
|
// declared driver's own bytes. Those toolchain inputs are attached
|
|
@@ -659,10 +707,14 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
659
707
|
// the cross profile. For the same reason it names its npm packages here.
|
|
660
708
|
inputs: [
|
|
661
709
|
...archiveInputs,
|
|
662
|
-
...
|
|
710
|
+
...cargoToolchainInputs(),
|
|
663
711
|
...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
|
|
664
712
|
cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
|
|
665
|
-
{
|
|
713
|
+
{
|
|
714
|
+
externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand, pluginInstalled),
|
|
715
|
+
},
|
|
716
|
+
// The Cargo.lock entries the whole workspace reaches, for the same reason.
|
|
717
|
+
{ externalDependencies: [cargoLockNodeName(projectRoot)] },
|
|
666
718
|
],
|
|
667
719
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
668
720
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
@@ -697,9 +749,10 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
697
749
|
function createCargoTestTarget(projectRoot) {
|
|
698
750
|
return {
|
|
699
751
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
752
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
700
753
|
cache: true,
|
|
701
754
|
inputs: CARGO_INPUTS,
|
|
702
|
-
dependsOn: [
|
|
755
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
703
756
|
options: {
|
|
704
757
|
command: cargoFrozen('test --workspace'),
|
|
705
758
|
cwd: projectRoot,
|
|
@@ -716,13 +769,46 @@ const PLUGIN_NEXTEST_CONFIG = fileURLToPath(new URL('../nextest.toml', import.me
|
|
|
716
769
|
const PLUGIN_NEXTEST_CODE_BOUND = fileURLToPath(new URL('../src/nextest-code-bound.ts', import.meta.url));
|
|
717
770
|
const PLUGIN_PACKAGE = '@smoothbricks/nx-plugin';
|
|
718
771
|
/**
|
|
719
|
-
* Whether this plugin
|
|
720
|
-
*
|
|
721
|
-
*
|
|
772
|
+
* Whether this plugin's code was loaded from an installed npm package: a path
|
|
773
|
+
* through `node_modules`. Not enough alone to name it as an
|
|
774
|
+
* `externalDependencies` entry ({@link pluginInstalledIn}).
|
|
722
775
|
*/
|
|
723
|
-
const
|
|
776
|
+
const PLUGIN_LOADED_FROM_NODE_MODULES = fileURLToPath(new URL('..', import.meta.url))
|
|
724
777
|
.split(sep)
|
|
725
778
|
.includes('node_modules');
|
|
779
|
+
const workspaceProjectPlugins = new Map();
|
|
780
|
+
/**
|
|
781
|
+
* Whether the workspace at `workspaceRoot` runs this plugin as an installed npm package, whose lockfile node an
|
|
782
|
+
* `externalDependencies` entry can name. In the repository that develops it the plugin is a workspace project: the
|
|
783
|
+
* workspace's own `node_modules/@smoothbricks/nx-plugin` resolves to a directory of the workspace outside every
|
|
784
|
+
* `node_modules`, and Nx refuses a workspace project named as an `externalDependencies` entry ("could not be
|
|
785
|
+
* found"), whatever path this process loaded the plugin's code through. A daemon of that repository did load it
|
|
786
|
+
* through one with `node_modules` in it, and every cargo target it inferred afterwards named the plugin, so a gate
|
|
787
|
+
* refused the graph.
|
|
788
|
+
*/
|
|
789
|
+
export function pluginInstalledIn(workspaceRoot, loadedFromNodeModules = PLUGIN_LOADED_FROM_NODE_MODULES) {
|
|
790
|
+
if (!loadedFromNodeModules)
|
|
791
|
+
return false;
|
|
792
|
+
let workspaceProject = workspaceProjectPlugins.get(workspaceRoot);
|
|
793
|
+
if (workspaceProject === undefined) {
|
|
794
|
+
let linked = null;
|
|
795
|
+
try {
|
|
796
|
+
linked = relative(realpathSync(workspaceRoot), realpathSync(join(workspaceRoot, 'node_modules', PLUGIN_PACKAGE)));
|
|
797
|
+
}
|
|
798
|
+
catch {
|
|
799
|
+
// No such package in the workspace: whatever runs the plugin, it is not a project of this workspace.
|
|
800
|
+
}
|
|
801
|
+
workspaceProject =
|
|
802
|
+
linked !== null &&
|
|
803
|
+
linked !== '' &&
|
|
804
|
+
!isAbsolute(linked) &&
|
|
805
|
+
linked !== '..' &&
|
|
806
|
+
!linked.startsWith(`..${sep}`) &&
|
|
807
|
+
!linked.split(sep).includes('node_modules');
|
|
808
|
+
workspaceProjectPlugins.set(workspaceRoot, workspaceProject);
|
|
809
|
+
}
|
|
810
|
+
return !workspaceProject;
|
|
811
|
+
}
|
|
726
812
|
/**
|
|
727
813
|
* The npm packages a cached cargo target runs, for its `externalDependencies`.
|
|
728
814
|
* Cargo runs none. A target this plugin's executor runs, or whose command reads
|
|
@@ -731,7 +817,7 @@ const PLUGIN_IS_INSTALLED = fileURLToPath(new URL('..', import.meta.url))
|
|
|
731
817
|
* executor is not an `@nx/` one on every package in the lockfile, so a
|
|
732
818
|
* lockfile-only commit re-ran every cargo verdict.
|
|
733
819
|
*/
|
|
734
|
-
export function cargoCommandNpmPackages(target, commandText, installed
|
|
820
|
+
export function cargoCommandNpmPackages(target, commandText, installed) {
|
|
735
821
|
const runsPlugin = target.executor?.startsWith(`${PLUGIN_PACKAGE}:`) === true ||
|
|
736
822
|
commandText.includes(`node_modules/${PLUGIN_PACKAGE}/`);
|
|
737
823
|
return installed && runsPlugin ? [PLUGIN_PACKAGE] : [];
|
|
@@ -781,10 +867,15 @@ function createNodesHandler(hostPlatform) {
|
|
|
781
867
|
const results = [];
|
|
782
868
|
const errors = [];
|
|
783
869
|
let cargoWorkspaces;
|
|
784
|
-
let
|
|
870
|
+
let eslint;
|
|
871
|
+
let nativeTools;
|
|
785
872
|
try {
|
|
786
873
|
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
|
|
787
|
-
|
|
874
|
+
eslint = await eslintWorkspace(context.workspaceRoot);
|
|
875
|
+
nativeTools =
|
|
876
|
+
hostPlatform === null
|
|
877
|
+
? null
|
|
878
|
+
: await resolveNativeTools(context.workspaceRoot, projectConfigurationFiles, EXECUTABLE_PLATFORM_DIRECTORY[hostPlatform.targetFamily][hostPlatform.architecture], scriptcTargetName(hostPlatform));
|
|
788
879
|
}
|
|
789
880
|
catch (error) {
|
|
790
881
|
throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
|
|
@@ -804,7 +895,7 @@ function createNodesHandler(hostPlatform) {
|
|
|
804
895
|
}
|
|
805
896
|
results.push([
|
|
806
897
|
packageJsonPath,
|
|
807
|
-
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, cargoWorkspaces,
|
|
898
|
+
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, nativeTools, cargoWorkspaces, eslint, versionless),
|
|
808
899
|
]);
|
|
809
900
|
}
|
|
810
901
|
catch (error) {
|
|
@@ -838,8 +929,9 @@ function isBuildOutputPackageJson(packageJsonPath) {
|
|
|
838
929
|
* Nx accepts one pre/post task-hook pair per plugin. Two independent observers share it: the controller's task-results
|
|
839
930
|
* hint and the opt-in producer completion receipts. Each sees the same options and run context; neither reads the
|
|
840
931
|
* other's output. The hint is recorded first so a producer-receipt bug cannot cost the controller its evidence. The
|
|
841
|
-
* pair also serves a run
|
|
842
|
-
*
|
|
932
|
+
* pair also serves a run that inherits no CPU pool its own, which every task inherits (`run-cpu-pool.ts`), and closes
|
|
933
|
+
* it when the run ends. Last, once every task has finished, the post hook reclaims the
|
|
934
|
+
* superseded Cargo unit generations of each Cargo workspace the run built into (`@smoothbricks/cargo-retain`).
|
|
843
935
|
*/
|
|
844
936
|
export const preTasksExecution = async (options, context) => {
|
|
845
937
|
// Before any task is hashed: a workspace that declares the test-walk check
|
|
@@ -853,29 +945,220 @@ export const postTasksExecution = async (options, context) => {
|
|
|
853
945
|
await postTaskResults(options, context);
|
|
854
946
|
await postProducerReceipts(options, context);
|
|
855
947
|
await closeRunCpuPool(context);
|
|
948
|
+
await postCargoRetention(options, context);
|
|
856
949
|
};
|
|
857
|
-
|
|
950
|
+
/** The lock-scope nodes' edges: each bun node's to the packages and members its manifest resolves. */
|
|
951
|
+
export const createDependencies = (_options, context) => bunLockDependencies(context);
|
|
952
|
+
/** Nx invokes this only after merging inferred/declarative targets and every plugin's project dependencies. */
|
|
953
|
+
export const createMetadata = (graph, _options, context) => {
|
|
954
|
+
refuseOverlappingOutputs(graph, context.workspaceRoot);
|
|
955
|
+
refuseBuildTestDependencies(graph, context.workspaceRoot);
|
|
956
|
+
return {};
|
|
957
|
+
};
|
|
958
|
+
export default { createNodesV2, createDependencies, createMetadata, postTasksExecution, preTasksExecution };
|
|
858
959
|
function packageBinOutputs(packageJson, packageJsonPath) {
|
|
960
|
+
return [...new Set(packageBinEntries(packageJson, packageJsonPath).values())];
|
|
961
|
+
}
|
|
962
|
+
/** `package.json#bin` as npm links it: each command's name and executable path; a lone path is the unscoped package's. */
|
|
963
|
+
function packageBinEntries(packageJson, packageJsonPath) {
|
|
859
964
|
if (packageJson.bin === undefined) {
|
|
860
|
-
return
|
|
965
|
+
return new Map();
|
|
861
966
|
}
|
|
862
967
|
if (typeof packageJson.bin === 'string') {
|
|
863
968
|
if (packageJson.bin.length === 0) {
|
|
864
969
|
throw new Error(`${packageJsonPath}: bin must not be empty`);
|
|
865
970
|
}
|
|
866
|
-
return [packageJson.bin];
|
|
971
|
+
return new Map([[(packageJson.name ?? '').replace(/^@[^/]*\//, ''), packageJson.bin]]);
|
|
867
972
|
}
|
|
868
973
|
if (!isRecord(packageJson.bin)) {
|
|
869
974
|
throw new Error(`${packageJsonPath}: bin must be a string or an object of executable paths`);
|
|
870
975
|
}
|
|
871
|
-
const
|
|
976
|
+
const entries = new Map();
|
|
872
977
|
for (const [name, output] of Object.entries(packageJson.bin)) {
|
|
873
978
|
if (typeof output !== 'string' || output.length === 0) {
|
|
874
979
|
throw new Error(`${packageJsonPath}: bin.${name} must be a non-empty executable path`);
|
|
875
980
|
}
|
|
876
|
-
|
|
981
|
+
entries.set(name, output);
|
|
982
|
+
}
|
|
983
|
+
return entries;
|
|
984
|
+
}
|
|
985
|
+
/** Resolve declared bins and optional package-root-relative native overrides to emit-root-relative modules. */
|
|
986
|
+
export function scriptcBinModules(bins, scriptc, packageJsonPath, javascriptRoot) {
|
|
987
|
+
const modulePath = (name, entry, field) => {
|
|
988
|
+
const emitted = posix.normalize(entry);
|
|
989
|
+
if (!/^[\w.-]+$/.test(name) || !emitted.startsWith(`${javascriptRoot}/`) || !emitted.endsWith('.js')) {
|
|
990
|
+
throw new Error(`${packageJsonPath}: ${field} must name JavaScript tsc-js emits under ${javascriptRoot}/ (it is ${entry})`);
|
|
991
|
+
}
|
|
992
|
+
return emitted.slice(javascriptRoot.length + 1);
|
|
993
|
+
};
|
|
994
|
+
const modules = Object.fromEntries(bins);
|
|
995
|
+
for (const [name, entry] of bins) {
|
|
996
|
+
modules[name] = modulePath(name, entry, `bin.${name}`);
|
|
997
|
+
}
|
|
998
|
+
if (scriptc === undefined)
|
|
999
|
+
return modules;
|
|
1000
|
+
if (!isRecord(scriptc) || Array.isArray(scriptc)) {
|
|
1001
|
+
throw new Error(`${packageJsonPath}: scriptc must be an object`);
|
|
1002
|
+
}
|
|
1003
|
+
const overrides = scriptc.entries;
|
|
1004
|
+
if (overrides === undefined)
|
|
1005
|
+
return modules;
|
|
1006
|
+
if (!isRecord(overrides) || Array.isArray(overrides)) {
|
|
1007
|
+
throw new Error(`${packageJsonPath}: scriptc.entries must be an object mapping declared bin names to module paths`);
|
|
1008
|
+
}
|
|
1009
|
+
for (const [name, entry] of Object.entries(overrides)) {
|
|
1010
|
+
if (!bins.has(name)) {
|
|
1011
|
+
throw new Error(`${packageJsonPath}: scriptc.entries.${name} is not declared in bin; entries cannot add executables`);
|
|
1012
|
+
}
|
|
1013
|
+
if (typeof entry !== 'string' || entry.length === 0) {
|
|
1014
|
+
throw new Error(`${packageJsonPath}: scriptc.entries.${name} must be a non-empty module path`);
|
|
1015
|
+
}
|
|
1016
|
+
modules[name] = modulePath(name, entry, `scriptc.entries.${name}`);
|
|
877
1017
|
}
|
|
878
|
-
return
|
|
1018
|
+
return modules;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Every platform a scriptc package ships an executable for, with the triple `SCRIPTC_TARGET` names for it and the
|
|
1022
|
+
* runtime pack scriptc links that triple against. Linux executables are static musl, as cowshed's CLI is, so one file
|
|
1023
|
+
* runs on every distribution.
|
|
1024
|
+
*/
|
|
1025
|
+
const SCRIPTC_PLATFORMS = [
|
|
1026
|
+
{
|
|
1027
|
+
architecture: 'arm64',
|
|
1028
|
+
targetFamily: 'macos',
|
|
1029
|
+
triple: 'aarch64-macos',
|
|
1030
|
+
runtimePack: '@scriptc/runtime-darwin-arm64',
|
|
1031
|
+
},
|
|
1032
|
+
{ architecture: 'x64', targetFamily: 'macos', triple: 'x86_64-macos', runtimePack: '@scriptc/runtime-darwin-x64' },
|
|
1033
|
+
{
|
|
1034
|
+
architecture: 'arm64',
|
|
1035
|
+
targetFamily: 'linux',
|
|
1036
|
+
triple: 'aarch64-linux-musl',
|
|
1037
|
+
runtimePack: '@scriptc/runtime-linux-arm64-musl',
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
architecture: 'x64',
|
|
1041
|
+
targetFamily: 'linux',
|
|
1042
|
+
triple: 'x86_64-linux-musl',
|
|
1043
|
+
runtimePack: '@scriptc/runtime-linux-x64-musl',
|
|
1044
|
+
},
|
|
1045
|
+
];
|
|
1046
|
+
/**
|
|
1047
|
+
* `package.json#scriptc.ffi`: the C a package's executables call through scriptc's FFI, which every platform run stages
|
|
1048
|
+
* beside the emitted JavaScript and builds for its triple. Absent for a package that calls no C.
|
|
1049
|
+
*/
|
|
1050
|
+
function scriptcFfi(packageJson, packageJsonPath) {
|
|
1051
|
+
if (packageJson.scriptc === undefined || (isRecord(packageJson.scriptc) && packageJson.scriptc.ffi === undefined)) {
|
|
1052
|
+
return undefined;
|
|
1053
|
+
}
|
|
1054
|
+
const refusal = (what) => new Error(`${packageJsonPath}: scriptc.ffi ${what}; it is { "manifest": "<ffi.json>", "declarations": ` +
|
|
1055
|
+
'{ "<source .d.ts>": "<path beside the emitted JavaScript>" }, "sources": ["<C file>"] }');
|
|
1056
|
+
const ffi = isRecord(packageJson.scriptc) ? packageJson.scriptc.ffi : undefined;
|
|
1057
|
+
if (!isRecord(ffi)) {
|
|
1058
|
+
throw refusal('must be an object');
|
|
1059
|
+
}
|
|
1060
|
+
const { manifest, declarations, sources } = ffi;
|
|
1061
|
+
if (typeof manifest !== 'string' || manifest.length === 0) {
|
|
1062
|
+
throw refusal('needs a manifest path');
|
|
1063
|
+
}
|
|
1064
|
+
if (!isRecord(declarations)) {
|
|
1065
|
+
throw refusal('needs declarations mapping each source file to its staged path');
|
|
1066
|
+
}
|
|
1067
|
+
const staged = {};
|
|
1068
|
+
for (const [source, destination] of Object.entries(declarations)) {
|
|
1069
|
+
if (typeof destination !== 'string') {
|
|
1070
|
+
throw refusal(`needs declarations mapping each source file to its staged path (${source} is not)`);
|
|
1071
|
+
}
|
|
1072
|
+
staged[source] = destination;
|
|
1073
|
+
}
|
|
1074
|
+
if (!Array.isArray(sources)) {
|
|
1075
|
+
throw refusal('needs sources, a list of C files');
|
|
1076
|
+
}
|
|
1077
|
+
const files = [];
|
|
1078
|
+
for (const source of sources) {
|
|
1079
|
+
if (typeof source !== 'string') {
|
|
1080
|
+
throw refusal('needs sources, a list of C files');
|
|
1081
|
+
}
|
|
1082
|
+
files.push(source);
|
|
1083
|
+
}
|
|
1084
|
+
const declared = { manifest, declarations: staged, sources: files };
|
|
1085
|
+
const problem = ffiPathProblem(declared);
|
|
1086
|
+
if (problem !== undefined) {
|
|
1087
|
+
throw refusal(problem);
|
|
1088
|
+
}
|
|
1089
|
+
return declared;
|
|
1090
|
+
}
|
|
1091
|
+
/** The files a target's FFI is built from: change one and every platform's executable is stale. */
|
|
1092
|
+
function scriptcFfiInputs(ffi) {
|
|
1093
|
+
return ffi === undefined
|
|
1094
|
+
? []
|
|
1095
|
+
: [ffi.manifest, ...Object.keys(ffi.declarations), ...ffi.sources].map((path) => `{projectRoot}/${path}`);
|
|
1096
|
+
}
|
|
1097
|
+
/** The scriptc target writing `platform`'s executables; its suffix is the platform family the publish legs select. */
|
|
1098
|
+
function scriptcTargetName(platform) {
|
|
1099
|
+
return `scriptc-${platform.architecture}-${platform.targetFamily}`;
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* `scriptc-<arch>-<family>`, one per platform in SCRIPTC_PLATFORMS: each `package.json#bin` entry compiled by scriptc
|
|
1103
|
+
* to the executable `dist/bin/<platform>/<name>`, from the transformed JavaScript the run itself emits from
|
|
1104
|
+
* `tsconfig.lib.json` into private staging, never from `tsc-js`'s output: a platform target's closure stays in its
|
|
1105
|
+
* family (package-target-policy.ts) and the four are collected on different hosts, so none depends on a sibling or
|
|
1106
|
+
* shares an output with another. A package opts in by depending on `scriptc`, which also pins the compiler the targets
|
|
1107
|
+
* run, and lists each platform's runtime pack at that same version. Every host builds every platform the same way,
|
|
1108
|
+
* `SCRIPTC_TARGET=<triple>` with zig as the C compiler, so a target's output does not depend on the host that built
|
|
1109
|
+
* it, and like every platform target the host's own joins `build` while the publish legs build the rest. The bins
|
|
1110
|
+
* name JavaScript below `dist/` beside `bin/` (`dist/ts`), so `tsc-js`'s output and the executables are disjoint.
|
|
1111
|
+
*/
|
|
1112
|
+
function scriptcPlatformTargets(packageJson, packageJsonPath, projectRoot, libTsconfigPath, toolchainInputs) {
|
|
1113
|
+
const compiler = packageJson.devDependencies?.scriptc;
|
|
1114
|
+
if (compiler === undefined) {
|
|
1115
|
+
return {};
|
|
1116
|
+
}
|
|
1117
|
+
const missingPacks = SCRIPTC_PLATFORMS.filter((platform) => packageJson.devDependencies?.[platform.runtimePack] !== compiler).map((platform) => `${platform.runtimePack}@${String(compiler)}`);
|
|
1118
|
+
if (missingPacks.length > 0) {
|
|
1119
|
+
throw new Error(`${packageJsonPath}: a scriptc package builds every platform's executable, each linked against its runtime pack at ` +
|
|
1120
|
+
`the compiler's version; list ${missingPacks.join(', ')} in devDependencies beside scriptc`);
|
|
1121
|
+
}
|
|
1122
|
+
const javascriptRoot = typescriptOutDir(libTsconfigPath, packageJsonPath);
|
|
1123
|
+
const [outputRoot, below] = javascriptRoot?.split('/') ?? [];
|
|
1124
|
+
if (javascriptRoot === null || outputRoot !== 'dist' || below === undefined || below === 'bin') {
|
|
1125
|
+
throw new Error(`${packageJsonPath}: a scriptc package emits its JavaScript below dist/ beside dist/bin; ` +
|
|
1126
|
+
`set tsconfig.lib.json compilerOptions.outDir to "dist/ts" (it is ${JSON.stringify(javascriptRoot)})`);
|
|
1127
|
+
}
|
|
1128
|
+
const entries = packageBinEntries(packageJson, packageJsonPath);
|
|
1129
|
+
if (entries.size === 0) {
|
|
1130
|
+
throw new Error(`${packageJsonPath}: a scriptc package names the executables it compiles in bin`);
|
|
1131
|
+
}
|
|
1132
|
+
const modules = scriptcBinModules(entries, packageJson.scriptc, packageJsonPath, javascriptRoot);
|
|
1133
|
+
const ffi = scriptcFfi(packageJson, packageJsonPath);
|
|
1134
|
+
const targets = {};
|
|
1135
|
+
for (const platform of SCRIPTC_PLATFORMS) {
|
|
1136
|
+
const outputDirectory = `dist/bin/${EXECUTABLE_PLATFORM_DIRECTORY[platform.targetFamily][platform.architecture]}`;
|
|
1137
|
+
targets[scriptcTargetName(platform)] = {
|
|
1138
|
+
executor: '@smoothbricks/nx-plugin:scriptc-native',
|
|
1139
|
+
cache: true,
|
|
1140
|
+
inputs: [
|
|
1141
|
+
'production',
|
|
1142
|
+
'^production',
|
|
1143
|
+
...toolchainInputs,
|
|
1144
|
+
'{projectRoot}/tsconfig.lib.json',
|
|
1145
|
+
{ externalDependencies: ['scriptc', platform.runtimePack] },
|
|
1146
|
+
...scriptcFfiInputs(ffi),
|
|
1147
|
+
],
|
|
1148
|
+
outputs: [...entries.keys()].map((name) => `{projectRoot}/${outputDirectory}/${name}`),
|
|
1149
|
+
// The emit type-checks against its dependencies' emitted JavaScript, as tsc-js does.
|
|
1150
|
+
dependsOn: ['^*-js'],
|
|
1151
|
+
options: {
|
|
1152
|
+
cwd: projectRoot,
|
|
1153
|
+
tsConfig: 'tsconfig.lib.json',
|
|
1154
|
+
triple: platform.triple,
|
|
1155
|
+
outputDirectory,
|
|
1156
|
+
entries: modules,
|
|
1157
|
+
...(ffi === undefined ? {} : { ffi }),
|
|
1158
|
+
},
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
return targets;
|
|
879
1162
|
}
|
|
880
1163
|
/**
|
|
881
1164
|
* The deployment manifests wrangler itself looks for, in its own precedence
|
|
@@ -916,7 +1199,7 @@ const WRANGLER_CONFIG_FILES = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml
|
|
|
916
1199
|
* `--stage` refuses it, which is the failure we want at the boundary.
|
|
917
1200
|
*/
|
|
918
1201
|
const WRANGLER_DEPLOY_COMMAND = 'smoo wrangler deploy-stage --stage {args.stage}';
|
|
919
|
-
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, cargoWorkspaces,
|
|
1202
|
+
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, nativeTools, cargoWorkspaces, eslint, versionless) {
|
|
920
1203
|
const projectRoot = dirname(packageJsonPath);
|
|
921
1204
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
922
1205
|
const packageJson = await readPackageJson(join(workspaceRoot, packageJsonPath));
|
|
@@ -946,15 +1229,27 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
946
1229
|
// transitive half `^production`.
|
|
947
1230
|
const hasCrateManifests = isCargoProject || existsSync(cargoTomlPath);
|
|
948
1231
|
const crateInputs = versionless !== null && hasCrateManifests ? await versionlessCrateInputs(projectRoot, workspaceRoot) : [];
|
|
949
|
-
const versionlessProjectInputs = versionless === null
|
|
1232
|
+
const versionlessProjectInputs = versionless === null
|
|
1233
|
+
? []
|
|
1234
|
+
: [...VERSIONLESS_PACKAGE_INPUTS, ...crateInputs, ...(projectRoot === '.' ? ROOT_LOCKFILE_EXCLUSIONS : [])];
|
|
950
1235
|
// The options a TypeScript task's answer really depends on, which is the
|
|
951
1236
|
// whole `extends` chain of the configs its commands name and not just those
|
|
952
1237
|
// two files. Resolved once per project: every target below shares it.
|
|
953
1238
|
const typescriptConfigChain = typescriptConfigChainInputs([...(hasLibTsconfig ? [libTsconfigPath] : []), ...(hasTestTsconfig ? [testTsconfigPath] : [])], workspaceRoot);
|
|
954
|
-
const toolchainInputs = [
|
|
1239
|
+
const toolchainInputs = [
|
|
1240
|
+
...RELEASE_REWRITTEN_WORKSPACE_INPUTS,
|
|
1241
|
+
bunLockInput(projectRoot),
|
|
1242
|
+
...TYPESCRIPT_PATCH_INPUTS,
|
|
1243
|
+
...typescriptConfigChain,
|
|
1244
|
+
];
|
|
955
1245
|
const checkInputs = versionless === null
|
|
956
1246
|
? toolchainInputs
|
|
957
|
-
: [
|
|
1247
|
+
: [
|
|
1248
|
+
...TYPESCRIPT_PATCH_INPUTS,
|
|
1249
|
+
...typescriptConfigChain,
|
|
1250
|
+
...VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS,
|
|
1251
|
+
bunLockInput(projectRoot),
|
|
1252
|
+
];
|
|
958
1253
|
const selfProduction = versionless === null ? 'production' : VERSIONLESS_PRODUCTION_INPUT;
|
|
959
1254
|
const selfDefault = versionless === null ? 'default' : VERSIONLESS_DEFAULT_INPUT;
|
|
960
1255
|
const dependencyProduction = versionless?.transitive === true
|
|
@@ -1004,6 +1299,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1004
1299
|
cwd: projectRoot,
|
|
1005
1300
|
},
|
|
1006
1301
|
};
|
|
1302
|
+
Object.assign(targets, scriptcPlatformTargets(packageJson, packageJsonPath, projectRoot, libTsconfigPath, toolchainInputs));
|
|
1007
1303
|
}
|
|
1008
1304
|
if (hasTestTsconfig) {
|
|
1009
1305
|
targets['typecheck-tests'] = {
|
|
@@ -1051,7 +1347,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1051
1347
|
targets['cargo-wasm'] = createCargoWasmTarget(projectRoot, cargoWasmConfig, isRepoRootedCargoProject, cargoWasmTargetDirectory(projectRoot, cargoWasmConfig, isRepoRootedCargoProject, cargoWorkspace));
|
|
1052
1348
|
}
|
|
1053
1349
|
if (napiConfig) {
|
|
1054
|
-
Object.assign(targets, createNapiTargets(projectRoot, napiConfig, hostPlatform, isRepoRootedCargoProject));
|
|
1350
|
+
Object.assign(targets, createNapiTargets(projectRoot, napiConfig, hostPlatform, nativeTools, isRepoRootedCargoProject));
|
|
1055
1351
|
if (!('napi-test' in (packageJson.nx?.targets ?? {})) &&
|
|
1056
1352
|
existsSync(join(absoluteProjectRoot, 'src/native.test.ts'))) {
|
|
1057
1353
|
targets['napi-test'] = createNapiTestTarget(projectRoot, existsSync(join(absoluteProjectRoot, 'bunfig.napi-test.toml')));
|
|
@@ -1092,7 +1388,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1092
1388
|
// `dependsOn` REPLACES rather than unions. These lists state what each target
|
|
1093
1389
|
// consumes — the fetched registry, the archive, the debug addon — and a
|
|
1094
1390
|
// package that must re-route one (build its artifact ahead of the test run,
|
|
1095
|
-
// or drop `cargo-test-
|
|
1391
|
+
// or drop `cargo-test-archive` because it compiles differently) can only say
|
|
1096
1392
|
// so by replacing the list; a union would make every inferred edge
|
|
1097
1393
|
// unremovable and a corrected order unrepresentable.
|
|
1098
1394
|
// Additive intent already has a spelling (`"..."` above), so a plugin-local
|
|
@@ -1107,13 +1403,13 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1107
1403
|
const ownsCargoWorkspaceTargets = isCargoWorkspaceRoot;
|
|
1108
1404
|
if (ownsCargoWorkspaceTargets && cargoWorkspace) {
|
|
1109
1405
|
const cargoWorkspaceRoot = cargoWorkspace.projectRoot;
|
|
1110
|
-
targets[CARGO_TEST_COMPILE_TARGET] = createCargoTestCompileTarget(cargoWorkspaceRoot);
|
|
1111
1406
|
const workspaceInputs = [
|
|
1112
1407
|
...new Set((await Promise.all(cargoWorkspace.packages.map((plan) => cargoPackageTestInputs({
|
|
1113
1408
|
workspaceRoot,
|
|
1114
1409
|
absoluteProjectRoot: join(workspaceRoot, cargoWorkspaceRoot),
|
|
1115
1410
|
memberDir: plan.package.dir,
|
|
1116
1411
|
cache: cargoWorkspace.inputsCache,
|
|
1412
|
+
cargo: cargoWorkspace.closureSource.cargo,
|
|
1117
1413
|
})))).flat()),
|
|
1118
1414
|
];
|
|
1119
1415
|
// Generated crate sources (wire codecs, vocabularies, fixtures) are
|
|
@@ -1128,7 +1424,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1128
1424
|
...(workspaceInputs.length > 0 ? workspaceInputs : CARGO_INPUTS),
|
|
1129
1425
|
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
1130
1426
|
];
|
|
1131
|
-
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
1132
1427
|
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot));
|
|
1133
1428
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
1134
1429
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
@@ -1138,10 +1433,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1138
1433
|
// binaries whichever machine they are for, so a change that invalidates
|
|
1139
1434
|
// the host archive must invalidate every cross one.
|
|
1140
1435
|
for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
|
|
1141
|
-
Object.assign(targets, createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), crossTarget, [
|
|
1142
|
-
...workspaceCargoInputs,
|
|
1143
|
-
`{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
|
|
1144
|
-
]));
|
|
1436
|
+
Object.assign(targets, createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), crossTarget, [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`], pluginInstalledIn(workspaceRoot)));
|
|
1145
1437
|
}
|
|
1146
1438
|
// A serial group's filter can span members, so no single crate owns it. The root
|
|
1147
1439
|
// owns each group's runner beside the archive it executes, and gives it the inputs
|
|
@@ -1149,7 +1441,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1149
1441
|
// to its packages reruns only when their sources or local dependencies change,
|
|
1150
1442
|
// and an unscoped one hashes every member, as the archive itself does.
|
|
1151
1443
|
for (const group of cargoWorkspace.serialGroups) {
|
|
1152
|
-
targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(cargoWorkspace, await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)), group);
|
|
1444
|
+
targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(cargoWorkspace, nativeTools, await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)), group);
|
|
1153
1445
|
}
|
|
1154
1446
|
// Every project's crate pieces. The serial groups' runners are the gate's (`test`, below), so
|
|
1155
1447
|
// `cargo-test` is the ordinary suite alone and a run of it never reaches a group's real-image tests.
|
|
@@ -1161,15 +1453,18 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1161
1453
|
aggregateDependencies.length > 0
|
|
1162
1454
|
? { executor: 'nx:noop', cache: true, outputs: [], dependsOn: aggregateDependencies }
|
|
1163
1455
|
: createCargoTestTarget(cargoWorkspaceRoot);
|
|
1164
|
-
// One clippy over the whole workspace
|
|
1165
|
-
// of
|
|
1166
|
-
//
|
|
1167
|
-
//
|
|
1168
|
-
//
|
|
1169
|
-
//
|
|
1170
|
-
//
|
|
1456
|
+
// One clippy over the whole workspace. Clippy of a crate is a check build
|
|
1457
|
+
// of its closure; a target dir per crate compiled every shared dependency
|
|
1458
|
+
// once per crate (49 closures, 11 GiB on one repository) and no per-crate
|
|
1459
|
+
// cache hit ever repaid that. The workspace inputs are exactly the union of
|
|
1460
|
+
// every crate's, so the verdict caches on the same key set the archive
|
|
1461
|
+
// does. Non-root packages depend on this target. Its target dir is its own
|
|
1462
|
+
// (CARGO_LINT_CLIPPY_COMMAND, ./cross-check-policy.ts): Cargo flocks one
|
|
1463
|
+
// directory per invocation, and a workspace clippy holding the dev build's
|
|
1464
|
+
// `target/` queued the archive and every dev build behind it.
|
|
1171
1465
|
targets['cargo-lint'] = {
|
|
1172
1466
|
executor: 'nx:run-commands',
|
|
1467
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1173
1468
|
cache: true,
|
|
1174
1469
|
inputs: workspaceCargoInputs,
|
|
1175
1470
|
outputs: [],
|
|
@@ -1208,6 +1503,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1208
1503
|
// macOS host demand the zig toolchain that the devenv profile keeps opt-in.
|
|
1209
1504
|
targets[CARGO_CROSS_LINT_TARGET] = {
|
|
1210
1505
|
executor: 'nx:run-commands',
|
|
1506
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1211
1507
|
cache: true,
|
|
1212
1508
|
inputs: workspaceCargoInputs,
|
|
1213
1509
|
outputs: [],
|
|
@@ -1223,27 +1519,33 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1223
1519
|
// progress, so its bound is a wall-clock backstop, not a performance budget.
|
|
1224
1520
|
targets.mutation = {
|
|
1225
1521
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
1522
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1226
1523
|
cache: false,
|
|
1227
1524
|
options: { command: cargoFrozen('mutants --workspace'), cwd: cargoWorkspaceRoot, timeoutMs: MUTATION_TIMEOUT_MS },
|
|
1228
1525
|
};
|
|
1229
1526
|
targets.bench = {
|
|
1230
1527
|
executor: 'nx:run-commands',
|
|
1528
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1231
1529
|
cache: false,
|
|
1232
1530
|
options: { command: cargoFrozen('bench --workspace'), cwd: cargoWorkspaceRoot },
|
|
1233
1531
|
};
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
//
|
|
1237
|
-
//
|
|
1238
|
-
|
|
1239
|
-
targets['cargo-
|
|
1532
|
+
// A read-only preview of the retention pass the plugin's postTasksExecution
|
|
1533
|
+
// schedules after runs that built (@smoothbricks/cargo-retain): the superseded unit
|
|
1534
|
+
// generations it would reclaim and why everything else stays. Never cached:
|
|
1535
|
+
// the verdict is about this machine's disk, not the commit.
|
|
1536
|
+
const retainTool = nativeToolDependsOn(nativeTools, 'cargo-retain');
|
|
1537
|
+
targets['cargo-retention'] = {
|
|
1240
1538
|
executor: 'nx:run-commands',
|
|
1241
1539
|
cache: false,
|
|
1242
|
-
|
|
1540
|
+
...(retainTool.length > 0 ? { dependsOn: retainTool } : {}),
|
|
1541
|
+
options: {
|
|
1542
|
+
command: nativeToolCommand(nativeTools, cargoWorkspaceRoot, 'cargo-retain', 'smoo-nx-cargo-retain'),
|
|
1543
|
+
cwd: cargoWorkspaceRoot,
|
|
1544
|
+
},
|
|
1243
1545
|
};
|
|
1244
1546
|
}
|
|
1245
1547
|
if (cargoWorkspace) {
|
|
1246
|
-
const packageTargetNames = await addCargoTestTargets(targets, projectName, projectRoot, workspaceRoot, cargoWorkspace);
|
|
1548
|
+
const packageTargetNames = await addCargoTestTargets(targets, projectName, projectRoot, workspaceRoot, cargoWorkspace, nativeTools);
|
|
1247
1549
|
// Serial-group runners belong to the workspace root, outside inferred ordinary tests. Explicit repository
|
|
1248
1550
|
// aggregates can reach them; their own inputs decide whether each runner executes or replays from cache.
|
|
1249
1551
|
if (!isCargoWorkspaceRoot) {
|
|
@@ -1291,7 +1593,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1291
1593
|
};
|
|
1292
1594
|
}
|
|
1293
1595
|
for (const name of Object.keys(declaredTargets)) {
|
|
1294
|
-
if (name === 'test' || !
|
|
1596
|
+
if (name === 'test' || !isTestNamespaceTargetName(name) || targets[name] !== undefined)
|
|
1295
1597
|
continue;
|
|
1296
1598
|
targets[name] = { dependsOn: ['^build', 'build'] };
|
|
1297
1599
|
}
|
|
@@ -1329,6 +1631,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1329
1631
|
// would skip work a cold registry still needs. Nothing here is a
|
|
1330
1632
|
// workspace output, so there is nothing for Nx to restore in its place.
|
|
1331
1633
|
cache: false,
|
|
1634
|
+
inputs: cargoFetchInputs(projectRoot),
|
|
1332
1635
|
options: {
|
|
1333
1636
|
// One fetch per manifest, independent of the others: Cargo's own
|
|
1334
1637
|
// package-cache lock arbitrates the CARGO_HOME they share.
|
|
@@ -1365,7 +1668,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1365
1668
|
// Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
|
|
1366
1669
|
// directories. Resolve tool versions from the command's actual directory.
|
|
1367
1670
|
// Name the npm packages the command runs (cargoCommandNpmPackages) unless
|
|
1368
|
-
// the target already does.
|
|
1671
|
+
// the target already does, and the Cargo.lock entries its crates reach (the
|
|
1672
|
+
// lock-scope node of the directory it runs in) unless its inputs already do.
|
|
1369
1673
|
for (const [name, target] of Object.entries(targets)) {
|
|
1370
1674
|
const text = targetCommandText(target);
|
|
1371
1675
|
if (!runsFrozenCargo(text))
|
|
@@ -1380,24 +1684,24 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1380
1684
|
? ' && cargo nextest --version'
|
|
1381
1685
|
: '';
|
|
1382
1686
|
const inputs = target.inputs ?? CARGO_INPUTS;
|
|
1383
|
-
const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input);
|
|
1687
|
+
const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input && !isCargoLockInput(input));
|
|
1688
|
+
const namesLock = inputs.some((input) => input === CARGO_CLOSURE_INPUT || isCargoLockInput(input));
|
|
1689
|
+
const lockDirectory = typeof cwd === 'string' ? cwd : projectRoot;
|
|
1384
1690
|
target.inputs = [
|
|
1385
1691
|
...inputs,
|
|
1386
|
-
...
|
|
1692
|
+
...cargoToolchainInputs(),
|
|
1387
1693
|
cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
|
|
1388
|
-
...(namesPackages
|
|
1694
|
+
...(namesPackages
|
|
1695
|
+
? []
|
|
1696
|
+
: [{ externalDependencies: cargoCommandNpmPackages(target, text, pluginInstalledIn(workspaceRoot)) }]),
|
|
1697
|
+
...(namesLock
|
|
1698
|
+
? []
|
|
1699
|
+
: cargoSourcesUnder(lockDirectory, cargoWorkspaces).length > 0
|
|
1700
|
+
? [{ externalDependencies: [cargoLockNodeName(lockDirectory)] }]
|
|
1701
|
+
: // No project-rooted Cargo workspace claims these crates, so the plugin holds no resolve to scope.
|
|
1702
|
+
[UNRESOLVED_CARGO_LOCK_INPUT]),
|
|
1389
1703
|
];
|
|
1390
1704
|
}
|
|
1391
|
-
// `build` warms the test executables' compile; in a nested package that names
|
|
1392
|
-
// the root workspace's one compile.
|
|
1393
|
-
const cargoTestCompileDependency = targets[CARGO_TEST_COMPILE_TARGET]
|
|
1394
|
-
? CARGO_TEST_COMPILE_TARGET
|
|
1395
|
-
: isCargoProject && cargoWorkspace
|
|
1396
|
-
? cargoTargetDependency(projectName, {
|
|
1397
|
-
projectName: cargoWorkspace.rootProjectName,
|
|
1398
|
-
targetName: CARGO_TEST_COMPILE_TARGET,
|
|
1399
|
-
})
|
|
1400
|
-
: null;
|
|
1401
1705
|
const napiDebug = targets['napi-debug'];
|
|
1402
1706
|
if (napiDebug && cargoWorkspace) {
|
|
1403
1707
|
// A crate whose project also builds the debug cdylib runs its tests after
|
|
@@ -1418,15 +1722,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1418
1722
|
}
|
|
1419
1723
|
}
|
|
1420
1724
|
else if (napiDebug) {
|
|
1421
|
-
for (const [name, target] of Object.entries(targets)) {
|
|
1422
|
-
if (!name.startsWith('cargo-test-') || name === CARGO_TEST_COMPILE_TARGET) {
|
|
1423
|
-
continue;
|
|
1424
|
-
}
|
|
1425
|
-
const dependsOn = target.dependsOn ?? [];
|
|
1426
|
-
if (dependsOn.includes(CARGO_TEST_COMPILE_TARGET) && !dependsOn.includes('napi-debug')) {
|
|
1427
|
-
target.dependsOn = [...dependsOn, 'napi-debug'];
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
1725
|
const cargoTest = targets[CARGO_TEST_TARGET];
|
|
1431
1726
|
if (cargoTest?.options &&
|
|
1432
1727
|
typeof cargoTest.options.command === 'string' &&
|
|
@@ -1440,6 +1735,31 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1440
1735
|
// The inferring host's own platform binaries join the aggregate `build`;
|
|
1441
1736
|
// publish still owns foreign platforms.
|
|
1442
1737
|
const hostPlatformBinaries = hostPlatformTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)], hostPlatform);
|
|
1738
|
+
// `<tool>-native` is the host's own build of one tool, so a test that runs it names one edge: `cli-native` is the
|
|
1739
|
+
// declared `cli-<arch>-<family>` build for this machine, `napi-native` the addon (this host's platform target, or
|
|
1740
|
+
// cargo-napi where no configured triple is this machine's), and scriptc-native its host executable producer.
|
|
1741
|
+
// Each is picked from hostPlatformBinaries by the same
|
|
1742
|
+
// suffix rule, its family name `-native` joins it to `build`, and it states no outputs. It runs nothing, so it
|
|
1743
|
+
// states `cache: false`; a cached aggregate would need inputs of its own. A host with no such producer gets no
|
|
1744
|
+
// aggregate, and inference makes no test depend on one.
|
|
1745
|
+
const hostBuilds = {
|
|
1746
|
+
'scriptc-native': hostPlatformBinaries.filter((name) => name.startsWith('scriptc-')),
|
|
1747
|
+
'cli-native': hostPlatformBinaries.filter((name) => name.startsWith('cli-')),
|
|
1748
|
+
'napi-native': targets['cargo-napi']
|
|
1749
|
+
? ['cargo-napi']
|
|
1750
|
+
: hostPlatformBinaries.filter((name) => name.startsWith('napi-')),
|
|
1751
|
+
};
|
|
1752
|
+
for (const [name, dependsOn] of Object.entries(hostBuilds)) {
|
|
1753
|
+
if (dependsOn.length > 0) {
|
|
1754
|
+
targets[name] = {
|
|
1755
|
+
executor: 'nx:noop',
|
|
1756
|
+
cache: false,
|
|
1757
|
+
outputs: [],
|
|
1758
|
+
dependsOn,
|
|
1759
|
+
configurations: { production: {} },
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1443
1763
|
// A deploy is never cached; the build half beside it always is.
|
|
1444
1764
|
//
|
|
1445
1765
|
// Nx's cache answers "did this exact input set already produce an output". A deploy's real
|
|
@@ -1522,9 +1842,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1522
1842
|
dependsOn: [
|
|
1523
1843
|
...new Set([
|
|
1524
1844
|
'^build',
|
|
1525
|
-
// Compiling the test executables is unbounded preparation. Cargo
|
|
1526
|
-
// reuses its incremental state; Nx never restores that shared state.
|
|
1527
|
-
...(cargoTestCompileDependency ? [cargoTestCompileDependency] : []),
|
|
1528
1845
|
...buildOutputTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)]),
|
|
1529
1846
|
...hostPlatformBinaries,
|
|
1530
1847
|
]),
|
|
@@ -1593,10 +1910,12 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1593
1910
|
};
|
|
1594
1911
|
validationTargets.push(SHARD_TIMINGS_TARGET);
|
|
1595
1912
|
}
|
|
1596
|
-
const { commands: lintCommands, inputs: lintProgramInputs, eslintFileSet, } = projectLintCommands(projectRoot, workspaceRoot,
|
|
1913
|
+
const { commands: lintCommands, inputs: lintProgramInputs, eslintFileSet, } = projectLintCommands(projectRoot, workspaceRoot, eslint);
|
|
1914
|
+
// Every lint tool reaches its own verdict in one run: run-commands would end the
|
|
1915
|
+
// other tools once one fails, and their findings would surface a run later.
|
|
1597
1916
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
1598
1917
|
targets.lint = {
|
|
1599
|
-
executor: lintCommands.length > 0 ?
|
|
1918
|
+
executor: lintCommands.length > 0 ? ALL_VERDICTS_EXECUTOR : 'nx:noop',
|
|
1600
1919
|
...(eslintFileSet === null ? {} : { metadata: { eslintFileSet } }),
|
|
1601
1920
|
cache: true,
|
|
1602
1921
|
dependsOn: validationTargets,
|
|
@@ -1610,7 +1929,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1610
1929
|
`{workspaceRoot}/${name}`,
|
|
1611
1930
|
`{projectRoot}/${name}`,
|
|
1612
1931
|
]),
|
|
1613
|
-
|
|
1932
|
+
...(eslint?.configImports ?? []).map((path) => `{workspaceRoot}/${path}`),
|
|
1614
1933
|
],
|
|
1615
1934
|
...(lintCommands.length > 0
|
|
1616
1935
|
? {
|
|
@@ -1619,12 +1938,21 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1619
1938
|
: {}),
|
|
1620
1939
|
};
|
|
1621
1940
|
}
|
|
1941
|
+
// Publish each inferred target's semantic kind (`inferredTaskKind`) as metadata. Nx merges metadata beneath a
|
|
1942
|
+
// declaration, so the final graph still says which tasks are build and which are test work after a package rewrites
|
|
1943
|
+
// one. Fresh objects: `CARGO_PRODUCER_METADATA` is shared by every producer.
|
|
1944
|
+
for (const [name, target] of Object.entries(targets)) {
|
|
1945
|
+
const kind = inferredTaskKind(name);
|
|
1946
|
+
if (kind !== undefined) {
|
|
1947
|
+
target.metadata = { ...target.metadata, smooTaskKind: kind };
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1622
1950
|
// A declared target REPLACES the inferred input list, pin included, so a
|
|
1623
1951
|
// repository that hand-writes `inputs` for a cargo target silently loses its
|
|
1624
|
-
// toolchain identity. Name the
|
|
1625
|
-
// reference it as `cargoToolchain` instead of restating
|
|
1952
|
+
// toolchain identity. Name the identity once here so such a declaration can
|
|
1953
|
+
// reference it as `cargoToolchain` instead of restating entries that could
|
|
1626
1954
|
// drift from the plugin; `smoo monorepo validate` refuses a cached cargo
|
|
1627
|
-
// target
|
|
1955
|
+
// target that does not reach it. Defined only for projects that
|
|
1628
1956
|
// HAVE cargo targets: a project's namedInputs definitions are hashed into
|
|
1629
1957
|
// its configuration hash, so defining it everywhere would invalidate every
|
|
1630
1958
|
// task in the repository to serve projects that can never reference it.
|
|
@@ -1636,7 +1964,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1636
1964
|
[VERSIONLESS_DEFAULT_INPUT]: ['default', ...versionlessProjectInputs],
|
|
1637
1965
|
}),
|
|
1638
1966
|
...(Object.keys(targets).some((name) => name.startsWith('cargo-') || name.startsWith('napi-'))
|
|
1639
|
-
? { [CARGO_TOOLCHAIN_NAMED_INPUT]:
|
|
1967
|
+
? { [CARGO_TOOLCHAIN_NAMED_INPUT]: cargoToolchainInputs() }
|
|
1640
1968
|
: {}),
|
|
1641
1969
|
};
|
|
1642
1970
|
// A custom Cargo target names this instead of a hand-kept crate list or a
|
|
@@ -1644,14 +1972,17 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1644
1972
|
// computation and Nx hashes its files from its own index. Defined for a
|
|
1645
1973
|
// project with a workspace crate under its root — the same projects the
|
|
1646
1974
|
// `--closure <projectRoot>` command could describe.
|
|
1647
|
-
const closureSources =
|
|
1648
|
-
const crate = posix.join(workspace.projectRoot, pkg.dir);
|
|
1649
|
-
return projectRoot === '.' || crate === projectRoot || crate.startsWith(`${projectRoot}/`);
|
|
1650
|
-
}));
|
|
1975
|
+
const closureSources = cargoSourcesUnder(projectRoot, cargoWorkspaces);
|
|
1651
1976
|
if (closureSources.length > 0) {
|
|
1652
|
-
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot, closureSources
|
|
1977
|
+
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot, closureSources);
|
|
1653
1978
|
}
|
|
1979
|
+
const externalNodes = await lockScopeNodes(projectRoot, [
|
|
1980
|
+
...Object.values(targets).map((target) => target.inputs),
|
|
1981
|
+
...Object.values(declaredTargets).map((target) => (isRecord(target) ? target.inputs : undefined)),
|
|
1982
|
+
...Object.values(namedInputs),
|
|
1983
|
+
], cargoWorkspaces);
|
|
1654
1984
|
return {
|
|
1985
|
+
...(Object.keys(externalNodes).length === 0 ? {} : { externalNodes }),
|
|
1655
1986
|
projects: {
|
|
1656
1987
|
[projectRoot]: {
|
|
1657
1988
|
name: projectName,
|
|
@@ -1669,6 +2000,43 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1669
2000
|
},
|
|
1670
2001
|
};
|
|
1671
2002
|
}
|
|
2003
|
+
/** The Cargo resolves with a workspace crate under `directory`: the ones its crates' closure and lock scope cover. */
|
|
2004
|
+
function cargoSourcesUnder(directory, cargoWorkspaces) {
|
|
2005
|
+
return cargoWorkspaces
|
|
2006
|
+
.filter((workspace) => workspace.packages.some(({ package: pkg }) => {
|
|
2007
|
+
const crate = posix.join(workspace.projectRoot, pkg.dir);
|
|
2008
|
+
return directory === '.' || crate === directory || crate.startsWith(`${directory}/`);
|
|
2009
|
+
}))
|
|
2010
|
+
.map((workspace) => workspace.closureSource);
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* The lock-scope nodes a project publishes: its own bun node, and one Cargo
|
|
2014
|
+
* node per directory its inputs name, computed from the resolves that cover
|
|
2015
|
+
* it. A project names only nodes its own crates' resolves define, so two
|
|
2016
|
+
* projects publishing the same node publish the same value.
|
|
2017
|
+
*/
|
|
2018
|
+
async function lockScopeNodes(projectRoot, inputLists, cargoWorkspaces) {
|
|
2019
|
+
const directories = new Set();
|
|
2020
|
+
for (const inputs of inputLists) {
|
|
2021
|
+
if (!Array.isArray(inputs))
|
|
2022
|
+
continue;
|
|
2023
|
+
for (const input of inputs) {
|
|
2024
|
+
if (!isRecord(input) || !Array.isArray(input.externalDependencies))
|
|
2025
|
+
continue;
|
|
2026
|
+
for (const name of input.externalDependencies) {
|
|
2027
|
+
if (typeof name === 'string' && name.startsWith(CARGO_LOCK_NODE_PREFIX)) {
|
|
2028
|
+
directories.add(name.slice(CARGO_LOCK_NODE_PREFIX.length));
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
const own = bunLockNode(projectRoot);
|
|
2034
|
+
const nodes = { [own.name]: own };
|
|
2035
|
+
for (const node of await Promise.all([...directories].map((directory) => cargoLockNode(directory, cargoSourcesUnder(directory, cargoWorkspaces))))) {
|
|
2036
|
+
nodes[node.name] = node;
|
|
2037
|
+
}
|
|
2038
|
+
return nodes;
|
|
2039
|
+
}
|
|
1672
2040
|
const WASM_BINDGEN_OUTPUT_NAMES = {
|
|
1673
2041
|
bundler: 'bundler',
|
|
1674
2042
|
deno: 'deno',
|
|
@@ -1760,20 +2128,27 @@ async function resolveCargoWasmConfig(absoluteProjectRoot, packageJsonPath, work
|
|
|
1760
2128
|
return resolved[0] ?? null;
|
|
1761
2129
|
}
|
|
1762
2130
|
function inferTypescriptOutputs(tsconfigPath, packageJsonPath) {
|
|
2131
|
+
const outDir = typescriptOutDir(tsconfigPath, packageJsonPath);
|
|
2132
|
+
// No .tsbuildinfo here: the emit executor overlays incremental: false, so
|
|
2133
|
+
// tsc-js never writes one and a declared-but-absent output fails the
|
|
2134
|
+
// release-candidate output inspection.
|
|
2135
|
+
return outDir === null
|
|
2136
|
+
? ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}']
|
|
2137
|
+
: [`{projectRoot}/${outDir}/`];
|
|
2138
|
+
}
|
|
2139
|
+
/** The project-relative `compilerOptions.outDir` the config itself states, or null when it states none. */
|
|
2140
|
+
function typescriptOutDir(tsconfigPath, packageJsonPath) {
|
|
1763
2141
|
const tsconfig = readJsonFile(tsconfigPath);
|
|
1764
2142
|
const compilerOptions = isRecord(tsconfig) && isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : null;
|
|
1765
2143
|
const outDir = compilerOptions?.outDir;
|
|
1766
2144
|
if (typeof outDir !== 'string' || outDir.length === 0) {
|
|
1767
|
-
|
|
1768
|
-
// tsc-js never writes one and a declared-but-absent output fails the
|
|
1769
|
-
// release-candidate output inspection.
|
|
1770
|
-
return ['{projectRoot}/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}'];
|
|
2145
|
+
return null;
|
|
1771
2146
|
}
|
|
1772
2147
|
const normalized = posix.normalize(outDir.replaceAll('\\', '/'));
|
|
1773
2148
|
if (normalized === '.' || normalized === '..' || normalized.startsWith('../') || normalized.startsWith('/')) {
|
|
1774
2149
|
throw new Error(`${packageJsonPath}: tsconfig.lib.json compilerOptions.outDir must stay inside the project`);
|
|
1775
2150
|
}
|
|
1776
|
-
return
|
|
2151
|
+
return normalized.replace(/\/$/, '');
|
|
1777
2152
|
}
|
|
1778
2153
|
function resolveNapiConfig(packageJson, packageJsonPath, absoluteProjectRoot, isCargoWorkspace, repoRootPackages) {
|
|
1779
2154
|
if (!packageJson.napi) {
|
|
@@ -1809,7 +2184,7 @@ function resolveNapiConfig(packageJson, packageJsonPath, absoluteProjectRoot, is
|
|
|
1809
2184
|
}
|
|
1810
2185
|
return { binaryName, cargoPackage, manifestPath, targets };
|
|
1811
2186
|
}
|
|
1812
|
-
function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
2187
|
+
function createNapiTargets(projectRoot, config, hostPlatform, nativeTools, repoRooted) {
|
|
1813
2188
|
// napi derives the addon filename ([name]) from the nearest package.json `napi`
|
|
1814
2189
|
// field starting at the invocation cwd. A repository-root invocation runs where
|
|
1815
2190
|
// no such field exists, so without an explicit path every repo-rooted build
|
|
@@ -1822,7 +2197,20 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1822
2197
|
// A repository-root Cargo invocation runs outside the owning npm package, so
|
|
1823
2198
|
// Nx's root-only PATH cannot resolve that package's napi CLI.
|
|
1824
2199
|
const napiCommand = repoRooted ? posix.join(projectRoot, 'node_modules/.bin/napi') : 'napi';
|
|
1825
|
-
const
|
|
2200
|
+
const outputDir = (projectOutput) => (repoRooted ? posix.join(projectRoot, projectOutput) : projectOutput);
|
|
2201
|
+
// The directory a run writes into, as its `outputDir` option states it for the run's profile.
|
|
2202
|
+
const runOutputDirectory = outputDir(OUTPUT_DIR_ARGUMENT);
|
|
2203
|
+
// After a build, the step that writes its input record (build-inputs.ts) into the output directory from the dep-info
|
|
2204
|
+
// rustc wrote for the addon (`target/[<triple>/]<profile>/lib<crate>.d`). The record is inside the target's
|
|
2205
|
+
// outputs, so Nx restores it with the addon it describes. Relative to the runner's cwd, so the hashed command is
|
|
2206
|
+
// the same in every checkout.
|
|
2207
|
+
const recordInputs = (triple, profile, outputDirectory) => {
|
|
2208
|
+
const depInfo = posix.join(...(triple === null ? [] : [triple]), CARGO_PROFILE_OUTPUT_DIR[profile], `lib${config.cargoPackage.replaceAll('-', '_')}.d`);
|
|
2209
|
+
const bin = nativeToolCommand(nativeTools, cargoCwd, 'build-inputs', 'smoo-nx-build-inputs');
|
|
2210
|
+
return ` && ${bin} --manifest-path ${config.manifestPath} --dep-info ${depInfo} --output ${outputDirectory}`;
|
|
2211
|
+
};
|
|
2212
|
+
// The task that builds the executable recordInputs runs, when this workspace builds it.
|
|
2213
|
+
const buildInputsTool = nativeToolDependsOn(nativeTools, 'build-inputs');
|
|
1826
2214
|
const hasHostPlatformTarget = config.targets.some((triple) => {
|
|
1827
2215
|
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
1828
2216
|
return convention !== undefined && sameNapiPlatform(convention, hostPlatform);
|
|
@@ -1838,13 +2226,14 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1838
2226
|
// production loads never see it.
|
|
1839
2227
|
targets['napi-debug'] = {
|
|
1840
2228
|
executor: 'nx:run-commands',
|
|
2229
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1841
2230
|
cache: true,
|
|
1842
2231
|
dependsOn: ['^build'],
|
|
1843
2232
|
inputs: cargoInputs,
|
|
1844
|
-
outputs: ['{projectRoot}/.cache/native-debug'],
|
|
2233
|
+
outputs: ['{projectRoot}/.cache/native-debug/'],
|
|
1845
2234
|
options: {
|
|
1846
2235
|
cwd: cargoCwd,
|
|
1847
|
-
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${
|
|
2236
|
+
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputDir('.cache/native-debug')}`,
|
|
1848
2237
|
},
|
|
1849
2238
|
};
|
|
1850
2239
|
if (!hasHostPlatformTarget) {
|
|
@@ -1852,20 +2241,26 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1852
2241
|
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
1853
2242
|
// (a plain build and a `--target` build write different target/
|
|
1854
2243
|
// subdirectories); native.ts already resolves the identical
|
|
1855
|
-
// platform-suffixed filename from
|
|
1856
|
-
//
|
|
1857
|
-
|
|
2244
|
+
// platform-suffixed filename from <tree>/<platform-dir> after <tree>/host,
|
|
2245
|
+
// in the one tree its package's source authority selects (.cache/native-dev
|
|
2246
|
+
// in a checkout, dist/native installed).
|
|
2247
|
+
const hostBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${runOutputDirectory}${recordInputs(null, profile, runOutputDirectory)}`;
|
|
2248
|
+
const hostOutputs = nativeOutputPaths('host');
|
|
1858
2249
|
targets['cargo-napi'] = {
|
|
1859
2250
|
executor: 'nx:run-commands',
|
|
2251
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1860
2252
|
cache: true,
|
|
1861
|
-
dependsOn: ['^build'],
|
|
2253
|
+
dependsOn: ['^build', ...buildInputsTool],
|
|
1862
2254
|
inputs: cargoInputs,
|
|
1863
|
-
outputs: [
|
|
2255
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
1864
2256
|
options: {
|
|
1865
2257
|
cwd: cargoCwd,
|
|
1866
2258
|
command: hostBuild('dev'),
|
|
2259
|
+
outputDir: hostOutputs.dev,
|
|
2260
|
+
},
|
|
2261
|
+
configurations: {
|
|
2262
|
+
[RELEASE_CONFIGURATION]: { command: hostBuild('release'), outputDir: hostOutputs.release },
|
|
1867
2263
|
},
|
|
1868
|
-
configurations: { [RELEASE_CONFIGURATION]: { command: hostBuild('release') } },
|
|
1869
2264
|
};
|
|
1870
2265
|
}
|
|
1871
2266
|
for (const triple of config.targets) {
|
|
@@ -1874,40 +2269,50 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1874
2269
|
throw new Error(`Missing N-API target convention for ${triple}`);
|
|
1875
2270
|
}
|
|
1876
2271
|
const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
|
|
1877
|
-
const
|
|
2272
|
+
const outputs = nativeOutputPaths(convention.outputName);
|
|
1878
2273
|
if (convention.targetFamily === 'linux') {
|
|
1879
2274
|
// Every host builds a Linux addon the same way: devenv's zig through
|
|
1880
2275
|
// cargo-zigbuild, glibc pinned by the triple suffix. The napi CLI cannot
|
|
1881
2276
|
// carry that suffix (it looks for the artifact under
|
|
1882
2277
|
// target/<triple>.2.17/), so the executor names the `.node` itself.
|
|
2278
|
+
const nodeFile = (directory) => `{projectRoot}/${directory}/${config.binaryName}.${convention.outputName}.node`;
|
|
1883
2279
|
targets[targetName] = {
|
|
1884
2280
|
executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
|
|
2281
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1885
2282
|
cache: true,
|
|
1886
2283
|
inputs: napiInputs(projectRoot, repoRooted, []),
|
|
1887
|
-
|
|
2284
|
+
// The executor takes no `outputDir`: its `output` file is the one place each profile states where it
|
|
2285
|
+
// writes, and the declared output reads the directory holding it from there (`/../`, which Nx's interpolation
|
|
2286
|
+
// joins to the parent). The build-input record stamped beside the `.node` file is restored with it.
|
|
2287
|
+
outputs: ['{options.output}/../'],
|
|
1888
2288
|
options: {
|
|
1889
2289
|
target: `${triple}.${LINUX_GLIBC_FLOOR}`,
|
|
1890
2290
|
manifestPath: posix.join(cargoCwd, config.manifestPath),
|
|
1891
2291
|
package: config.cargoPackage,
|
|
1892
|
-
output:
|
|
2292
|
+
output: nodeFile(outputs.dev),
|
|
1893
2293
|
},
|
|
1894
|
-
configurations: { [RELEASE_CONFIGURATION]: { release: true } },
|
|
2294
|
+
configurations: { [RELEASE_CONFIGURATION]: { release: true, output: nodeFile(outputs.release) } },
|
|
1895
2295
|
};
|
|
1896
2296
|
continue;
|
|
1897
2297
|
}
|
|
1898
2298
|
// macOS addons need Apple's SDK, which zig does not carry: the napi CLI
|
|
1899
2299
|
// drives the host's own toolchain and writes the platform `.d.ts`.
|
|
1900
|
-
const platformBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple} ${commonCommand} --output-dir ${
|
|
2300
|
+
const platformBuild = (profile) => `${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)}`;
|
|
1901
2301
|
targets[targetName] = {
|
|
1902
2302
|
executor: 'nx:run-commands',
|
|
2303
|
+
metadata: CARGO_PRODUCER_METADATA,
|
|
1903
2304
|
cache: true,
|
|
2305
|
+
...(buildInputsTool.length > 0 ? { dependsOn: buildInputsTool } : {}),
|
|
1904
2306
|
inputs: cargoInputs,
|
|
1905
|
-
outputs: [`{projectRoot}/${
|
|
2307
|
+
outputs: [`{projectRoot}/${OUTPUT_DIR_OPTION}/`],
|
|
1906
2308
|
options: {
|
|
1907
2309
|
cwd: cargoCwd,
|
|
1908
2310
|
command: platformBuild('dev'),
|
|
2311
|
+
outputDir: outputs.dev,
|
|
2312
|
+
},
|
|
2313
|
+
configurations: {
|
|
2314
|
+
[RELEASE_CONFIGURATION]: { command: platformBuild('release'), outputDir: outputs.release },
|
|
1909
2315
|
},
|
|
1910
|
-
configurations: { [RELEASE_CONFIGURATION]: { command: platformBuild('release') } },
|
|
1911
2316
|
};
|
|
1912
2317
|
}
|
|
1913
2318
|
return targets;
|
|
@@ -1947,9 +2352,11 @@ async function readPackageJson(packageJsonPath) {
|
|
|
1947
2352
|
const rawNx = isRecord(parsed.nx) ? parsed.nx : undefined;
|
|
1948
2353
|
return {
|
|
1949
2354
|
...('bin' in parsed ? { bin: parsed.bin } : {}),
|
|
2355
|
+
...(isRecord(parsed.devDependencies) ? { devDependencies: parsed.devDependencies } : {}),
|
|
1950
2356
|
...(typeof parsed.name === 'string' ? { name: parsed.name } : {}),
|
|
1951
2357
|
...(isRecord(parsed.napi) ? { napi: parsed.napi } : {}),
|
|
1952
2358
|
...(typeof parsed.private === 'boolean' ? { private: parsed.private } : {}),
|
|
2359
|
+
...('scriptc' in parsed ? { scriptc: parsed.scriptc } : {}),
|
|
1953
2360
|
...(isRecord(parsed.scripts) ? { scripts: parsed.scripts } : {}),
|
|
1954
2361
|
...(rawNx
|
|
1955
2362
|
? {
|
|
@@ -2054,10 +2461,25 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatf
|
|
|
2054
2461
|
// piece excludes them: each test is selected by exactly one target.
|
|
2055
2462
|
const serialExclusion = serialGroups.length === 0 ? null : serialGroups.map((group) => group.filter).join(' or ');
|
|
2056
2463
|
const notSerial = serialExclusion === null ? [] : [`not (${serialExclusion})`];
|
|
2464
|
+
const timings = readNextestTimings(join(absoluteRoot, NEXTEST_TIMINGS_PATH));
|
|
2465
|
+
for (const crate of Object.keys(timings)) {
|
|
2466
|
+
if (!attributed.some((pkg) => pkg.name === crate && pkg.testShards > 1)) {
|
|
2467
|
+
throw new Error(`${posix.join(rootProject.root, NEXTEST_TIMINGS_PATH)} times ${crate}, which is no member of this Cargo ` +
|
|
2468
|
+
'workspace that declares smoothbricks.test.shards above 1');
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2057
2471
|
for (const pkg of attributed) {
|
|
2058
2472
|
const pieces = [];
|
|
2059
2473
|
const sharded = pkg.testShards > 1;
|
|
2060
|
-
const
|
|
2474
|
+
const timed = timings[pkg.name] ?? {};
|
|
2475
|
+
const named = Object.keys(timed);
|
|
2476
|
+
const exceptionalHere = sharded ? exceptional : null;
|
|
2477
|
+
// The tests the hash does not place: nextest.toml's exceptional class and the measured slow tests.
|
|
2478
|
+
const pin = named.length === 0
|
|
2479
|
+
? exceptionalHere
|
|
2480
|
+
: exceptionalHere === null
|
|
2481
|
+
? namedTestsFilter(named)
|
|
2482
|
+
: `(${exceptionalHere}) or (${namedTestsFilter(named)})`;
|
|
2061
2483
|
const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
|
|
2062
2484
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2063
2485
|
const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
|
|
@@ -2068,10 +2490,22 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatf
|
|
|
2068
2490
|
});
|
|
2069
2491
|
}
|
|
2070
2492
|
if (pin !== null) {
|
|
2493
|
+
// Measured tests are dealt by time; the last shard also takes every exceptional test the
|
|
2494
|
+
// manifest does not name, so the exception shards stay an exact cover of the pin.
|
|
2495
|
+
const members = named.length === 0 ? null : timedShardMembers(timed, pkg.testShards);
|
|
2071
2496
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2497
|
+
const own = members?.[index - 1];
|
|
2498
|
+
const unnamed = own !== undefined && exceptionalHere !== null && index === pkg.testShards
|
|
2499
|
+
? ` or ((${exceptionalHere}) and not (${namedTestsFilter(named)}))`
|
|
2500
|
+
: '';
|
|
2072
2501
|
pieces.push({
|
|
2073
|
-
extra: ` --partition hash:${index}/${pkg.testShards}
|
|
2074
|
-
selector: [
|
|
2502
|
+
extra: own === undefined ? ` --partition hash:${index}/${pkg.testShards}` : '',
|
|
2503
|
+
selector: [
|
|
2504
|
+
own === undefined
|
|
2505
|
+
? `package(${pkg.name}) and (${pin})`
|
|
2506
|
+
: `package(${pkg.name}) and ((${namedTestsFilter(own)})${unnamed})`,
|
|
2507
|
+
...notSerial,
|
|
2508
|
+
].join(' and '),
|
|
2075
2509
|
targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
|
|
2076
2510
|
});
|
|
2077
2511
|
}
|
|
@@ -2117,12 +2551,13 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatf
|
|
|
2117
2551
|
* own on every run, so N pieces paid N extractions of every binary in the
|
|
2118
2552
|
* workspace to run 1/N of the tests each: on a workspace with ~200 test
|
|
2119
2553
|
* binaries, ~25 runners extracting side by side on a loaded host all hit the
|
|
2120
|
-
* 120s bound still "Extracting". `smoo-nx-nextest-extract`
|
|
2121
|
-
*
|
|
2554
|
+
* 120s bound still "Extracting". `smoo-nx-nextest-extract` reads the archive's
|
|
2555
|
+
* key, the hash of the task that produced it (createCargoTestArchiveTarget),
|
|
2556
|
+
* unpacks it under that key unless a previous runner already did — one
|
|
2122
2557
|
* extracts while the rest wait — and prints the directory; the run then reuses
|
|
2123
2558
|
* it through nextest's own reuse-build flags, which is what `--archive-file`
|
|
2124
|
-
* does after unpacking. Keyed by the
|
|
2125
|
-
* archive can never run an older extraction's binaries. The one difference
|
|
2559
|
+
* does after unpacking. Keyed by the producing task's inputs, so a rebuilt or
|
|
2560
|
+
* restored archive of other inputs can never run an older extraction's binaries. The one difference
|
|
2126
2561
|
* from `--archive-file` is the Rust standard library directory: nextest has no
|
|
2127
2562
|
* flag to remap it, so a run uses the producing toolchain's own sysroot rather
|
|
2128
2563
|
* than the archived copy of it — the same toolchain, because the archive's hash
|
|
@@ -2165,7 +2600,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatf
|
|
|
2165
2600
|
* `target/`, so no piece waits on another. The one extraction per archive is
|
|
2166
2601
|
* coordinated by `smoo-nx-nextest-extract` itself.
|
|
2167
2602
|
*/
|
|
2168
|
-
async function addCargoTestTargets(targets, currentProjectName, projectRoot, workspaceRoot, workspace) {
|
|
2603
|
+
async function addCargoTestTargets(targets, currentProjectName, projectRoot, workspaceRoot, workspace, nativeTools) {
|
|
2169
2604
|
const targetNames = [];
|
|
2170
2605
|
for (const plan of workspace.packages) {
|
|
2171
2606
|
if (plan.package.projectRoot !== projectRoot) {
|
|
@@ -2178,7 +2613,7 @@ async function addCargoTestTargets(targets, currentProjectName, projectRoot, wor
|
|
|
2178
2613
|
});
|
|
2179
2614
|
for (const piece of plan.pieces) {
|
|
2180
2615
|
targetNames.push(piece.targetName);
|
|
2181
|
-
targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
|
|
2616
|
+
targets[piece.targetName] = cargoTestRunnerTarget(workspace, nativeTools, archive, inputs, piece);
|
|
2182
2617
|
}
|
|
2183
2618
|
}
|
|
2184
2619
|
return targetNames;
|
|
@@ -2203,15 +2638,16 @@ function serialGroupMemberDirs(workspace, group) {
|
|
|
2203
2638
|
}
|
|
2204
2639
|
/**
|
|
2205
2640
|
* The inputs of the runners that select crates from one cargo workspace: the
|
|
2206
|
-
* sources of the crates they select,
|
|
2207
|
-
* nextest config.
|
|
2641
|
+
* sources of the crates they select, the manifest of every package the workspace
|
|
2642
|
+
* builds, and the repository's nextest config.
|
|
2208
2643
|
*
|
|
2209
2644
|
* Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
|
|
2210
2645
|
* `{projectRoot}` glob hashes only files this project owns, and sibling manifests
|
|
2211
2646
|
* belong to whichever nested project holds them. A workspace nextest build unifies
|
|
2212
|
-
* features across every
|
|
2213
|
-
* tests without being a path dependency:
|
|
2214
|
-
*
|
|
2647
|
+
* features across every package it compiles, so a sibling manifest can change a
|
|
2648
|
+
* crate's tests without being a path dependency: a member's, and a path package's
|
|
2649
|
+
* that reaches the build only as another crate's dev-dependency. Track those
|
|
2650
|
+
* manifests, not unrelated sibling sources.
|
|
2215
2651
|
*
|
|
2216
2652
|
* The repository's own nextest config layers OVER the plugin's tool config, so it
|
|
2217
2653
|
* decides timeouts, groups and archive contents: a cached verdict that ignored it
|
|
@@ -2224,14 +2660,39 @@ async function cargoTestRunnerInputs(workspaceRoot, workspace, memberDirs) {
|
|
|
2224
2660
|
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2225
2661
|
memberDir,
|
|
2226
2662
|
cache: workspace.inputsCache,
|
|
2663
|
+
cargo: workspace.closureSource.cargo,
|
|
2227
2664
|
})));
|
|
2665
|
+
// The archive unifies every built package's manifest into every test binary, and a runner's key does not follow the
|
|
2666
|
+
// archive's outputs, so each runner names them all: the ones Nx holds as files, the rest through the repository's
|
|
2667
|
+
// runtime hash of external sources.
|
|
2668
|
+
const manifests = [];
|
|
2669
|
+
const external = new Map();
|
|
2670
|
+
for (const pkg of workspace.closureSource.cargo.local) {
|
|
2671
|
+
const manifest = relative(workspace.closureSource.root, pkg.manifest);
|
|
2672
|
+
if (manifest === '..' || manifest.startsWith(`..${sep}`) || isAbsolute(manifest)) {
|
|
2673
|
+
external.set(pkg.name, pkg.directory);
|
|
2674
|
+
}
|
|
2675
|
+
else {
|
|
2676
|
+
manifests.push(posix.join('{workspaceRoot}', manifest.split(sep).join('/')));
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
if (external.size > 0) {
|
|
2680
|
+
requireExternalRustCratesInput(workspaceRoot, posix.join(workspace.projectRoot, 'Cargo.toml'), external);
|
|
2681
|
+
}
|
|
2228
2682
|
return [
|
|
2229
2683
|
...new Set([
|
|
2230
2684
|
...sources.flat(),
|
|
2231
|
-
...
|
|
2685
|
+
...manifests,
|
|
2686
|
+
...(external.size > 0 ? [EXTERNAL_RUST_CRATES_INPUT] : []),
|
|
2232
2687
|
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2233
2688
|
]),
|
|
2234
2689
|
fileHashInput(PLUGIN_NEXTEST_CONFIG_PATH),
|
|
2690
|
+
// The Cargo.lock entries each selected crate's closure reaches.
|
|
2691
|
+
{
|
|
2692
|
+
externalDependencies: [
|
|
2693
|
+
...new Set(memberDirs.map((memberDir) => cargoLockNodeName(posix.join(workspace.projectRoot, memberDir)))),
|
|
2694
|
+
],
|
|
2695
|
+
},
|
|
2235
2696
|
];
|
|
2236
2697
|
}
|
|
2237
2698
|
/**
|
|
@@ -2239,25 +2700,25 @@ async function cargoTestRunnerInputs(workspaceRoot, workspace, memberDirs) {
|
|
|
2239
2700
|
* workspace builds its command here, so the extraction, reuse-build, tool config and cwd cannot
|
|
2240
2701
|
* drift between the per-crate pieces and the serial groups.
|
|
2241
2702
|
*/
|
|
2242
|
-
function nextestRunnerCommand(workspace, selector, flags) {
|
|
2703
|
+
function nextestRunnerCommand(workspace, nativeTools, selector, flags) {
|
|
2243
2704
|
const toolConfig = nextestToolConfigArg(workspace.projectRoot);
|
|
2244
2705
|
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2245
|
-
const
|
|
2706
|
+
const extract = nativeToolCommand(nativeTools, workspace.projectRoot, 'nextest-extract', 'smoo-nx-nextest-extract');
|
|
2246
2707
|
const reuseExtraction = `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2247
2708
|
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2248
2709
|
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2249
|
-
return (`extracted="$(
|
|
2710
|
+
return (`extracted="$(${extract} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2250
2711
|
cargoFrozen(`nextest run ${reuseExtraction} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`));
|
|
2251
2712
|
}
|
|
2252
2713
|
/** One per-crate piece: a bounded run of its partition of the archive's tests. */
|
|
2253
|
-
function cargoTestRunnerTarget(workspace, archive, inputs, piece) {
|
|
2714
|
+
function cargoTestRunnerTarget(workspace, nativeTools, archive, inputs, piece) {
|
|
2254
2715
|
return {
|
|
2255
2716
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2256
2717
|
cache: true,
|
|
2257
2718
|
inputs,
|
|
2258
|
-
dependsOn: [archive],
|
|
2719
|
+
dependsOn: [archive, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
2259
2720
|
options: {
|
|
2260
|
-
command: nextestRunnerCommand(workspace, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
|
|
2721
|
+
command: nextestRunnerCommand(workspace, nativeTools, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
|
|
2261
2722
|
cwd: workspace.projectRoot,
|
|
2262
2723
|
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2263
2724
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
@@ -2272,14 +2733,14 @@ function cargoTestRunnerTarget(workspace, archive, inputs, piece) {
|
|
|
2272
2733
|
* tests and a failed verdict lists the failed ones, and `--no-tests=fail`, so a filter that selects
|
|
2273
2734
|
* nothing fails rather than passing a group that ran no test.
|
|
2274
2735
|
*/
|
|
2275
|
-
function cargoTestGroupTarget(workspace, inputs, group) {
|
|
2736
|
+
function cargoTestGroupTarget(workspace, nativeTools, inputs, group) {
|
|
2276
2737
|
return {
|
|
2277
2738
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2278
2739
|
cache: true,
|
|
2279
2740
|
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
|
|
2280
|
-
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
2741
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET, ...nativeToolDependsOn(nativeTools, 'nextest-extract')],
|
|
2281
2742
|
options: {
|
|
2282
|
-
command: nextestRunnerCommand(workspace, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
2743
|
+
command: nextestRunnerCommand(workspace, nativeTools, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
2283
2744
|
cwd: workspace.projectRoot,
|
|
2284
2745
|
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2285
2746
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|