@smoothbricks/nx-plugin 0.4.26 → 0.4.28
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 +994 -117
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +15 -73
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +3 -2
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +16 -15
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +43 -6
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +309 -73
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +101 -5
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +291 -10
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +207 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +576 -202
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +370 -138
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +2 -5
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -67
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +569 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -93
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +1146 -159
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -41
- package/package.json +74 -12
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo.ts +33 -14
- package/src/__tests__/fixture-nx-env.ts +111 -46
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +16 -74
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -21
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +138 -66
- package/src/cargo-closure-input.ts +17 -15
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +70 -1
- package/src/cargo-source-hash.test.ts +193 -97
- package/src/cargo-source-hash.ts +345 -68
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +336 -10
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1036 -578
- package/src/ensure-built.ts +820 -224
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +909 -295
- package/src/index.ts +441 -143
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +2 -6
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +427 -82
- package/src/nx-cache-bound.test.ts +5 -10
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +7 -16
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +26 -25
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +87 -89
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -0
- package/test-timings.json +85 -30
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -665
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
package/dist/index.js
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
import { existsSync, realpathSync } from 'node:fs';
|
|
2
2
|
import { readdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
|
-
import { dirname, isAbsolute, join, posix, relative, resolve } from 'node:path';
|
|
4
|
+
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
7
7
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
8
8
|
import { parse as parseToml } from 'smol-toml';
|
|
9
|
-
import {
|
|
9
|
+
import { parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
10
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
10
11
|
import { CARGO_CLOSURE_INPUT, cargoClosureInputs, indexedCargoManifests, resolveCargoClosureSource, } from './cargo-closure-input.js';
|
|
11
|
-
import { CARGO_TOOLCHAIN_NAMED_INPUT, CARGO_TOOLCHAIN_PIN_INPUTS } from './cargo-toolchain-policy.js';
|
|
12
|
-
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_COMPILE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestPackageTargetName, createCargoInputsCache, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, } from './cargo-workspace.js';
|
|
12
|
+
import { CARGO_TOOLCHAIN_NAMED_INPUT, CARGO_TOOLCHAIN_PIN_INPUTS, cargoRuntimeInput, } from './cargo-toolchain-policy.js';
|
|
13
|
+
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_COMPILE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, serialTestGroups, } from './cargo-workspace.js';
|
|
13
14
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_FROZEN_PREFIX, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, } from './cross-check-policy.js';
|
|
14
15
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
15
16
|
import { EXTRACTED_BINARIES_METADATA, EXTRACTED_CARGO_METADATA, EXTRACTED_TARGET_DIR, NEXTEST_EXTRACT_BIN, } from './nextest-extraction.js';
|
|
17
|
+
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
16
18
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
19
|
+
import { postTasksExecution, preTasksExecution } from './task-results.js';
|
|
20
|
+
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
17
21
|
import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from './workspace-config-policy.js';
|
|
18
|
-
|
|
22
|
+
import { globIndexedFiles } from './workspace-index.js';
|
|
23
|
+
export { CARGO_TEST_COMPILE_TARGET, postTasksExecution, preTasksExecution };
|
|
19
24
|
/** Makes a version live and proves it answers; never cached. */
|
|
20
25
|
export const DEPLOY_TARGET = 'deploy';
|
|
21
26
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
22
27
|
export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
23
28
|
/** The workspace-wide manifests a release rewrites: the version of every member, and the lockfile mirror of it. */
|
|
24
29
|
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
|
25
|
-
/** Installed
|
|
26
|
-
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
30
|
+
/** Installed patch bytes and pins affect the compiler; Markdown explains them but is not loaded. */
|
|
31
|
+
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*', '!{workspaceRoot}/patches/**/*.md'];
|
|
27
32
|
/**
|
|
28
33
|
* The workspace's own base config, hashed for every TypeScript task whether or
|
|
29
34
|
* not this project's chain reaches it: it is where a workspace puts the options
|
|
@@ -31,6 +36,22 @@ const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
|
31
36
|
* its own has no chain to reach it with.
|
|
32
37
|
*/
|
|
33
38
|
const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
39
|
+
/**
|
|
40
|
+
* The native compiler a typecheck runs, apart from the one emit runs: devenv.smoo.nix builds it
|
|
41
|
+
* from a pinned source revision and exports its path. The typecheck targets run it directly,
|
|
42
|
+
* not through ttsc: ttsc auto-loads a dependency's transform plugin (typia) and then checks
|
|
43
|
+
* inside that plugin's host, which links ttsc's own compiler and never runs the pinned one.
|
|
44
|
+
* Transform diagnostics stay enforced where the transform runs: for the lib program in `tsc-js`'s
|
|
45
|
+
* emit, for test files when the test runner transforms them. A test file no test executes has
|
|
46
|
+
* its types checked here but its transform calls checked nowhere. Hashed by the store path,
|
|
47
|
+
* which carries the revision, so a compiler bump misses the cache. The command refuses an unset
|
|
48
|
+
* variable: falling back would check with another compiler under the same key.
|
|
49
|
+
*/
|
|
50
|
+
const TYPECHECK_COMPILER_ENV = 'SMOO_TYPECHECK_TSC';
|
|
51
|
+
const TYPECHECK_COMPILER_INPUT = { env: TYPECHECK_COMPILER_ENV };
|
|
52
|
+
function typecheckCommand(args) {
|
|
53
|
+
return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
|
|
54
|
+
}
|
|
34
55
|
/**
|
|
35
56
|
* The two release-rewritten files hashed by field instead of by byte, for a
|
|
36
57
|
* check that only reads them.
|
|
@@ -40,9 +61,18 @@ const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
|
40
61
|
* name, version and dependency specifiers — and every one of those is already
|
|
41
62
|
* hashed from the member's own `package.json`. Dropping that section keeps the
|
|
42
63
|
* resolution table, which is the reason the lockfile is an input at all.
|
|
64
|
+
*
|
|
65
|
+
* The root manifest also drops `scripts`, `smoo` and `nx`. No lint or
|
|
66
|
+
* typecheck reads them: `scripts` are commands a developer runs, `smoo` holds
|
|
67
|
+
* the developer links whose linked bytes reach the hash only through their own
|
|
68
|
+
* inputs, and the root project's `nx` configuration is hashed as that
|
|
69
|
+
* project's configuration. Hashing them made a root `postinstall` edit or a
|
|
70
|
+
* developer-link edit re-key every lint task (74, measured in a consumer
|
|
71
|
+
* workspace). The dependency fields, `overrides`, `patchedDependencies` and
|
|
72
|
+
* `workspaces` stay hashed.
|
|
43
73
|
*/
|
|
44
74
|
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
45
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
75
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
46
76
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
47
77
|
];
|
|
48
78
|
/** A path segment Nx's workspace file map never carries, so a fileset naming it hashes nothing. */
|
|
@@ -220,36 +250,86 @@ const ESLINT_CONFIG_FILES = [
|
|
|
220
250
|
'eslint.config.mts',
|
|
221
251
|
'eslint.config.cts',
|
|
222
252
|
];
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
253
|
+
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
254
|
+
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
255
|
+
/**
|
|
256
|
+
* The JavaScript and TypeScript files of Nx's workspace file index, listed once
|
|
257
|
+
* per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
258
|
+
*
|
|
259
|
+
* The ESLint file list is part of the lint target's command, metadata and
|
|
260
|
+
* inputs, and Nx hashes the whole target configuration into every task that
|
|
261
|
+
* reaches the project. A walk of the tree also listed gitignored generated
|
|
262
|
+
* modules a build had left on disk, so every such task's key depended on
|
|
263
|
+
* whether a build had run in that checkout: one workspace's graph listed them
|
|
264
|
+
* and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
|
|
265
|
+
* Drawing the list from the index makes the plugin and the hasher agree on one
|
|
266
|
+
* file set.
|
|
267
|
+
*/
|
|
268
|
+
async function indexedEslintSources(workspaceRoot) {
|
|
269
|
+
if (!ESLINT_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name))))
|
|
270
|
+
return null;
|
|
271
|
+
return new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB]));
|
|
238
272
|
}
|
|
239
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
|
|
275
|
+
* undeclared `require('typescript')` resolved from its own location: where that lands on the
|
|
276
|
+
* TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
|
|
277
|
+
* graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
|
|
278
|
+
* `sys` this uses, so the resolution is the one this package's manifest promises.
|
|
279
|
+
*/
|
|
280
|
+
function readTestTsConfig(testConfig) {
|
|
281
|
+
const readResult = readConfigFile(testConfig, typescriptSys.readFile);
|
|
282
|
+
return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
|
|
283
|
+
}
|
|
284
|
+
function projectLintCommands(projectRoot, workspaceRoot, eslintSources) {
|
|
240
285
|
const commands = [];
|
|
286
|
+
const inputs = [];
|
|
287
|
+
let eslintFileSet = null;
|
|
241
288
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
242
289
|
const quote = (path) => `'${path.replaceAll("'", "'\"'\"'")}'`;
|
|
243
290
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
244
291
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
245
292
|
}
|
|
246
|
-
if (
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
293
|
+
if (eslintSources !== null) {
|
|
294
|
+
const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
|
|
295
|
+
const sourceFiles = new Set();
|
|
296
|
+
for (const path of eslintSources) {
|
|
297
|
+
if (path.startsWith(sourcePrefix) &&
|
|
298
|
+
!path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)) {
|
|
299
|
+
sourceFiles.add(path);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
303
|
+
if (existsSync(testConfig)) {
|
|
304
|
+
// A test program can live anywhere the declaration selects, not just src.
|
|
305
|
+
// Use the compiler's file set and the existing declaration-chain hasher,
|
|
306
|
+
// so inherited includes and files outside this project keep their keys.
|
|
307
|
+
const program = readTestTsConfig(testConfig);
|
|
308
|
+
const errors = program.errors.filter(({ code }) => code !== 18003);
|
|
309
|
+
if (errors.length > 0) {
|
|
310
|
+
throw new Error(`${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`);
|
|
311
|
+
}
|
|
312
|
+
inputs.push('{projectRoot}/tsconfig.test.json');
|
|
313
|
+
for (const file of program.fileNames) {
|
|
314
|
+
const path = relative(workspaceRoot, file).split(sep).join('/');
|
|
315
|
+
if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
|
|
316
|
+
throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
|
|
317
|
+
}
|
|
318
|
+
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
319
|
+
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
320
|
+
if (!eslintSources.has(path) || path.split('/').some(isNonSourceDirectory))
|
|
321
|
+
continue;
|
|
322
|
+
sourceFiles.add(path);
|
|
323
|
+
inputs.push(`{workspaceRoot}/${path}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (sourceFiles.size > 0) {
|
|
327
|
+
const files = [...sourceFiles].sort();
|
|
328
|
+
eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
|
|
329
|
+
commands.push(eslintFileSet.command);
|
|
250
330
|
}
|
|
251
331
|
}
|
|
252
|
-
return commands;
|
|
332
|
+
return { commands, inputs: [...new Set(inputs)], eslintFileSet };
|
|
253
333
|
}
|
|
254
334
|
function napiPlatform(platform, architecture) {
|
|
255
335
|
const targetFamily = platform === 'darwin' ? 'macos' : platform === 'linux' ? 'linux' : null;
|
|
@@ -319,21 +399,13 @@ const CARGO_INPUTS = [
|
|
|
319
399
|
// build really reads is the package's `napi` block (binary name, targets) and
|
|
320
400
|
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
|
|
321
401
|
const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
|
|
322
|
-
const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
|
|
323
|
-
'{workspaceRoot}/**/*.rs',
|
|
324
|
-
'{workspaceRoot}/**/Cargo.toml',
|
|
325
|
-
'{workspaceRoot}/Cargo.lock',
|
|
326
|
-
'{workspaceRoot}/**/.cargo/config.toml',
|
|
327
|
-
'{workspaceRoot}/scripts/*.sh',
|
|
328
|
-
'!{workspaceRoot}/**/target/**',
|
|
329
|
-
];
|
|
330
402
|
// The toolchain half of a cargo task's identity lives in its own module
|
|
331
403
|
// because `smoo monorepo validate` reads the same two constants to refuse a
|
|
332
404
|
// declaration that drops it. See cargo-toolchain-policy.ts for why it is the
|
|
333
405
|
// declared pin and not the ambient environment.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return
|
|
406
|
+
/** A runtime input that changes when the file's bytes do: the runtime hashes the file itself. */
|
|
407
|
+
function fileHashInput(path) {
|
|
408
|
+
return runtimeInput(`bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' ${shellWord(path)}`);
|
|
337
409
|
}
|
|
338
410
|
/**
|
|
339
411
|
* One shell command that runs `steps` in order and stops at the first failure.
|
|
@@ -379,9 +451,11 @@ function napiInputs(projectRoot, repoRooted) {
|
|
|
379
451
|
// by its path from there whichever way the Cargo invocation is rooted.
|
|
380
452
|
const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
|
|
381
453
|
return [
|
|
382
|
-
|
|
454
|
+
CARGO_CLOSURE_INPUT,
|
|
455
|
+
'{projectRoot}/scripts/*.sh',
|
|
456
|
+
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
383
457
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
384
|
-
|
|
458
|
+
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
385
459
|
{ externalDependencies: ['@napi-rs/cli'] },
|
|
386
460
|
];
|
|
387
461
|
}
|
|
@@ -439,8 +513,7 @@ const CARGO_PROFILE_OUTPUT_DIR = { dev: 'debug', release: 'release' };
|
|
|
439
513
|
function cargoWasmTargetDirectory(projectRoot, config, repoRooted, cargoWorkspace) {
|
|
440
514
|
const cwd = repoRooted ? '.' : projectRoot;
|
|
441
515
|
const crateDir = posix.join(cwd, posix.dirname(config.manifestPath));
|
|
442
|
-
const owner = cargoWorkspace
|
|
443
|
-
cargoWorkspace.packages.some((plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir)
|
|
516
|
+
const owner = cargoWorkspace?.packages.some((plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir)
|
|
444
517
|
? cargoWorkspace.projectRoot
|
|
445
518
|
: crateDir;
|
|
446
519
|
return posix.relative(cwd, posix.join(owner, 'target'));
|
|
@@ -457,7 +530,9 @@ function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirec
|
|
|
457
530
|
executor: 'nx:run-commands',
|
|
458
531
|
cache: true,
|
|
459
532
|
dependsOn: ['^build'],
|
|
460
|
-
inputs: repoRooted
|
|
533
|
+
inputs: repoRooted
|
|
534
|
+
? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
|
|
535
|
+
: CARGO_OUTPUT_INPUTS,
|
|
461
536
|
outputs: [`{projectRoot}/${config.outputDirectory}`],
|
|
462
537
|
options: {
|
|
463
538
|
command: buildCommand('dev'),
|
|
@@ -572,9 +647,15 @@ function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
|
572
647
|
function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archiveInputs) {
|
|
573
648
|
const { target: triple, cargo } = crossTarget;
|
|
574
649
|
const archiveFile = cargoCrossTestArchiveFile(triple);
|
|
650
|
+
const archiveCommand = sequence([
|
|
651
|
+
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
652
|
+
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
653
|
+
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
654
|
+
]);
|
|
655
|
+
const archiveExecutor = 'nx:run-commands';
|
|
575
656
|
return {
|
|
576
657
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
577
|
-
executor:
|
|
658
|
+
executor: archiveExecutor,
|
|
578
659
|
cache: true,
|
|
579
660
|
// The toolchain inputs every cached cargo target carries, plus the
|
|
580
661
|
// declared driver's own bytes. Those toolchain inputs are attached
|
|
@@ -586,21 +667,18 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
586
667
|
// must never hash equal to the same sources built under another. The
|
|
587
668
|
// declared driver is hashed by its own bytes; nothing samples the shell
|
|
588
669
|
// that supplies it, which is why this hash is the same bare and inside
|
|
589
|
-
// the cross profile.
|
|
670
|
+
// the cross profile. For the same reason it names its npm packages here.
|
|
590
671
|
inputs: [
|
|
591
672
|
...archiveInputs,
|
|
592
673
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
593
674
|
...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
|
|
594
675
|
cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
|
|
676
|
+
{ externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand) },
|
|
595
677
|
],
|
|
596
678
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
597
679
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
598
680
|
options: {
|
|
599
|
-
command:
|
|
600
|
-
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
601
|
-
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
602
|
-
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
603
|
-
]),
|
|
681
|
+
command: archiveCommand,
|
|
604
682
|
cwd: projectRoot,
|
|
605
683
|
// `CARGO` is cargo's own driver variable and the only seam nextest
|
|
606
684
|
// offers: it shells out to `$CARGO metadata` and
|
|
@@ -621,7 +699,7 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
621
699
|
command: `cargo-nextest nextest run --archive-file ${archiveFile} --workspace-remap . ` +
|
|
622
700
|
`--no-tests=pass --user-config-file none ${toolConfig}`,
|
|
623
701
|
cwd: projectRoot,
|
|
624
|
-
|
|
702
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
625
703
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
626
704
|
},
|
|
627
705
|
},
|
|
@@ -636,12 +714,39 @@ function createCargoTestTarget(projectRoot) {
|
|
|
636
714
|
options: {
|
|
637
715
|
command: cargoFrozen('test --workspace'),
|
|
638
716
|
cwd: projectRoot,
|
|
639
|
-
|
|
717
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
640
718
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
641
719
|
},
|
|
642
720
|
};
|
|
643
721
|
}
|
|
644
722
|
const PLUGIN_NEXTEST_CONFIG = fileURLToPath(new URL('../nextest.toml', import.meta.url));
|
|
723
|
+
/**
|
|
724
|
+
* The nextest run-wrapper a serial group names to bound each test's code time.
|
|
725
|
+
* The group's target hashes it, so changing the wrapper reruns the group.
|
|
726
|
+
*/
|
|
727
|
+
const PLUGIN_NEXTEST_CODE_BOUND = fileURLToPath(new URL('../src/nextest-code-bound.ts', import.meta.url));
|
|
728
|
+
const PLUGIN_PACKAGE = '@smoothbricks/nx-plugin';
|
|
729
|
+
/**
|
|
730
|
+
* Whether this plugin runs as an installed npm package. Inside the repository
|
|
731
|
+
* that develops it, it is a workspace project, and Nx refuses a workspace
|
|
732
|
+
* project named as an `externalDependencies` entry.
|
|
733
|
+
*/
|
|
734
|
+
const PLUGIN_IS_INSTALLED = fileURLToPath(new URL('..', import.meta.url))
|
|
735
|
+
.split(sep)
|
|
736
|
+
.includes('node_modules');
|
|
737
|
+
/**
|
|
738
|
+
* The npm packages a cached cargo target runs, for its `externalDependencies`.
|
|
739
|
+
* Cargo runs none. A target this plugin's executor runs, or whose command reads
|
|
740
|
+
* the installed plugin's files (the nextest tool config, the archive
|
|
741
|
+
* extractor), runs the plugin. Without the input Nx keys every task whose
|
|
742
|
+
* executor is not an `@nx/` one on every package in the lockfile, so a
|
|
743
|
+
* lockfile-only commit re-ran every cargo verdict.
|
|
744
|
+
*/
|
|
745
|
+
export function cargoCommandNpmPackages(target, commandText, installed = PLUGIN_IS_INSTALLED) {
|
|
746
|
+
const runsPlugin = target.executor?.startsWith(`${PLUGIN_PACKAGE}:`) === true ||
|
|
747
|
+
commandText.includes(`node_modules/${PLUGIN_PACKAGE}/`);
|
|
748
|
+
return installed && runsPlugin ? [PLUGIN_PACKAGE] : [];
|
|
749
|
+
}
|
|
645
750
|
function versionlessManifestPolicy(context) {
|
|
646
751
|
if (!supportsJsonInputs())
|
|
647
752
|
return null;
|
|
@@ -687,8 +792,10 @@ function createNodesHandler(hostPlatform) {
|
|
|
687
792
|
const results = [];
|
|
688
793
|
const errors = [];
|
|
689
794
|
let cargoWorkspaces;
|
|
795
|
+
let eslintSources;
|
|
690
796
|
try {
|
|
691
|
-
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot);
|
|
797
|
+
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
|
|
798
|
+
eslintSources = await indexedEslintSources(context.workspaceRoot);
|
|
692
799
|
}
|
|
693
800
|
catch (error) {
|
|
694
801
|
throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
|
|
@@ -708,7 +815,7 @@ function createNodesHandler(hostPlatform) {
|
|
|
708
815
|
}
|
|
709
816
|
results.push([
|
|
710
817
|
packageJsonPath,
|
|
711
|
-
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, cargoWorkspaces, versionless),
|
|
818
|
+
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, cargoWorkspaces, eslintSources, versionless),
|
|
712
819
|
]);
|
|
713
820
|
}
|
|
714
821
|
catch (error) {
|
|
@@ -738,7 +845,7 @@ function isBuildOutputPackageJson(packageJsonPath) {
|
|
|
738
845
|
const normalized = `/${packageJsonPath.replaceAll('\\', '/')}`;
|
|
739
846
|
return BUILD_OUTPUT_SEGMENTS.some((segment) => normalized.includes(segment));
|
|
740
847
|
}
|
|
741
|
-
export default { createNodesV2 };
|
|
848
|
+
export default { createNodesV2, postTasksExecution, preTasksExecution };
|
|
742
849
|
function packageBinOutputs(packageJson, packageJsonPath) {
|
|
743
850
|
if (packageJson.bin === undefined) {
|
|
744
851
|
return [];
|
|
@@ -800,7 +907,7 @@ const WRANGLER_CONFIG_FILES = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml
|
|
|
800
907
|
* `--stage` refuses it, which is the failure we want at the boundary.
|
|
801
908
|
*/
|
|
802
909
|
const WRANGLER_DEPLOY_COMMAND = 'smoo wrangler deploy-stage --stage {args.stage}';
|
|
803
|
-
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, cargoWorkspaces, versionless) {
|
|
910
|
+
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, cargoWorkspaces, eslintSources, versionless) {
|
|
804
911
|
const projectRoot = dirname(packageJsonPath);
|
|
805
912
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
806
913
|
const packageJson = await readPackageJson(join(workspaceRoot, packageJsonPath));
|
|
@@ -874,11 +981,17 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
874
981
|
targets.typecheck = {
|
|
875
982
|
executor: 'nx:run-commands',
|
|
876
983
|
cache: true,
|
|
877
|
-
inputs: [
|
|
984
|
+
inputs: [
|
|
985
|
+
selfProduction,
|
|
986
|
+
dependencyProduction,
|
|
987
|
+
...checkInputs,
|
|
988
|
+
TYPECHECK_COMPILER_INPUT,
|
|
989
|
+
'{projectRoot}/tsconfig.lib.json',
|
|
990
|
+
],
|
|
878
991
|
outputs: [],
|
|
879
992
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
880
993
|
options: {
|
|
881
|
-
command: '
|
|
994
|
+
command: typecheckCommand('-p tsconfig.lib.json --noEmit'),
|
|
882
995
|
cwd: projectRoot,
|
|
883
996
|
},
|
|
884
997
|
};
|
|
@@ -887,10 +1000,16 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
887
1000
|
targets['typecheck-tests'] = {
|
|
888
1001
|
executor: 'nx:run-commands',
|
|
889
1002
|
cache: true,
|
|
890
|
-
inputs: [
|
|
1003
|
+
inputs: [
|
|
1004
|
+
selfDefault,
|
|
1005
|
+
dependencyProduction,
|
|
1006
|
+
...checkInputs,
|
|
1007
|
+
TYPECHECK_COMPILER_INPUT,
|
|
1008
|
+
'{projectRoot}/tsconfig.test.json',
|
|
1009
|
+
],
|
|
891
1010
|
dependsOn: ['typecheck'],
|
|
892
1011
|
options: {
|
|
893
|
-
command: '
|
|
1012
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit'),
|
|
894
1013
|
cwd: projectRoot,
|
|
895
1014
|
},
|
|
896
1015
|
};
|
|
@@ -898,7 +1017,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
898
1017
|
executor: 'nx:run-commands',
|
|
899
1018
|
continuous: true,
|
|
900
1019
|
options: {
|
|
901
|
-
command: '
|
|
1020
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit --watch'),
|
|
902
1021
|
cwd: projectRoot,
|
|
903
1022
|
},
|
|
904
1023
|
};
|
|
@@ -1001,7 +1120,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1001
1120
|
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
1002
1121
|
];
|
|
1003
1122
|
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
1004
|
-
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(
|
|
1123
|
+
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot));
|
|
1005
1124
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
1006
1125
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
1007
1126
|
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
|
|
@@ -1010,8 +1129,21 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1010
1129
|
// binaries whichever machine they are for, so a change that invalidates
|
|
1011
1130
|
// the host archive must invalidate every cross one.
|
|
1012
1131
|
for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
|
|
1013
|
-
Object.assign(targets, createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(
|
|
1132
|
+
Object.assign(targets, createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), crossTarget, [
|
|
1133
|
+
...workspaceCargoInputs,
|
|
1134
|
+
`{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
|
|
1135
|
+
]));
|
|
1136
|
+
}
|
|
1137
|
+
// A serial group's filter can span members, so no single crate owns it. The root
|
|
1138
|
+
// owns each group's runner beside the archive it executes, and gives it the inputs
|
|
1139
|
+
// of exactly the members its filter can select from (`filterScope`): a group scoped
|
|
1140
|
+
// to its packages reruns only when their sources or local dependencies change,
|
|
1141
|
+
// and an unscoped one hashes every member, as the archive itself does.
|
|
1142
|
+
for (const group of cargoWorkspace.serialGroups) {
|
|
1143
|
+
targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(cargoWorkspace, await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)), group);
|
|
1014
1144
|
}
|
|
1145
|
+
// Every project's crate pieces. The serial groups' runners are the gate's (`test`, below), so
|
|
1146
|
+
// `cargo-test` is the ordinary suite alone and a run of it never reaches a group's real-image tests.
|
|
1015
1147
|
const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) => plan.pieces.map((piece) => cargoTargetDependency(projectName, {
|
|
1016
1148
|
projectName: plan.package.projectName,
|
|
1017
1149
|
targetName: piece.targetName,
|
|
@@ -1075,13 +1207,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1075
1207
|
cwd: cargoWorkspaceRoot,
|
|
1076
1208
|
},
|
|
1077
1209
|
};
|
|
1078
|
-
if (!targets.test && !('test' in declaredTargets) && typeof packageJson.scripts?.test !== 'string') {
|
|
1079
|
-
targets.test = {
|
|
1080
|
-
executor: 'nx:noop',
|
|
1081
|
-
cache: true,
|
|
1082
|
-
dependsOn: [CARGO_TEST_TARGET],
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
1210
|
// Mutation runs are minutes-to-hours: never cached, never part of build/lint.
|
|
1086
1211
|
// CI runs these per-PR via `cargo mutants --in-diff` (see mutants.toml docs).
|
|
1087
1212
|
targets.mutation = {
|
|
@@ -1107,6 +1232,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1107
1232
|
}
|
|
1108
1233
|
if (cargoWorkspace) {
|
|
1109
1234
|
const packageTargetNames = await addCargoTestTargets(targets, projectName, projectRoot, workspaceRoot, cargoWorkspace);
|
|
1235
|
+
// Serial-group runners belong to the workspace root, outside inferred ordinary tests. Explicit repository
|
|
1236
|
+
// aggregates can reach them; their own inputs decide whether each runner executes or replays from cache.
|
|
1110
1237
|
if (!isCargoWorkspaceRoot) {
|
|
1111
1238
|
targets[CARGO_TEST_TARGET] = {
|
|
1112
1239
|
executor: 'nx:noop',
|
|
@@ -1135,6 +1262,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1135
1262
|
targets.test = {
|
|
1136
1263
|
executor: 'nx:noop',
|
|
1137
1264
|
cache: true,
|
|
1265
|
+
// Ordinary tests never infer an edge to a serial group; host aggregates are explicit repository config.
|
|
1138
1266
|
dependsOn: [CARGO_TEST_TARGET],
|
|
1139
1267
|
};
|
|
1140
1268
|
}
|
|
@@ -1225,6 +1353,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1225
1353
|
}
|
|
1226
1354
|
// Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
|
|
1227
1355
|
// directories. Resolve tool versions from the command's actual directory.
|
|
1356
|
+
// Name the npm packages the command runs (cargoCommandNpmPackages) unless
|
|
1357
|
+
// the target already does.
|
|
1228
1358
|
for (const [name, target] of Object.entries(targets)) {
|
|
1229
1359
|
const text = targetCommandText(target);
|
|
1230
1360
|
if (!text.includes(CARGO_FROZEN_PREFIX))
|
|
@@ -1238,10 +1368,13 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1238
1368
|
: text.includes('nextest ')
|
|
1239
1369
|
? ' && cargo nextest --version'
|
|
1240
1370
|
: '';
|
|
1371
|
+
const inputs = target.inputs ?? CARGO_INPUTS;
|
|
1372
|
+
const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input);
|
|
1241
1373
|
target.inputs = [
|
|
1242
|
-
...
|
|
1374
|
+
...inputs,
|
|
1243
1375
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
1244
1376
|
cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
|
|
1377
|
+
...(namesPackages ? [] : [{ externalDependencies: cargoCommandNpmPackages(target, text) }]),
|
|
1245
1378
|
];
|
|
1246
1379
|
}
|
|
1247
1380
|
// `build` warms the test executables' compile; in a nested package that names
|
|
@@ -1259,12 +1392,17 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1259
1392
|
// A crate whose project also builds the debug cdylib runs its tests after
|
|
1260
1393
|
// that build: the tests dlopen what `napi-debug` writes into `target/debug`,
|
|
1261
1394
|
// and an archived test binary still loads it from this tree.
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1395
|
+
const runners = [
|
|
1396
|
+
...cargoPackagePlans.flatMap((plan) => plan.pieces.map((piece) => piece.targetName)),
|
|
1397
|
+
// The root owns the serial groups' runners, so they take its build as its pieces do.
|
|
1398
|
+
...(ownsCargoWorkspaceTargets
|
|
1399
|
+
? cargoWorkspace.serialGroups.map((group) => cargoTestGroupTargetName(group.group))
|
|
1400
|
+
: []),
|
|
1401
|
+
];
|
|
1402
|
+
for (const name of runners) {
|
|
1403
|
+
const target = targets[name];
|
|
1404
|
+
if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
|
|
1405
|
+
target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
|
|
1268
1406
|
}
|
|
1269
1407
|
}
|
|
1270
1408
|
}
|
|
@@ -1426,16 +1564,37 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1426
1564
|
targets['typecheck-tests'].dependsOn = ['build'];
|
|
1427
1565
|
}
|
|
1428
1566
|
}
|
|
1429
|
-
|
|
1567
|
+
// A Bun suite that `--shard` splits and a `--timings` manifest balances gets a
|
|
1568
|
+
// check, which `lint` depends on, that the manifest names every file the
|
|
1569
|
+
// shards run: Bun charges an unnamed file the median, and unnamed files
|
|
1570
|
+
// cluster into one shard. Uncached, because Bun's discovery also finds
|
|
1571
|
+
// gitignored files that no Nx input keys, and the check only walks a tree.
|
|
1572
|
+
const sharded = timingsShardedSuite(projectRoot, declaredTargets);
|
|
1573
|
+
if (!sharded.ok) {
|
|
1574
|
+
throw new Error(`${packageJsonPath}: ${sharded.error}`);
|
|
1575
|
+
}
|
|
1576
|
+
if (sharded.suite !== null) {
|
|
1577
|
+
targets[SHARD_TIMINGS_TARGET] = {
|
|
1578
|
+
executor: SHARD_TIMINGS_EXECUTOR,
|
|
1579
|
+
cache: false,
|
|
1580
|
+
outputs: [],
|
|
1581
|
+
options: { cwd: sharded.suite.cwd, args: sharded.suite.args },
|
|
1582
|
+
};
|
|
1583
|
+
validationTargets.push(SHARD_TIMINGS_TARGET);
|
|
1584
|
+
}
|
|
1585
|
+
const { commands: lintCommands, inputs: lintProgramInputs, eslintFileSet, } = projectLintCommands(projectRoot, workspaceRoot, eslintSources);
|
|
1430
1586
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
1431
1587
|
targets.lint = {
|
|
1432
1588
|
executor: lintCommands.length > 0 ? 'nx:run-commands' : 'nx:noop',
|
|
1589
|
+
...(eslintFileSet === null ? {} : { metadata: { eslintFileSet } }),
|
|
1433
1590
|
cache: true,
|
|
1434
1591
|
dependsOn: validationTargets,
|
|
1435
1592
|
outputs: [],
|
|
1436
1593
|
inputs: [
|
|
1437
1594
|
selfDefault,
|
|
1595
|
+
dependencyProduction,
|
|
1438
1596
|
...checkInputs,
|
|
1597
|
+
...lintProgramInputs,
|
|
1439
1598
|
...[...BIOME_CONFIG_FILES, ...ESLINT_CONFIG_FILES].flatMap((name) => [
|
|
1440
1599
|
`{workspaceRoot}/${name}`,
|
|
1441
1600
|
`{projectRoot}/${name}`,
|
|
@@ -1780,8 +1939,8 @@ function createNapiTestTarget(projectRoot, hasDedicatedBunfig) {
|
|
|
1780
1939
|
// Routes the package's native loader to the napi-debug artifact under
|
|
1781
1940
|
// .cache/native-debug instead of the packaged dist/native tree.
|
|
1782
1941
|
env: { NAPI_DEBUG_ADDON: '1' },
|
|
1783
|
-
|
|
1784
|
-
killAfterMs:
|
|
1942
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
1943
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
1785
1944
|
},
|
|
1786
1945
|
};
|
|
1787
1946
|
}
|
|
@@ -1861,7 +2020,7 @@ function cargoTargetDependency(currentProjectName, target) {
|
|
|
1861
2020
|
? target.targetName
|
|
1862
2021
|
: { projects: [target.projectName], target: target.targetName };
|
|
1863
2022
|
}
|
|
1864
|
-
async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
2023
|
+
async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatform) {
|
|
1865
2024
|
const projects = [];
|
|
1866
2025
|
for (const packageJsonPath of packageJsonPaths) {
|
|
1867
2026
|
if (isManagedPackageJsonSource(packageJsonPath) || isBuildOutputPackageJson(packageJsonPath)) {
|
|
@@ -1891,16 +2050,25 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1891
2050
|
})), projects).map((pkg) => ({ ...pkg, dir: posix.relative(rootProject.root, pkg.dir) || '.' }));
|
|
1892
2051
|
const packages = [];
|
|
1893
2052
|
const exceptional = exceptionalTestFilter(PLUGIN_NEXTEST_CONFIG);
|
|
2053
|
+
// A serial group runs only where its declared cfg holds, macOS. Elsewhere it is not inferred and
|
|
2054
|
+
// no piece excludes its tests: nextest does not apply the group there, so the pieces select them.
|
|
2055
|
+
const serialGroups = hostPlatform?.targetFamily === 'macos'
|
|
2056
|
+
? serialTestGroups(join(workspaceRoot, rootProject.root, NEXTEST_REPO_CONFIG_PATH))
|
|
2057
|
+
: [];
|
|
2058
|
+
// A serial group's tests belong to that group's one runner, so every per-crate
|
|
2059
|
+
// piece excludes them: each test is selected by exactly one target.
|
|
2060
|
+
const serialExclusion = serialGroups.length === 0 ? null : serialGroups.map((group) => group.filter).join(' or ');
|
|
2061
|
+
const notSerial = serialExclusion === null ? [] : [`not (${serialExclusion})`];
|
|
1894
2062
|
for (const pkg of attributed) {
|
|
1895
2063
|
const pieces = [];
|
|
1896
2064
|
const sharded = pkg.testShards > 1;
|
|
1897
2065
|
const pin = sharded && exceptional !== null ? exceptional : null;
|
|
1898
|
-
const
|
|
2066
|
+
const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
|
|
1899
2067
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
1900
2068
|
const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
|
|
1901
2069
|
pieces.push({
|
|
1902
2070
|
extra: sharded ? ` --partition hash:${index}/${pkg.testShards}` : '',
|
|
1903
|
-
selector:
|
|
2071
|
+
selector: ordinary,
|
|
1904
2072
|
targetName,
|
|
1905
2073
|
});
|
|
1906
2074
|
}
|
|
@@ -1908,7 +2076,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1908
2076
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
1909
2077
|
pieces.push({
|
|
1910
2078
|
extra: ` --partition hash:${index}/${pkg.testShards}`,
|
|
1911
|
-
selector: `package(${pkg.name}) and (${pin})`,
|
|
2079
|
+
selector: [`package(${pkg.name}) and (${pin})`, ...notSerial].join(' and '),
|
|
1912
2080
|
targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
|
|
1913
2081
|
});
|
|
1914
2082
|
}
|
|
@@ -1920,6 +2088,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1920
2088
|
rootProjectName: rootProject.name,
|
|
1921
2089
|
projectRoot: rootProject.root,
|
|
1922
2090
|
inputsCache: createCargoInputsCache(),
|
|
2091
|
+
serialGroups,
|
|
1923
2092
|
});
|
|
1924
2093
|
}
|
|
1925
2094
|
if (found.length === 0)
|
|
@@ -1929,7 +2098,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1929
2098
|
const indexedManifests = indexedCargoManifests(workspaceRoot);
|
|
1930
2099
|
return Promise.all(found.map(async (workspace) => ({
|
|
1931
2100
|
...workspace,
|
|
1932
|
-
closureSource: await resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests),
|
|
2101
|
+
closureSource: await resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests, workspace.inputsCache.compiledInFiles),
|
|
1933
2102
|
})));
|
|
1934
2103
|
}
|
|
1935
2104
|
/**
|
|
@@ -1962,9 +2131,11 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1962
2131
|
* from `--archive-file` is the Rust standard library directory: nextest has no
|
|
1963
2132
|
* flag to remap it, so a run uses the producing toolchain's own sysroot rather
|
|
1964
2133
|
* than the archived copy of it — the same toolchain, because the archive's hash
|
|
1965
|
-
* covers the toolchain pin. The extraction lives
|
|
1966
|
-
* in an Nx output: it
|
|
1967
|
-
* outputs
|
|
2134
|
+
* covers the toolchain pin. The extraction lives in Cargo's own target
|
|
2135
|
+
* directory (`<target_directory>/nextest-extracted`), never in an Nx output: it
|
|
2136
|
+
* is a multi-GB tree for a cached verdict that has no outputs, rebuilt from the
|
|
2137
|
+
* archive like the rest of the build tree, and a checkout that keeps its build
|
|
2138
|
+
* state off its source tree keeps the extraction there with it.
|
|
1968
2139
|
*
|
|
1969
2140
|
* `--workspace-remap .` is not cosmetic. An archive records the ABSOLUTE paths
|
|
1970
2141
|
* of the tree that produced it; without the remap, a restored archive hands
|
|
@@ -1984,9 +2155,9 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1984
2155
|
* happened to fall.
|
|
1985
2156
|
*
|
|
1986
2157
|
* The two filtersets are exact complements, so their union is the crate whatever
|
|
1987
|
-
* either one matches. Every piece uses `--no-
|
|
1988
|
-
* member may expose no nextest tests, a small suite can
|
|
1989
|
-
* shard empty, and platform-specific exceptions may not exist on this host.
|
|
2158
|
+
* either one matches. Every piece uses `--no-fail-fast`, so one failing test does not stop the rest of its
|
|
2159
|
+
* piece, and `--no-tests=pass`: a valid workspace member may expose no nextest tests, a small suite can
|
|
2160
|
+
* leave a declared hash shard empty, and platform-specific exceptions may not exist on this host.
|
|
1990
2161
|
* Manifest discovery proves the package exists and generates the selector from
|
|
1991
2162
|
* its Cargo name, so accepting an empty run cannot hide a misspelled package.
|
|
1992
2163
|
*
|
|
@@ -2001,65 +2172,126 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
2001
2172
|
*/
|
|
2002
2173
|
async function addCargoTestTargets(targets, currentProjectName, projectRoot, workspaceRoot, workspace) {
|
|
2003
2174
|
const targetNames = [];
|
|
2004
|
-
const toolConfig = nextestToolConfigArg(workspaceRoot, workspace.projectRoot, PLUGIN_NEXTEST_CONFIG);
|
|
2005
|
-
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2006
|
-
const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
|
|
2007
|
-
const reuseExtraction = `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2008
|
-
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2009
|
-
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2010
2175
|
for (const plan of workspace.packages) {
|
|
2011
2176
|
if (plan.package.projectRoot !== projectRoot) {
|
|
2012
2177
|
continue;
|
|
2013
2178
|
}
|
|
2014
|
-
|
|
2015
|
-
// `{projectRoot}` glob hashes only files this project owns, and sibling
|
|
2016
|
-
// manifests belong to whichever nested project holds them.
|
|
2017
|
-
const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
|
|
2018
|
-
// A workspace nextest build unifies features across every selected member.
|
|
2019
|
-
// A sibling manifest can therefore change this crate's tests without being
|
|
2020
|
-
// a path dependency. Track those manifests, not unrelated sibling sources.
|
|
2021
|
-
//
|
|
2022
|
-
// The repository's own nextest config layers OVER the plugin's tool config,
|
|
2023
|
-
// so it decides timeouts, groups and archive contents: a cached verdict that
|
|
2024
|
-
// ignored it would survive the change that invalidates it.
|
|
2025
|
-
const inputs = [
|
|
2026
|
-
...new Set([
|
|
2027
|
-
...(await cargoPackageTestInputs({
|
|
2028
|
-
workspaceRoot,
|
|
2029
|
-
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2030
|
-
memberDir: plan.package.dir,
|
|
2031
|
-
cache: workspace.inputsCache,
|
|
2032
|
-
})),
|
|
2033
|
-
...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
|
|
2034
|
-
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2035
|
-
]),
|
|
2036
|
-
{
|
|
2037
|
-
runtime: `bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' '${PLUGIN_NEXTEST_CONFIG.replaceAll("'", "'\"'\"'")}'`,
|
|
2038
|
-
},
|
|
2039
|
-
];
|
|
2179
|
+
const inputs = await cargoTestRunnerInputs(workspaceRoot, workspace, [plan.package.dir]);
|
|
2040
2180
|
const archive = cargoTargetDependency(currentProjectName, {
|
|
2041
2181
|
projectName: workspace.rootProjectName,
|
|
2042
2182
|
targetName: CARGO_TEST_ARCHIVE_TARGET,
|
|
2043
2183
|
});
|
|
2044
2184
|
for (const piece of plan.pieces) {
|
|
2045
2185
|
targetNames.push(piece.targetName);
|
|
2046
|
-
targets[piece.targetName] =
|
|
2047
|
-
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2048
|
-
cache: true,
|
|
2049
|
-
inputs,
|
|
2050
|
-
dependsOn: [archive],
|
|
2051
|
-
options: {
|
|
2052
|
-
command: `extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2053
|
-
cargoFrozen(`nextest run ${reuseExtraction} --workspace-remap . -E '${piece.selector}'${piece.extra} --no-tests=pass --user-config-file none ${toolConfig}`),
|
|
2054
|
-
cwd: workspace.projectRoot,
|
|
2055
|
-
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
2056
|
-
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2057
|
-
},
|
|
2058
|
-
};
|
|
2186
|
+
targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
|
|
2059
2187
|
}
|
|
2060
2188
|
}
|
|
2061
2189
|
return targetNames;
|
|
2062
2190
|
}
|
|
2191
|
+
/**
|
|
2192
|
+
* The member directories a serial group's runner hashes: the packages its filter is scoped to,
|
|
2193
|
+
* or every member when it is not. A scope naming a package that is not a member is a config
|
|
2194
|
+
* error, refused rather than hashed as nothing.
|
|
2195
|
+
*/
|
|
2196
|
+
function serialGroupMemberDirs(workspace, group) {
|
|
2197
|
+
if (group.scope.kind === 'workspace') {
|
|
2198
|
+
return workspace.packages.map((plan) => plan.package.dir);
|
|
2199
|
+
}
|
|
2200
|
+
return group.scope.packages.map((name) => {
|
|
2201
|
+
const member = workspace.packages.find((plan) => plan.package.name === name);
|
|
2202
|
+
if (member === undefined) {
|
|
2203
|
+
throw new Error(`test-group "${group.group}" selects package(${name}), which is not a member of the Cargo workspace at ` +
|
|
2204
|
+
`${workspace.projectRoot || '.'}`);
|
|
2205
|
+
}
|
|
2206
|
+
return member.package.dir;
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* The inputs of the runners that select crates from one cargo workspace: the
|
|
2211
|
+
* sources of the crates they select, every member manifest, and the repository's
|
|
2212
|
+
* nextest config.
|
|
2213
|
+
*
|
|
2214
|
+
* Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
|
|
2215
|
+
* `{projectRoot}` glob hashes only files this project owns, and sibling manifests
|
|
2216
|
+
* belong to whichever nested project holds them. A workspace nextest build unifies
|
|
2217
|
+
* features across every selected member, so a sibling manifest can change a crate's
|
|
2218
|
+
* tests without being a path dependency: track those manifests, not unrelated
|
|
2219
|
+
* sibling sources.
|
|
2220
|
+
*
|
|
2221
|
+
* The repository's own nextest config layers OVER the plugin's tool config, so it
|
|
2222
|
+
* decides timeouts, groups and archive contents: a cached verdict that ignored it
|
|
2223
|
+
* would survive the change that invalidates it.
|
|
2224
|
+
*/
|
|
2225
|
+
async function cargoTestRunnerInputs(workspaceRoot, workspace, memberDirs) {
|
|
2226
|
+
const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
|
|
2227
|
+
const sources = await Promise.all(memberDirs.map((memberDir) => cargoPackageTestInputs({
|
|
2228
|
+
workspaceRoot,
|
|
2229
|
+
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2230
|
+
memberDir,
|
|
2231
|
+
cache: workspace.inputsCache,
|
|
2232
|
+
})));
|
|
2233
|
+
return [
|
|
2234
|
+
...new Set([
|
|
2235
|
+
...sources.flat(),
|
|
2236
|
+
...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
|
|
2237
|
+
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2238
|
+
]),
|
|
2239
|
+
fileHashInput(PLUGIN_NEXTEST_CONFIG_PATH),
|
|
2240
|
+
];
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* One `nextest run` over a filterset against the workspace's archive. Every runner of the
|
|
2244
|
+
* workspace builds its command here, so the extraction, reuse-build, tool config and cwd cannot
|
|
2245
|
+
* drift between the per-crate pieces and the serial groups.
|
|
2246
|
+
*/
|
|
2247
|
+
function nextestRunnerCommand(workspace, selector, flags) {
|
|
2248
|
+
const toolConfig = nextestToolConfigArg(workspace.projectRoot);
|
|
2249
|
+
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2250
|
+
const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
|
|
2251
|
+
const reuseExtraction = `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2252
|
+
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2253
|
+
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2254
|
+
return (`extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2255
|
+
cargoFrozen(`nextest run ${reuseExtraction} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`));
|
|
2256
|
+
}
|
|
2257
|
+
/** One per-crate piece: a bounded run of its partition of the archive's tests. */
|
|
2258
|
+
function cargoTestRunnerTarget(workspace, archive, inputs, piece) {
|
|
2259
|
+
return {
|
|
2260
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2261
|
+
cache: true,
|
|
2262
|
+
inputs,
|
|
2263
|
+
dependsOn: [archive],
|
|
2264
|
+
options: {
|
|
2265
|
+
command: nextestRunnerCommand(workspace, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
|
|
2266
|
+
cwd: workspace.projectRoot,
|
|
2267
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2268
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2269
|
+
},
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2272
|
+
/**
|
|
2273
|
+
* A serial group's runner: a nextest run of the group's selection with no partition and no thread
|
|
2274
|
+
* flag, the group being serial because its test-group declares `max-threads = 1`, so it asks for one
|
|
2275
|
+
* CPU token. It is bounded by progress like every test target: a group of slow tests runs as long as
|
|
2276
|
+
* it keeps finishing them. It runs `--no-fail-fast`, so an ordinary failure runs the group's remaining
|
|
2277
|
+
* tests and a failed verdict lists the failed ones, and `--no-tests=fail`, so a filter that selects
|
|
2278
|
+
* nothing fails rather than passing a group that ran no test.
|
|
2279
|
+
*/
|
|
2280
|
+
function cargoTestGroupTarget(workspace, inputs, group) {
|
|
2281
|
+
return {
|
|
2282
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2283
|
+
cache: true,
|
|
2284
|
+
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
|
|
2285
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
2286
|
+
options: {
|
|
2287
|
+
command: nextestRunnerCommand(workspace, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
2288
|
+
cwd: workspace.projectRoot,
|
|
2289
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2290
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2291
|
+
parallelism: 1,
|
|
2292
|
+
},
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2063
2295
|
function hasCargoTargetDependency(dependencies, expected) {
|
|
2064
2296
|
if (typeof expected === 'string') {
|
|
2065
2297
|
return dependencies.includes(expected);
|