@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
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'bun:test';
|
|
2
|
-
import { mkdir, readFile, rm, stat, symlink, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
6
|
-
import { bindListener } from './testing.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Guards the restore-time hunk of `patches/nx@23.2.1.patch`. Nx 23.2.1
|
|
10
|
-
* restores a cached output with its native `copy` (`std::fs::copy`), which on
|
|
11
|
-
* macOS clones the file and keeps its timestamps: the restored output carries
|
|
12
|
-
* the mtime it had when its cache entry was written. Build an output from
|
|
13
|
-
* input A, rebuild it from B, put A back, and the restored A is older than
|
|
14
|
-
* the B output it replaced, so every consumer that judges freshness by mtime
|
|
15
|
-
* (a Cargo build script's `rerun-if-changed`, make, a file watcher) keeps
|
|
16
|
-
* what it built from B. The patched restore stamps each restored file with
|
|
17
|
-
* the time of the restore, as running the task would have.
|
|
18
|
-
*
|
|
19
|
-
* A local hit restores through `DbCache.copyFilesFromCache`; a remote hit is
|
|
20
|
-
* restored inside the native `applyRemoteCacheResults`, which untars the
|
|
21
|
-
* artifact with its stored mtimes and copies it the same way. Each has a case.
|
|
22
|
-
*
|
|
23
|
-
* Only macOS (APFS clone) reproduces the bug: on Linux `std::fs::copy` writes
|
|
24
|
-
* a new file with a fresh mtime, so both cases pass there with or without the
|
|
25
|
-
* hunk. Run them on macOS before dropping the hunk.
|
|
26
|
-
*
|
|
27
|
-
* Drop the hunk, and keep this test, once the Nx version in use restores
|
|
28
|
-
* outputs newer than the files they replace.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
32
|
-
const repoRoot = dirname(dirname(packageRoot));
|
|
33
|
-
const nxEntry = join(repoRoot, 'node_modules', '.bin', 'nx');
|
|
34
|
-
|
|
35
|
-
const OUTPUTS = ['app/result.txt', 'app/dist/nested/copy.txt'] as const;
|
|
36
|
-
|
|
37
|
-
interface Run {
|
|
38
|
-
readonly log: string;
|
|
39
|
-
readonly outputs: readonly { readonly output: string; readonly text: string; readonly mtimeNs: bigint }[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A fixture workspace with one cached `app:build` that copies its input into a
|
|
44
|
-
* file output and a directory output. `run(text)` writes the input, builds
|
|
45
|
-
* under `env`, and reports the outputs' contents and mtimes.
|
|
46
|
-
*/
|
|
47
|
-
async function restoreFixture(workspace: string, env: Record<string, string>) {
|
|
48
|
-
await mkdir(join(workspace, 'app'), { recursive: true });
|
|
49
|
-
const git = Bun.spawnSync(['git', 'init', '--quiet', workspace]);
|
|
50
|
-
expect(git.exitCode, git.stderr.toString()).toBe(0);
|
|
51
|
-
// The repository's own node_modules: the Nx under test.
|
|
52
|
-
await symlink(join(repoRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
53
|
-
await writeFile(join(workspace, 'nx.json'), JSON.stringify({ cacheDirectory: '.nx/cache' }));
|
|
54
|
-
await writeFile(
|
|
55
|
-
join(workspace, 'app', 'project.json'),
|
|
56
|
-
JSON.stringify({
|
|
57
|
-
name: 'app',
|
|
58
|
-
targets: {
|
|
59
|
-
build: {
|
|
60
|
-
executor: 'nx:run-commands',
|
|
61
|
-
cache: true,
|
|
62
|
-
inputs: ['{projectRoot}/source.txt'],
|
|
63
|
-
// A file output and a directory output: the restore walks into the directory.
|
|
64
|
-
outputs: ['{projectRoot}/result.txt', '{projectRoot}/dist'],
|
|
65
|
-
options: {
|
|
66
|
-
cwd: 'app',
|
|
67
|
-
command: 'cp source.txt result.txt && mkdir -p dist/nested && cp source.txt dist/nested/copy.txt',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
);
|
|
73
|
-
const source = join(workspace, 'app', 'source.txt');
|
|
74
|
-
return async (text: string): Promise<Run> => {
|
|
75
|
-
await writeFile(source, text);
|
|
76
|
-
// Spawned asynchronously: a remote case's cache server answers from this process.
|
|
77
|
-
const child = Bun.spawn(['bun', nxEntry, 'run', 'app:build', '--outputStyle=static'], {
|
|
78
|
-
cwd: workspace,
|
|
79
|
-
env,
|
|
80
|
-
stdout: 'pipe',
|
|
81
|
-
stderr: 'pipe',
|
|
82
|
-
});
|
|
83
|
-
const [exitCode, stdout, stderr] = await Promise.all([
|
|
84
|
-
child.exited,
|
|
85
|
-
new Response(child.stdout).text(),
|
|
86
|
-
new Response(child.stderr).text(),
|
|
87
|
-
]);
|
|
88
|
-
const log = `${stdout}${stderr}`;
|
|
89
|
-
expect(exitCode, log).toBe(0);
|
|
90
|
-
const outputs = await Promise.all(
|
|
91
|
-
OUTPUTS.map(async (output) => ({
|
|
92
|
-
output,
|
|
93
|
-
text: await readFile(join(workspace, output), 'utf8'),
|
|
94
|
-
mtimeNs: (await stat(join(workspace, output), { bigint: true })).mtimeNs,
|
|
95
|
-
})),
|
|
96
|
-
);
|
|
97
|
-
return { log, outputs };
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** B must have been built, not restored: otherwise the case compares two restores. */
|
|
102
|
-
function expectBuilt(run: Run, text: string): void {
|
|
103
|
-
expect(run.log).not.toContain('[local cache]');
|
|
104
|
-
expect(run.log).not.toContain('[remote cache]');
|
|
105
|
-
expect(run.outputs.map((output) => output.text)).toEqual(OUTPUTS.map(() => text));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function expectRestoredNewer(restored: Run, replaced: Run, text: string): void {
|
|
109
|
-
restored.outputs.forEach(({ output, text: restoredText, mtimeNs }, index) => {
|
|
110
|
-
expect(restoredText, output).toBe(text);
|
|
111
|
-
const replacedNs = replaced.outputs[index].mtimeNs;
|
|
112
|
-
expect(
|
|
113
|
-
mtimeNs > replacedNs,
|
|
114
|
-
`${output}: restored mtime ${mtimeNs} is not newer than the replaced output's ${replacedNs}`,
|
|
115
|
-
).toBe(true);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
it('restores a locally cached output newer than the output it replaces', async () => {
|
|
120
|
-
await withNxFixture('nx-restore-mtime-', async ({ workspace, socketDirectory }) => {
|
|
121
|
-
const run = await restoreFixture(workspace, fixtureNxEnv(workspace, socketDirectory));
|
|
122
|
-
|
|
123
|
-
await run('A');
|
|
124
|
-
const fromB = await run('B');
|
|
125
|
-
expectBuilt(fromB, 'B');
|
|
126
|
-
const restored = await run('A');
|
|
127
|
-
expect(restored.log).toContain('[local cache]');
|
|
128
|
-
expectRestoredNewer(restored, fromB, 'A');
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('restores a remotely cached output newer than the output it replaces', async () => {
|
|
133
|
-
// The self-hosted remote cache protocol Nx's native HTTP cache speaks: GET and PUT of an
|
|
134
|
-
// artifact tarball at /v1/cache/<hash>.
|
|
135
|
-
const artifacts = new Map<string, ArrayBuffer>();
|
|
136
|
-
// Nx's HTTP cache client, a process of its own, connects to this server: in a sandbox it can only reach a
|
|
137
|
-
// port of the workspace's block, so the server binds one there (a port-0 server binds, but nothing can connect).
|
|
138
|
-
using server = await bindListener((port) =>
|
|
139
|
-
Bun.serve({
|
|
140
|
-
hostname: '127.0.0.1',
|
|
141
|
-
port,
|
|
142
|
-
async fetch(request) {
|
|
143
|
-
const hash = new URL(request.url).pathname.match(/^\/v1\/cache\/([^/]+)$/)?.[1];
|
|
144
|
-
if (hash === undefined) return new Response(null, { status: 404 });
|
|
145
|
-
if (request.method === 'PUT') {
|
|
146
|
-
artifacts.set(hash, await request.arrayBuffer());
|
|
147
|
-
return new Response(null, { status: 200 });
|
|
148
|
-
}
|
|
149
|
-
const artifact = artifacts.get(hash);
|
|
150
|
-
return artifact === undefined ? new Response(null, { status: 404 }) : new Response(artifact);
|
|
151
|
-
},
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
await withNxFixture('nx-restore-mtime-remote-', async ({ workspace, socketDirectory }) => {
|
|
155
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_SELF_HOSTED_REMOTE_CACHE_SERVER: server.url.origin };
|
|
156
|
-
const run = await restoreFixture(workspace, env);
|
|
157
|
-
|
|
158
|
-
await run('A');
|
|
159
|
-
const fromB = await run('B');
|
|
160
|
-
expectBuilt(fromB, 'B');
|
|
161
|
-
expect(artifacts.size).toBe(2);
|
|
162
|
-
// Forget the local cache and its records, so A can only come from the remote. The fixture's socket state in
|
|
163
|
-
// `.nx/sockets` stays: its published alias names it.
|
|
164
|
-
await rm(join(workspace, '.nx', 'cache'), { recursive: true });
|
|
165
|
-
await rm(join(workspace, '.nx', 'workspace-data'), { recursive: true });
|
|
166
|
-
const restored = await run('A');
|
|
167
|
-
expect(restored.log).toContain('[remote cache]');
|
|
168
|
-
expectRestoredNewer(restored, fromB, 'A');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
-
import { mkdir, readFile, rm, symlink, unlink, utimes, watch, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { guardEvent } from './__tests__/counted-cargo.js';
|
|
7
|
-
import { fixtureNxEnv, stopFixtureNxDaemon, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
8
|
-
import { awaitExit, isRunning, ownedWorkspaceSocketDirectory, processTable, terminate } from './testing.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Guards the daemon-claim hunk of `patches/nx@23.2.1.patch`. Every Nx 23.2.1 daemon overwrote the workspace's
|
|
12
|
-
* `server-process.json` with its own pid, so two clients that both found no daemon started two, and the later one
|
|
13
|
-
* displaced the first: the first's clients lost their socket in the middle of a request (EPIPE on
|
|
14
|
-
* `RECORD_OUTPUTS_HASH_BATCH`). Under a configured `NX_SOCKET_DIR` both daemons bind the same path, and closing a
|
|
15
|
-
* listening Unix socket unlinks its path: the displaced daemon's shutdown removed the successor's socket, so the
|
|
16
|
-
* successor ran on unreachable, the next client started yet another daemon, and that one displaced it the same way.
|
|
17
|
-
*
|
|
18
|
-
* A daemon now claims the record exclusively, and a second daemon started while one serves the workspace exits without
|
|
19
|
-
* touching the record or the socket. A daemon whose socket is gone, which no client can reach, exits instead of
|
|
20
|
-
* holding the record, and leaves a path another daemon bound alone. A record whose live pid has not answered for longer
|
|
21
|
-
* than a daemon takes to start is stale, whatever process holds that pid now. Drop the hunk, and keep this test, once
|
|
22
|
-
* the Nx version in use leaves a serving daemon alone.
|
|
23
|
-
*
|
|
24
|
-
* Nx's default socket root is the literal `/tmp/.nx` with the daemon's pid hashed into the name, which a sandbox does
|
|
25
|
-
* not admit. So the two daemons' socket paths are named: one directory each, which is what two daemons on the default
|
|
26
|
-
* root bind, and one directory for both, which is what a configured `NX_SOCKET_DIR` does.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
30
|
-
const nxEntry = join(repositoryRoot, 'node_modules', '.bin', 'nx');
|
|
31
|
-
const daemonStart = createRequire(join(repositoryRoot, 'package.json')).resolve('nx/src/daemon/server/start.js');
|
|
32
|
-
|
|
33
|
-
interface DaemonRecord {
|
|
34
|
-
readonly processId: number;
|
|
35
|
-
readonly socketPath: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async function daemonRecord(workspace: string): Promise<DaemonRecord | null> {
|
|
39
|
-
const text = await readFile(join(workspace, '.nx/workspace-data/d/server-process.json'), 'utf8').catch(
|
|
40
|
-
(error: unknown) => {
|
|
41
|
-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null;
|
|
42
|
-
throw error;
|
|
43
|
-
},
|
|
44
|
-
);
|
|
45
|
-
if (text === null) return null;
|
|
46
|
-
const record: unknown = JSON.parse(text);
|
|
47
|
-
if (
|
|
48
|
-
typeof record !== 'object' ||
|
|
49
|
-
record === null ||
|
|
50
|
-
!('processId' in record) ||
|
|
51
|
-
typeof record.processId !== 'number' ||
|
|
52
|
-
!('socketPath' in record) ||
|
|
53
|
-
typeof record.socketPath !== 'string'
|
|
54
|
-
) {
|
|
55
|
-
throw new Error(`the fixture daemon record names no process and socket: ${text}`);
|
|
56
|
-
}
|
|
57
|
-
return { processId: record.processId, socketPath: record.socketPath };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function fixtureWorkspace(workspace: string): Promise<void> {
|
|
61
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
62
|
-
await writeFile(join(workspace, 'nx.json'), '{}\n');
|
|
63
|
-
await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'daemon-claim', private: true }));
|
|
64
|
-
await mkdir(join(workspace, 'p'));
|
|
65
|
-
await writeFile(join(workspace, 'p', 'project.json'), JSON.stringify({ name: 'p' }));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function nx(workspace: string, env: Record<string, string>, ...args: string[]): string {
|
|
69
|
-
const ran = spawnSync('bun', [nxEntry, ...args], { cwd: workspace, env, encoding: 'utf8' });
|
|
70
|
-
expect(ran.status, `nx ${args.join(' ')}\n${ran.stdout}${ran.stderr}`).toBe(0);
|
|
71
|
-
return ran.stdout;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async function startedDaemon(workspace: string, env: Record<string, string>): Promise<DaemonRecord> {
|
|
75
|
-
nx(workspace, env, 'daemon', '--start');
|
|
76
|
-
const record = await daemonRecord(workspace);
|
|
77
|
-
if (record === null) throw new Error('nx daemon --start left no daemon record');
|
|
78
|
-
return record;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* A socket directory of its own, made below the workspace's short socket alias so that a configured `NX_SOCKET_DIR`
|
|
83
|
-
* names a real directory inside the workspace, which the sandbox admits. The caller stops any daemon bound in it before
|
|
84
|
-
* this returns; this removes only the directory it made, and `force` takes what is left.
|
|
85
|
-
*/
|
|
86
|
-
async function withSocketDir<T>(workspace: string, slot: 'a' | 'b', body: (dir: string) => Promise<T>): Promise<T> {
|
|
87
|
-
const dir = await ownedWorkspaceSocketDirectory(workspace, slot);
|
|
88
|
-
try {
|
|
89
|
-
return await body(dir);
|
|
90
|
-
} finally {
|
|
91
|
-
await rm(dir, { recursive: true, force: true });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* A daemon serves `workspace` under `servingEnv`, then a second one is started under `challengerEnv`. The two share
|
|
97
|
-
* a socket path only when their environments name one.
|
|
98
|
-
*/
|
|
99
|
-
async function secondDaemonDefers(
|
|
100
|
-
workspace: string,
|
|
101
|
-
servingEnv: Record<string, string>,
|
|
102
|
-
challengerEnv: Record<string, string>,
|
|
103
|
-
): Promise<void> {
|
|
104
|
-
const serving = await startedDaemon(workspace, servingEnv);
|
|
105
|
-
|
|
106
|
-
// What a second client does when its probe found no daemon: start one. The record's directory is watched from
|
|
107
|
-
// before the spawn, so no write the second daemon makes to it can be missed.
|
|
108
|
-
const recordChanges = new AbortController();
|
|
109
|
-
const changes = watch(join(workspace, '.nx/workspace-data/d'), { signal: recordChanges.signal });
|
|
110
|
-
let output = '';
|
|
111
|
-
const second = spawn(process.execPath, [daemonStart], {
|
|
112
|
-
cwd: workspace,
|
|
113
|
-
env: challengerEnv,
|
|
114
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
115
|
-
});
|
|
116
|
-
second.stdout.setEncoding('utf8').on('data', (text: string) => {
|
|
117
|
-
output += text;
|
|
118
|
-
});
|
|
119
|
-
second.stderr.setEncoding('utf8').on('data', (text: string) => {
|
|
120
|
-
output += text;
|
|
121
|
-
});
|
|
122
|
-
const exited = new Promise<number | null>((resolve) => second.once('exit', resolve));
|
|
123
|
-
// Unpatched, the second daemon never exits: it takes the record and serves. Either ends the wait.
|
|
124
|
-
let displaced = false;
|
|
125
|
-
const tookRecord = (async () => {
|
|
126
|
-
try {
|
|
127
|
-
for await (const _ of changes) {
|
|
128
|
-
if ((await daemonRecord(workspace))?.processId === second.pid) {
|
|
129
|
-
displaced = true;
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
} catch (error) {
|
|
134
|
-
if (!(error instanceof Error && error.name === 'AbortError')) throw error;
|
|
135
|
-
}
|
|
136
|
-
})();
|
|
137
|
-
try {
|
|
138
|
-
await guardEvent(
|
|
139
|
-
Promise.race([exited, tookRecord]),
|
|
140
|
-
'the second daemon to exit or take the record',
|
|
141
|
-
() => `second daemon ${second.pid}, exit ${second.exitCode}\n${output}`,
|
|
142
|
-
);
|
|
143
|
-
expect(displaced, `the second daemon ${second.pid} took the record from ${serving.processId}\n${output}`).toBe(
|
|
144
|
-
false,
|
|
145
|
-
);
|
|
146
|
-
expect(await exited, output).toBe(0);
|
|
147
|
-
expect(await daemonRecord(workspace)).toEqual(serving);
|
|
148
|
-
expect(isRunning(serving.processId)).toBe(true);
|
|
149
|
-
|
|
150
|
-
// The serving daemon still answers on its socket: no client starts another.
|
|
151
|
-
expect(JSON.parse(nx(workspace, servingEnv, 'show', 'projects', '--json'))).toEqual(['p']);
|
|
152
|
-
expect(await daemonRecord(workspace)).toEqual(serving);
|
|
153
|
-
} finally {
|
|
154
|
-
if (second.pid !== undefined && second.exitCode === null) {
|
|
155
|
-
terminate(second.pid);
|
|
156
|
-
await exited;
|
|
157
|
-
}
|
|
158
|
-
recordChanges.abort();
|
|
159
|
-
await tookRecord;
|
|
160
|
-
// Stopped under the environment that started it, before the caller removes the socket directory it bound.
|
|
161
|
-
await stopFixtureNxDaemon(workspace, servingEnv);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
describe('a second daemon started for a workspace a daemon serves', () => {
|
|
166
|
-
it('exits and leaves the serving daemon alone when each binds a socket directory of its own', async () => {
|
|
167
|
-
await withNxFixture('nx-daemon-claim-', async ({ socketDirectory, workspace }) => {
|
|
168
|
-
await fixtureWorkspace(workspace);
|
|
169
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
170
|
-
await withSocketDir(workspace, 'a', async (servingDir) => {
|
|
171
|
-
await withSocketDir(workspace, 'b', async (challengerDir) => {
|
|
172
|
-
await secondDaemonDefers(
|
|
173
|
-
workspace,
|
|
174
|
-
{ ...env, NX_SOCKET_DIR: servingDir },
|
|
175
|
-
{ ...env, NX_SOCKET_DIR: challengerDir },
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('exits and leaves the serving daemon alone when both use one socket directory', async () => {
|
|
183
|
-
await withNxFixture('nx-daemon-claim-shared-', async ({ socketDirectory, workspace }) => {
|
|
184
|
-
await fixtureWorkspace(workspace);
|
|
185
|
-
await withSocketDir(workspace, 'a', async (socketDir) => {
|
|
186
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true', NX_SOCKET_DIR: socketDir };
|
|
187
|
-
await secondDaemonDefers(workspace, env, env);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('replaces a daemon whose socket was removed, which no client could reach', async () => {
|
|
194
|
-
await withNxFixture('nx-daemon-claim-lost-', async ({ socketDirectory, workspace }) => {
|
|
195
|
-
await fixtureWorkspace(workspace);
|
|
196
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
197
|
-
const lost = await startedDaemon(workspace, env);
|
|
198
|
-
const lostProcess = (await processTable()).filter((entry) => entry.pid === lost.processId);
|
|
199
|
-
// What a temp-directory reaper does to a socket that has not been used for days.
|
|
200
|
-
await unlink(lost.socketPath);
|
|
201
|
-
await awaitExit(lostProcess, `the Nx daemon ${lost.processId}, whose socket was removed`);
|
|
202
|
-
|
|
203
|
-
expect(JSON.parse(nx(workspace, env, 'show', 'projects', '--json'))).toEqual(['p']);
|
|
204
|
-
const replacement = await daemonRecord(workspace);
|
|
205
|
-
expect(replacement?.processId).not.toBe(lost.processId);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('keeps serving clients whose socket directory differs from the one it bound', async () => {
|
|
210
|
-
await withNxFixture('nx-daemon-claim-env-', async ({ socketDirectory, workspace }) => {
|
|
211
|
-
await fixtureWorkspace(workspace);
|
|
212
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
213
|
-
await withSocketDir(workspace, 'a', async (socketDir) => {
|
|
214
|
-
await withSocketDir(workspace, 'b', async (otherSocketDir) => {
|
|
215
|
-
const servingEnv = { ...env, NX_SOCKET_DIR: socketDir };
|
|
216
|
-
try {
|
|
217
|
-
const serving = await startedDaemon(workspace, servingEnv);
|
|
218
|
-
// The daemon takes on each client's environment; NX_SOCKET_DIR is part of it.
|
|
219
|
-
expect(JSON.parse(nx(workspace, env, 'show', 'projects', '--json'))).toEqual(['p']);
|
|
220
|
-
expect(
|
|
221
|
-
JSON.parse(nx(workspace, { ...env, NX_SOCKET_DIR: otherSocketDir }, 'show', 'projects', '--json')),
|
|
222
|
-
).toEqual(['p']);
|
|
223
|
-
expect(await daemonRecord(workspace)).toEqual(serving);
|
|
224
|
-
expect(isRunning(serving.processId)).toBe(true);
|
|
225
|
-
} finally {
|
|
226
|
-
// Stopped under the environment that started it, before the caller removes the socket directory it bound.
|
|
227
|
-
await stopFixtureNxDaemon(workspace, servingEnv);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('replaces a record whose pid now belongs to an unrelated live process', async () => {
|
|
235
|
-
await withNxFixture('nx-daemon-claim-reused-', async ({ socketDirectory, workspace }) => {
|
|
236
|
-
await fixtureWorkspace(workspace);
|
|
237
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
238
|
-
// A process that lives until its stdin closes: what a daemon's pid can be reused by after a crash.
|
|
239
|
-
const unrelated = spawn(process.execPath, ['-e', 'process.stdin.resume()'], {
|
|
240
|
-
stdio: ['pipe', 'ignore', 'ignore'],
|
|
241
|
-
});
|
|
242
|
-
const unrelatedExited = new Promise<void>((resolve) => unrelated.once('exit', () => resolve()));
|
|
243
|
-
try {
|
|
244
|
-
if (unrelated.pid === undefined) throw new Error('the unrelated process did not start');
|
|
245
|
-
const nxPackage: unknown = JSON.parse(
|
|
246
|
-
await readFile(join(repositoryRoot, 'node_modules/nx/package.json'), 'utf8'),
|
|
247
|
-
);
|
|
248
|
-
if (typeof nxPackage !== 'object' || nxPackage === null || !('version' in nxPackage)) {
|
|
249
|
-
throw new Error('the installed nx package names no version');
|
|
250
|
-
}
|
|
251
|
-
const record = join(workspace, '.nx/workspace-data/d/server-process.json');
|
|
252
|
-
await mkdir(join(workspace, '.nx/workspace-data/d'), { recursive: true });
|
|
253
|
-
await writeFile(
|
|
254
|
-
record,
|
|
255
|
-
`${JSON.stringify({
|
|
256
|
-
processId: unrelated.pid,
|
|
257
|
-
socketPath: join(workspace, 'crashed.sock'),
|
|
258
|
-
nxVersion: nxPackage.version,
|
|
259
|
-
workspaceRoot: workspace,
|
|
260
|
-
})}\n`,
|
|
261
|
-
);
|
|
262
|
-
// Written by a daemon that crashed long before this client came.
|
|
263
|
-
const crashed = new Date(Date.now() - 10 * 60_000);
|
|
264
|
-
await utimes(record, crashed, crashed);
|
|
265
|
-
|
|
266
|
-
expect(JSON.parse(nx(workspace, env, 'show', 'projects', '--json'))).toEqual(['p']);
|
|
267
|
-
// A deferral to the stale record would wait out the client's whole budget for a daemon that never answers, and the
|
|
268
|
-
// client logs that exhaustion. A client that started its own daemon instead never logs it.
|
|
269
|
-
const clientLog = await readFile(join(workspace, '.nx/workspace-data/d/daemon.log'), 'utf8');
|
|
270
|
-
expect(clientLog).toContain('[Client] Starting new daemon server in background');
|
|
271
|
-
expect(clientLog).not.toContain('[Client] Server not available after');
|
|
272
|
-
expect((await daemonRecord(workspace))?.processId).not.toBe(unrelated.pid);
|
|
273
|
-
expect(isRunning(unrelated.pid)).toBe(true);
|
|
274
|
-
} finally {
|
|
275
|
-
unrelated.stdin.end();
|
|
276
|
-
await unrelatedExited;
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'bun:test';
|
|
2
|
-
import { execFile } from 'node:child_process';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
|
-
import { readFile, symlink, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
|
-
import { dirname, join } from 'node:path';
|
|
7
|
-
import { setTimeout as sleep } from 'node:timers/promises';
|
|
8
|
-
import { promisify } from 'node:util';
|
|
9
|
-
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
10
|
-
|
|
11
|
-
const run = promisify(execFile);
|
|
12
|
-
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
13
|
-
const nxEntry = join(repositoryRoot, 'node_modules/.bin/nx');
|
|
14
|
-
|
|
15
|
-
async function cpuSeconds(pid: number): Promise<number> {
|
|
16
|
-
const { stdout } = await run('ps', ['-p', String(pid), '-o', 'time=']);
|
|
17
|
-
const fields = stdout.trim().split(':');
|
|
18
|
-
if (fields.length < 2 || fields.some((field) => !/^\d+(?:\.\d+)?$/.test(field))) {
|
|
19
|
-
throw new Error(`could not read CPU time for owned daemon ${pid}: ${stdout}`);
|
|
20
|
-
}
|
|
21
|
-
return fields.reduce((seconds, field) => seconds * 60 + Number(field), 0);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// A host process-census proof, explicitly opted into through a focused Nx run.
|
|
25
|
-
// Keep the 30-second measurement out of ordinary bounded test shards.
|
|
26
|
-
it.skipIf(process.env.NX_DAEMON_CPU_PROOF !== 'true')(
|
|
27
|
-
'measures the installed Nx daemon idle CPU without profiling or source writes',
|
|
28
|
-
async () => {
|
|
29
|
-
await withNxFixture('nx-idle-cpu-', async ({ workspace, socketDirectory }) => {
|
|
30
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
31
|
-
await writeFile(join(workspace, 'nx.json'), '{}\n');
|
|
32
|
-
await writeFile(join(workspace, 'package.json'), '{"name":"idle-cpu-proof","private":true}\n');
|
|
33
|
-
await writeFile(join(workspace, '.gitignore'), 'node_modules\n.nx\n');
|
|
34
|
-
// Use this checkout's real lockfile size, not a tiny synthetic stand-in.
|
|
35
|
-
const lock = await readFile(join(repositoryRoot, 'bun.lock'));
|
|
36
|
-
await writeFile(join(workspace, 'bun.lock'), lock);
|
|
37
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
38
|
-
await run('node', [nxEntry, 'daemon', '--start'], { cwd: workspace, env });
|
|
39
|
-
await run('node', [nxEntry, 'show', 'projects', '--json'], { cwd: workspace, env });
|
|
40
|
-
const recordPath = join(workspace, '.nx/workspace-data/d/server-process.json');
|
|
41
|
-
const record: unknown = JSON.parse(await readFile(recordPath, 'utf8'));
|
|
42
|
-
if (
|
|
43
|
-
typeof record !== 'object' ||
|
|
44
|
-
record === null ||
|
|
45
|
-
!('processId' in record) ||
|
|
46
|
-
typeof record.processId !== 'number'
|
|
47
|
-
) {
|
|
48
|
-
throw new Error(`owned fixture has no daemon process id: ${JSON.stringify(record)}`);
|
|
49
|
-
}
|
|
50
|
-
const pid = record.processId;
|
|
51
|
-
const before = await cpuSeconds(pid);
|
|
52
|
-
const started = performance.now();
|
|
53
|
-
await sleep(30_000);
|
|
54
|
-
const after = await cpuSeconds(pid);
|
|
55
|
-
const wallSeconds = (performance.now() - started) / 1000;
|
|
56
|
-
const cpu = after - before;
|
|
57
|
-
const sourcePath = join(
|
|
58
|
-
dirname(createRequire(import.meta.url).resolve('nx/package.json')),
|
|
59
|
-
'dist/src/daemon/server/server.js',
|
|
60
|
-
);
|
|
61
|
-
const source = await readFile(sourcePath);
|
|
62
|
-
console.log(
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
proof: 'nx-daemon-idle-cpu',
|
|
65
|
-
pid,
|
|
66
|
-
wallSeconds,
|
|
67
|
-
cpuSeconds: cpu,
|
|
68
|
-
corePercent: (100 * cpu) / wallSeconds,
|
|
69
|
-
lockBytes: lock.length,
|
|
70
|
-
implementationSha256: createHash('sha256').update(source).digest('hex'),
|
|
71
|
-
intervalLog: (await readFile(join(workspace, '.nx/workspace-data/d/daemon.log'), 'utf8'))
|
|
72
|
-
.split('\n')
|
|
73
|
-
.find((line) => line.includes('interval (')),
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
expect(cpu).toBeGreaterThanOrEqual(0);
|
|
77
|
-
expect(wallSeconds).toBeGreaterThanOrEqual(30);
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
);
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'bun:test';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { watch as fsWatch, readFileSync } from 'node:fs';
|
|
4
|
-
import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
|
-
import { dirname, join } from 'node:path';
|
|
7
|
-
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
8
|
-
import { nxDaemonProcesses } from './testing.js';
|
|
9
|
-
|
|
10
|
-
// A graph plugin that asks its daemon for files, as globIndexedFiles does: from an isolated worker Nx routes the glob
|
|
11
|
-
// through the worker's own daemon client.
|
|
12
|
-
const DAEMON_GLOB_PLUGIN = `const { globWithWorkspaceContext } = require('nx/src/utils/workspace-context');
|
|
13
|
-
const { workspaceRoot } = require('nx/src/utils/workspace-root');
|
|
14
|
-
exports.createNodesV2 = ['**/project.json', async () => {
|
|
15
|
-
await globWithWorkspaceContext(workspaceRoot, ['**/project.json']);
|
|
16
|
-
return [];
|
|
17
|
-
}];
|
|
18
|
-
`;
|
|
19
|
-
// The daemon logs its open connection count on every connect and close.
|
|
20
|
-
const OPEN_CONNECTIONS = /Number of open connections: (\d+)$/;
|
|
21
|
-
|
|
22
|
-
it('serves real daemon requests with the installed five-minute inactivity policy', async () => {
|
|
23
|
-
const require = createRequire(import.meta.url);
|
|
24
|
-
const installedNx = require('nx/src/daemon/server/shutdown-utils.js');
|
|
25
|
-
expect(installedNx.SERVER_INACTIVITY_TIMEOUT_MS).toBe(5 * 60_000);
|
|
26
|
-
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
27
|
-
const nxEntry = join(repositoryRoot, 'node_modules/.bin/nx');
|
|
28
|
-
await withNxFixture('nx-idle-policy-', async ({ workspace, socketDirectory }) => {
|
|
29
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
30
|
-
await writeFile(join(workspace, 'nx.json'), '{}\n');
|
|
31
|
-
await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'idle-policy', private: true }));
|
|
32
|
-
await mkdir(join(workspace, 'p'));
|
|
33
|
-
await writeFile(join(workspace, 'p/project.json'), JSON.stringify({ name: 'p' }));
|
|
34
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true' };
|
|
35
|
-
const started = spawnSync('node', [nxEntry, 'daemon', '--start'], { cwd: workspace, env, encoding: 'utf8' });
|
|
36
|
-
expect(started.status, started.stdout + started.stderr).toBe(0);
|
|
37
|
-
const requested = spawnSync('node', [nxEntry, 'show', 'projects', '--json'], {
|
|
38
|
-
cwd: workspace,
|
|
39
|
-
env,
|
|
40
|
-
encoding: 'utf8',
|
|
41
|
-
});
|
|
42
|
-
expect(requested.status, requested.stdout + requested.stderr).toBe(0);
|
|
43
|
-
expect(JSON.parse(requested.stdout)).toEqual(['p']);
|
|
44
|
-
expect(await readFile(join(workspace, '.nx/workspace-data/d/daemon.log'), 'utf8')).toContain(
|
|
45
|
-
join(dirname(require.resolve('nx/package.json')), 'dist/src/daemon/server'),
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('lets a resident plugin worker ask its daemon for files without holding the daemon open', async () => {
|
|
51
|
-
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
52
|
-
const nxEntry = join(repositoryRoot, 'node_modules/.bin/nx');
|
|
53
|
-
await withNxFixture('nx-worker-connection-', async ({ workspace, socketDirectory }) => {
|
|
54
|
-
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
55
|
-
await writeFile(join(workspace, 'nx.json'), JSON.stringify({ plugins: ['./daemon-glob-plugin.js'] }));
|
|
56
|
-
await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'worker-connection', private: true }));
|
|
57
|
-
await writeFile(join(workspace, 'daemon-glob-plugin.js'), DAEMON_GLOB_PLUGIN);
|
|
58
|
-
await mkdir(join(workspace, 'p'));
|
|
59
|
-
await writeFile(join(workspace, 'p/project.json'), JSON.stringify({ name: 'p' }));
|
|
60
|
-
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true', NX_ISOLATE_PLUGINS: 'true' };
|
|
61
|
-
const requested = spawnSync('node', [nxEntry, 'show', 'projects', '--json'], {
|
|
62
|
-
cwd: workspace,
|
|
63
|
-
env,
|
|
64
|
-
encoding: 'utf8',
|
|
65
|
-
});
|
|
66
|
-
expect(requested.status, requested.stdout + requested.stderr).toBe(0);
|
|
67
|
-
expect(JSON.parse(requested.stdout)).toEqual(['p']);
|
|
68
|
-
const logPath = join(workspace, '.nx/workspace-data/d/daemon.log');
|
|
69
|
-
// The daemon logs its open connection count on every connect and close, so the wait ends on that log. A connection
|
|
70
|
-
// the worker kept would keep the daemon from its five-minute idle stop for as long as the worker lives, and the daemon
|
|
71
|
-
// keeps a worker with graph hooks for as long as it lives.
|
|
72
|
-
let open: string | undefined;
|
|
73
|
-
let notify: (() => void) | undefined;
|
|
74
|
-
const watcher = fsWatch(dirname(logPath), () => notify?.());
|
|
75
|
-
try {
|
|
76
|
-
while (open !== '0') {
|
|
77
|
-
// Armed before the read, so a count written while the read is in flight still wakes the next wait.
|
|
78
|
-
const changed = Promise.withResolvers<void>();
|
|
79
|
-
notify = () => changed.resolve();
|
|
80
|
-
const log = await readFile(logPath, 'utf8');
|
|
81
|
-
expect(log).toContain('Handled json message GLOB');
|
|
82
|
-
open = log
|
|
83
|
-
.split('\n')
|
|
84
|
-
.map((line) => OPEN_CONNECTIONS.exec(line)?.[1])
|
|
85
|
-
.filter((count) => count !== undefined)
|
|
86
|
-
.at(-1);
|
|
87
|
-
if (open !== '0') await changed.promise;
|
|
88
|
-
}
|
|
89
|
-
} finally {
|
|
90
|
-
watcher.close();
|
|
91
|
-
}
|
|
92
|
-
const workers = (await nxDaemonProcesses(workspace)).filter(({ command }) => command.includes('plugin-worker'));
|
|
93
|
-
expect(workers.length, 'the resident plugin worker that asked the daemon for files').toBeGreaterThan(0);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('syntax-checks every JavaScript file patched in the actual installed Nx product', () => {
|
|
98
|
-
const installedNxRoot = dirname(createRequire(import.meta.url).resolve('nx/package.json'));
|
|
99
|
-
const patch = readFileSync(new URL('../../../patches/nx@23.2.1.patch', import.meta.url), 'utf8');
|
|
100
|
-
const patchedJavaScript = patch
|
|
101
|
-
.split('\n')
|
|
102
|
-
.filter((line) => line.startsWith('+++ b/') && line.endsWith('.js'))
|
|
103
|
-
.map((line) => line.slice('+++ b/'.length));
|
|
104
|
-
expect(patchedJavaScript.length).toBeGreaterThan(0);
|
|
105
|
-
for (const relative of patchedJavaScript) {
|
|
106
|
-
const checked = spawnSync('node', ['--check', join(installedNxRoot, relative)], {
|
|
107
|
-
encoding: 'utf8',
|
|
108
|
-
});
|
|
109
|
-
expect(checked.status, `${relative}\n${checked.stdout}${checked.stderr}`).toBe(0);
|
|
110
|
-
}
|
|
111
|
-
});
|