@smoothbricks/nx-plugin 0.4.25 → 0.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1078 -98
- package/dist/bin/smoo-nx-bound-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-bound-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-bound-failures.js +31 -0
- package/dist/bin/smoo-nx-cargo-hash.js +28 -3
- package/dist/bin/smoo-nx-exec.js +16 -85
- package/dist/bin/smoo-nx-failures.d.ts +3 -0
- package/dist/bin/smoo-nx-failures.d.ts.map +1 -0
- package/dist/bin/smoo-nx-failures.js +3 -0
- package/dist/bin/smoo-nx-nextest-extract.js +3 -2
- package/dist/bin/smoo-nx-test-walks.d.ts +3 -0
- package/dist/bin/smoo-nx-test-walks.d.ts.map +1 -0
- package/dist/bin/smoo-nx-test-walks.js +34 -0
- package/dist/bounded-test-policy.d.ts +7 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +101 -40
- package/dist/build-state-output-policy.d.ts +25 -0
- package/dist/build-state-output-policy.d.ts.map +1 -0
- package/dist/build-state-output-policy.js +64 -0
- package/dist/cargo-closure-input.d.ts +16 -17
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +37 -44
- package/dist/cargo-dev-profile.d.ts +37 -0
- package/dist/cargo-dev-profile.d.ts.map +1 -0
- package/dist/cargo-dev-profile.js +108 -0
- package/dist/cargo-source-hash.d.ts +50 -8
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +691 -71
- package/dist/cargo-toolchain-policy.d.ts +4 -0
- package/dist/cargo-toolchain-policy.d.ts.map +1 -1
- package/dist/cargo-toolchain-policy.js +5 -0
- package/dist/cargo-workspace.d.ts +108 -12
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +299 -18
- package/dist/cross-check-policy.d.ts +21 -3
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +24 -6
- package/dist/disk-command-policy.d.ts +7 -0
- package/dist/disk-command-policy.d.ts.map +1 -0
- package/dist/disk-command-policy.js +98 -0
- package/dist/ensure-built-receipt.d.ts +25 -0
- package/dist/ensure-built-receipt.d.ts.map +1 -0
- package/dist/ensure-built-receipt.js +261 -0
- package/dist/ensure-built-witness.d.ts +57 -0
- package/dist/ensure-built-witness.d.ts.map +1 -0
- package/dist/ensure-built-witness.js +412 -0
- package/dist/ensure-built.d.ts +213 -12
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +624 -177
- package/dist/eslint-file-set.d.ts +7 -0
- package/dist/eslint-file-set.d.ts.map +1 -0
- package/dist/eslint-file-set.js +12 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts +63 -0
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-pool.js +379 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +82 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -0
- package/dist/executors/bounded-exec/cpu-tokens.js +114 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts +61 -0
- package/dist/executors/bounded-exec/disk-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/disk-lease.js +91 -0
- package/dist/executors/bounded-exec/executor.d.ts +45 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +447 -52
- package/dist/executors/bounded-exec/gateway-lease.d.ts +52 -0
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -0
- package/dist/executors/bounded-exec/gateway-lease.js +143 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +35 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -0
- package/dist/executors/bounded-exec/hang-diagnostics.js +231 -0
- package/dist/executors/bounded-exec/progress.d.ts +35 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -0
- package/dist/executors/bounded-exec/progress.js +79 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts +3 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-fixtures.js +12 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts +91 -0
- package/dist/executors/bounded-exec/ram-temp-held.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp-held.js +152 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts +223 -0
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -0
- package/dist/executors/bounded-exec/ram-temp.js +1528 -0
- package/dist/executors/bounded-exec/schema.d.ts +29 -11
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +162 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -0
- package/dist/executors/bounded-exec/verdict.js +318 -0
- package/dist/executors/shard-timings/executor.d.ts +14 -0
- package/dist/executors/shard-timings/executor.d.ts.map +1 -0
- package/dist/executors/shard-timings/executor.js +25 -0
- package/dist/executors/shard-timings/schema.d.ts +4 -0
- package/dist/executors/shard-timings/schema.d.ts.map +1 -0
- package/dist/executors/shard-timings/schema.js +1 -0
- package/dist/failure-summary.d.ts +5 -0
- package/dist/failure-summary.d.ts.map +1 -0
- package/dist/failure-summary.js +118 -0
- package/dist/generators/create-package/generator.d.ts.map +1 -1
- package/dist/generators/create-package/generator.js +6 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +435 -230
- package/dist/managed-assets.d.ts +6 -0
- package/dist/managed-assets.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.d.ts +13 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +44 -13
- package/dist/managed-files/files.d.ts +7 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +62 -8
- package/dist/managed-files/json-edit.d.ts +21 -0
- package/dist/managed-files/json-edit.d.ts.map +1 -0
- package/dist/managed-files/json-edit.js +295 -0
- package/dist/managed-files/managed-format.d.ts +33 -1
- package/dist/managed-files/managed-format.d.ts.map +1 -1
- package/dist/managed-files/managed-format.js +82 -2
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +7 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +68 -4
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +231 -48
- package/dist/managed-files/tree.d.ts +5 -0
- package/dist/managed-files/tree.d.ts.map +1 -1
- package/dist/managed-files/tree.js +5 -3
- package/dist/manifest-hash.js +3 -2
- package/dist/nextest-code-bound.d.ts +62 -0
- package/dist/nextest-code-bound.d.ts.map +1 -0
- package/dist/nextest-code-bound.js +154 -0
- package/dist/nextest-extraction.d.ts +24 -8
- package/dist/nextest-extraction.d.ts.map +1 -1
- package/dist/nextest-extraction.js +42 -7
- package/dist/package-target-policy.d.ts.map +1 -1
- package/dist/package-target-policy.js +3 -5
- package/dist/release-config-policy.d.ts.map +1 -1
- package/dist/release-config-policy.js +3 -5
- package/dist/runtime-input.d.ts +14 -0
- package/dist/runtime-input.d.ts.map +1 -0
- package/dist/runtime-input.js +15 -0
- package/dist/rust-tokens.d.ts +11 -0
- package/dist/rust-tokens.d.ts.map +1 -0
- package/dist/rust-tokens.js +81 -0
- package/dist/task-results.d.ts +6 -0
- package/dist/task-results.d.ts.map +1 -0
- package/dist/task-results.js +61 -0
- package/dist/test-program.d.ts +54 -0
- package/dist/test-program.d.ts.map +1 -0
- package/dist/test-program.js +292 -0
- package/dist/test-timings.d.ts +71 -0
- package/dist/test-timings.d.ts.map +1 -0
- package/dist/test-timings.js +393 -0
- package/dist/test-walk-policy.d.ts +103 -0
- package/dist/test-walk-policy.d.ts.map +1 -0
- package/dist/test-walk-policy.js +657 -0
- package/dist/testing.d.ts +177 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +824 -0
- package/dist/type-guards.d.ts +3 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +4 -0
- package/dist/typecheck-test-policy.d.ts +8 -5
- package/dist/typecheck-test-policy.d.ts.map +1 -1
- package/dist/typecheck-test-policy.js +113 -100
- package/dist/workspace-config-policy.d.ts +8 -0
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +175 -63
- package/dist/workspace-index.d.ts +12 -0
- package/dist/workspace-index.d.ts.map +1 -0
- package/dist/workspace-index.js +17 -0
- package/dist/workspace-manifest.d.ts +37 -1
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/executors.json +5 -0
- package/loader.js +13 -11
- package/managed/raw/envrc +33 -62
- package/managed/raw/git-format-staged.yml +30 -35
- package/managed/raw/patches/nx@23.2.1.patch +3484 -0
- package/managed/raw/tooling/direnv/apple-developer.sh +83 -0
- package/managed/raw/tooling/direnv/developer-links.ts +607 -17
- package/managed/raw/tooling/direnv/devenv.smoo.nix +314 -92
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -11
- package/managed/raw/tooling/direnv/linked-snapshots.ts +845 -0
- package/managed/raw/tooling/direnv/nx-socket-dir.sh +82 -0
- package/managed/raw/tooling/direnv/repo-path +14 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +1009 -118
- package/managed/raw/tooling/direnv/toolchain-stamp.ts +45 -3
- package/managed/raw/tooling/direnv/ttsc-env.sh +39 -0
- package/managed/raw/tooling/git-hooks/commit-msg.sh +5 -6
- package/managed/raw/tooling/git-hooks/pre-commit.sh +7 -6
- package/managed/raw/tooling/git-hooks/pre-push.sh +20 -15
- package/managed/templates/github/actions/cache-nix-devenv/action.yml +6 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +6 -4
- package/managed/templates/github/actions/cache-nx/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +1 -1
- package/managed/templates/github/actions/forgejo-artifact.cjs +99 -0
- package/managed/templates/github/actions/forgejo-download-artifact/action.yml +49 -0
- package/managed/templates/github/actions/forgejo-download-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/action.yml +65 -0
- package/managed/templates/github/actions/forgejo-upload-artifact/index.cjs +7 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +21 -3
- package/managed/templates/github/workflows/managed-files.yml +1 -2
- package/nextest.toml +8 -75
- package/package.json +75 -13
- package/runtime-input.sh +81 -0
- package/src/__tests__/counted-cargo-process.ts +286 -0
- package/src/__tests__/counted-cargo.ts +730 -0
- package/src/__tests__/fixture-cargo-home.ts +36 -0
- package/src/__tests__/fixture-nx-env.ts +157 -2
- package/src/__tests__/progress-clock.ts +43 -0
- package/src/__tests__/runtime-input.ts +23 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +127 -0
- package/src/bin/smoo-nx-bound-failures.ts +33 -0
- package/src/bin/smoo-nx-cargo-hash.ts +28 -3
- package/src/bin/smoo-nx-exec.ts +17 -86
- package/src/bin/smoo-nx-failures.ts +4 -0
- package/src/bin/smoo-nx-nextest-extract.ts +3 -2
- package/src/bin/smoo-nx-test-walks.ts +42 -0
- package/src/bounded-test-policy.test.ts +268 -22
- package/src/bounded-test-policy.ts +114 -42
- package/src/build-state-output-policy.test.ts +115 -0
- package/src/build-state-output-policy.ts +90 -0
- package/src/bun-bootstrap.test.ts +57 -3
- package/src/bun-file-packages.test.ts +47 -0
- package/src/cargo-closure-input.test.ts +432 -62
- package/src/cargo-closure-input.ts +51 -57
- package/src/cargo-dev-profile.ts +137 -0
- package/src/cargo-resolve-cache.test.ts +1044 -0
- package/src/cargo-source-hash.test.ts +203 -93
- package/src/cargo-source-hash.ts +762 -75
- package/src/cargo-toolchain-policy.ts +6 -0
- package/src/cargo-workspace.test.ts +320 -0
- package/src/cargo-workspace.ts +344 -18
- package/src/cross-check-policy.test.ts +59 -1
- package/src/cross-check-policy.ts +25 -6
- package/src/disk-command-policy.test.ts +61 -0
- package/src/disk-command-policy.ts +107 -0
- package/src/ensure-built-receipt.test.ts +184 -0
- package/src/ensure-built-receipt.ts +263 -0
- package/src/ensure-built-witness.test.ts +344 -0
- package/src/ensure-built-witness.ts +252 -0
- package/src/ensure-built.test.ts +1043 -483
- package/src/ensure-built.ts +870 -197
- package/src/eslint-file-set.ts +9 -0
- package/src/executors/bounded-exec/cpu-pool.test.ts +454 -0
- package/src/executors/bounded-exec/cpu-pool.ts +417 -0
- package/src/executors/bounded-exec/cpu-tokens.test.ts +269 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +177 -0
- package/src/executors/bounded-exec/disk-lease.test.ts +185 -0
- package/src/executors/bounded-exec/disk-lease.ts +139 -0
- package/src/executors/bounded-exec/executor-host.test.ts +778 -0
- package/src/executors/bounded-exec/executor.test.ts +1116 -63
- package/src/executors/bounded-exec/executor.ts +565 -67
- package/src/executors/bounded-exec/gateway-lease.ts +176 -0
- package/src/executors/bounded-exec/hang-diagnostics.test.ts +285 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +283 -0
- package/src/executors/bounded-exec/progress.test.ts +79 -0
- package/src/executors/bounded-exec/progress.ts +118 -0
- package/src/executors/bounded-exec/ram-temp-fixtures.ts +12 -0
- package/src/executors/bounded-exec/ram-temp-held.test.ts +264 -0
- package/src/executors/bounded-exec/ram-temp-held.ts +242 -0
- package/src/executors/bounded-exec/ram-temp-host.test.ts +605 -0
- package/src/executors/bounded-exec/ram-temp.test.ts +674 -0
- package/src/executors/bounded-exec/ram-temp.ts +1918 -0
- package/src/executors/bounded-exec/schema.json +11 -5
- package/src/executors/bounded-exec/schema.ts +27 -11
- package/src/executors/bounded-exec/verdict.test.ts +440 -0
- package/src/executors/bounded-exec/verdict.ts +433 -0
- package/src/executors/shard-timings/executor.ts +36 -0
- package/src/executors/shard-timings/schema.json +21 -0
- package/src/executors/shard-timings/schema.ts +4 -0
- package/src/failure-summary.ts +119 -0
- package/src/generators/bounded-test-targets/generator.test.ts +4 -4
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/create-package/generator.test.ts +6 -0
- package/src/generators/create-package/generator.ts +6 -2
- package/src/host-controller-wiring.test.ts +31 -0
- package/src/index.test.ts +1070 -360
- package/src/index.ts +524 -255
- package/src/linked-snapshots.nx.test.ts +172 -0
- package/src/managed-assets.ts +12 -0
- package/src/managed-files/ci-workflow.ts +54 -13
- package/src/managed-files/files.ts +65 -9
- package/src/managed-files/forgejo-artifact.test.ts +395 -0
- package/src/managed-files/generator.test.ts +60 -1
- package/src/managed-files/json-edit.test.ts +216 -0
- package/src/managed-files/json-edit.ts +290 -0
- package/src/managed-files/managed-format-json.test.ts +308 -0
- package/src/managed-files/managed-format.ts +90 -2
- package/src/managed-files/pr-preview-cleanup-workflow.ts +69 -3
- package/src/managed-files/publish-workflow.ts +285 -67
- package/src/managed-files/repo-path.test.ts +129 -0
- package/src/managed-files/trace-db-artifact.test.ts +7 -0
- package/src/managed-files/tree.ts +11 -3
- package/src/manifest-hash.ts +3 -2
- package/src/nextest-code-bound.test.ts +155 -0
- package/src/nextest-code-bound.ts +195 -0
- package/src/nextest-extraction.test.ts +37 -5
- package/src/nextest-extraction.ts +51 -9
- package/src/nextest-partitions.test.ts +495 -0
- package/src/nx-cache-bound.test.ts +109 -0
- package/src/nx-cache-restore-mtime.test.ts +170 -0
- package/src/nx-daemon-claim.test.ts +277 -0
- package/src/nx-daemon-idle-cpu.test.ts +81 -0
- package/src/nx-daemon-idle-policy.test.ts +51 -0
- package/src/nx-daemon-ignore-files.test.ts +210 -0
- package/src/nx-daemon-root-normalization.test.ts +105 -0
- package/src/nx-daemon-validity.test.ts +925 -0
- package/src/nx-dot-input-policy.test.ts +353 -0
- package/src/nx-failure-life-cycles.test.ts +207 -0
- package/src/nx-files-archive-racy.test.ts +97 -0
- package/src/nx-foreign-workspace-env.test.ts +329 -0
- package/src/nx-incomplete-run-summary.test.ts +70 -0
- package/src/nx-plugin-load-errors.test.ts +120 -0
- package/src/nx-project-resolution-cache.test.ts +176 -0
- package/src/nx-raw-inputs.test.ts +166 -0
- package/src/nx-resident-graph-workers.test.ts +112 -0
- package/src/nx-run-information.test.ts +118 -0
- package/src/nx-skipped-task-exit.test.ts +180 -0
- package/src/nx-state-location.test.ts +63 -0
- package/src/nx-store-resolution.test.ts +99 -0
- package/src/nx-task-graph-cycles.test.ts +148 -0
- package/src/nx-task-output-lease.test.ts +414 -0
- package/src/nx-use-local.test.ts +103 -0
- package/src/package-target-policy.ts +3 -6
- package/src/release-config-policy.ts +3 -6
- package/src/runtime-input.test.ts +215 -0
- package/src/runtime-input.ts +17 -0
- package/src/rust-tokens.ts +78 -0
- package/src/serial-group-wiring.test.ts +326 -0
- package/src/task-history-namespace.test.ts +181 -0
- package/src/task-results.test.ts +226 -0
- package/src/task-results.ts +75 -0
- package/src/test-program.test.ts +303 -0
- package/src/test-program.ts +341 -0
- package/src/test-timings.test.ts +240 -0
- package/src/test-timings.ts +311 -0
- package/src/test-walk-policy.test.ts +585 -0
- package/src/test-walk-policy.ts +731 -0
- package/src/testing.test.ts +509 -0
- package/src/testing.ts +922 -0
- package/src/type-guards.ts +4 -0
- package/src/typecheck-test-policy.test.ts +496 -11
- package/src/typecheck-test-policy.ts +137 -103
- package/src/workspace-config-policy.test.ts +212 -13
- package/src/workspace-config-policy.ts +101 -73
- package/src/workspace-index.ts +18 -0
- package/src/workspace-manifest.ts +41 -1
- package/test-timings.json +85 -28
- package/managed/raw/tooling/direnv/inherited-devenv.ts +0 -615
- package/managed/raw/tooling/direnv/shared-caches.sh +0 -53
- package/src/__tests__/in-process-nx-index.ts +0 -9
package/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]));
|
|
272
|
+
}
|
|
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));
|
|
238
283
|
}
|
|
239
|
-
|
|
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,25 @@ 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)}`);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* One shell command that runs `steps` in order and stops at the first failure.
|
|
412
|
+
*
|
|
413
|
+
* For a step that CONSUMES what an earlier step produces — the archive needs
|
|
414
|
+
* its directory, `wasm-bindgen` reads the `.wasm` that `cargo build` writes.
|
|
415
|
+
* The order lives in the command because that is the only place a
|
|
416
|
+
* producer-consumer pair inside one task can state it: `nx:run-commands`'
|
|
417
|
+
* `commands` array is a set of independent commands that Nx runs side by side.
|
|
418
|
+
*/
|
|
419
|
+
function sequence(steps) {
|
|
420
|
+
return steps.join(' && ');
|
|
337
421
|
}
|
|
338
422
|
/**
|
|
339
423
|
* Everything a target actually runs, as one string. `nx:run-commands` accepts
|
|
@@ -367,9 +451,11 @@ function napiInputs(projectRoot, repoRooted) {
|
|
|
367
451
|
// by its path from there whichever way the Cargo invocation is rooted.
|
|
368
452
|
const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
|
|
369
453
|
return [
|
|
370
|
-
|
|
454
|
+
CARGO_CLOSURE_INPUT,
|
|
455
|
+
'{projectRoot}/scripts/*.sh',
|
|
456
|
+
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
371
457
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
372
|
-
|
|
458
|
+
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
373
459
|
{ externalDependencies: ['@napi-rs/cli'] },
|
|
374
460
|
];
|
|
375
461
|
}
|
|
@@ -427,8 +513,7 @@ const CARGO_PROFILE_OUTPUT_DIR = { dev: 'debug', release: 'release' };
|
|
|
427
513
|
function cargoWasmTargetDirectory(projectRoot, config, repoRooted, cargoWorkspace) {
|
|
428
514
|
const cwd = repoRooted ? '.' : projectRoot;
|
|
429
515
|
const crateDir = posix.join(cwd, posix.dirname(config.manifestPath));
|
|
430
|
-
const owner = cargoWorkspace
|
|
431
|
-
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)
|
|
432
517
|
? cargoWorkspace.projectRoot
|
|
433
518
|
: crateDir;
|
|
434
519
|
return posix.relative(cwd, posix.join(owner, 'target'));
|
|
@@ -436,23 +521,24 @@ function cargoWasmTargetDirectory(projectRoot, config, repoRooted, cargoWorkspac
|
|
|
436
521
|
function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirectory) {
|
|
437
522
|
const outputDirectory = repoRooted ? posix.join(projectRoot, config.outputDirectory) : config.outputDirectory;
|
|
438
523
|
const cargoSelection = repoRooted ? `-p ${config.cargoPackage}` : `--manifest-path ${config.manifestPath}`;
|
|
439
|
-
const
|
|
524
|
+
const buildCommand = (profile) => sequence([
|
|
440
525
|
cargoFrozen(`build${CARGO_PROFILE_FLAG[profile]} --target wasm32-unknown-unknown ${cargoSelection}`),
|
|
441
526
|
...config.targets.map(({ bindgenTarget, outputName }) => `wasm-bindgen --target ${bindgenTarget} --out-dir ${outputDirectory}/${outputName} ` +
|
|
442
527
|
`${cargoTargetDirectory}/wasm32-unknown-unknown/${CARGO_PROFILE_OUTPUT_DIR[profile]}/${config.libraryName}.wasm`),
|
|
443
|
-
];
|
|
528
|
+
]);
|
|
444
529
|
return {
|
|
445
530
|
executor: 'nx:run-commands',
|
|
446
531
|
cache: true,
|
|
447
532
|
dependsOn: ['^build'],
|
|
448
|
-
inputs: repoRooted
|
|
533
|
+
inputs: repoRooted
|
|
534
|
+
? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
|
|
535
|
+
: CARGO_OUTPUT_INPUTS,
|
|
449
536
|
outputs: [`{projectRoot}/${config.outputDirectory}`],
|
|
450
537
|
options: {
|
|
451
|
-
|
|
538
|
+
command: buildCommand('dev'),
|
|
452
539
|
cwd: repoRooted ? '.' : projectRoot,
|
|
453
|
-
parallel: false,
|
|
454
540
|
},
|
|
455
|
-
configurations: { [RELEASE_CONFIGURATION]: {
|
|
541
|
+
configurations: { [RELEASE_CONFIGURATION]: { command: buildCommand('release') } },
|
|
456
542
|
};
|
|
457
543
|
}
|
|
458
544
|
/**
|
|
@@ -462,11 +548,11 @@ function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirec
|
|
|
462
548
|
* in its own unbounded target. Cargo reuses incremental compilation locally;
|
|
463
549
|
* Nx cannot cache this warming action without restoring shared mutable state.
|
|
464
550
|
*
|
|
465
|
-
* Cargo flocks one `target/` per invocation
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
551
|
+
* Cargo flocks one `target/` per invocation and owns that lock: a second cargo
|
|
552
|
+
* process on the same directory waits inside cargo ("Blocking waiting for file
|
|
553
|
+
* lock"). Inference adds no edge to keep writers apart — an edge says one
|
|
554
|
+
* target consumes another's output, and none of these do. These are unbounded
|
|
555
|
+
* `nx:run-commands` targets, so a wait is not charged against a test budget.
|
|
470
556
|
*
|
|
471
557
|
* Clippy runs ONCE over the whole workspace, in that same `target/`, rather
|
|
472
558
|
* than once per crate. Clippy of a crate is a check build of its whole
|
|
@@ -509,6 +595,9 @@ function createCargoTestCompileTarget(projectRoot) {
|
|
|
509
595
|
* Cached, unlike `cargo-test-compile`, because it produces a VALUE: one file,
|
|
510
596
|
* not a mutable build tree Nx would have to restore. `--workspace` matches the
|
|
511
597
|
* clippy selection exactly, so both gates unify features the same way.
|
|
598
|
+
*
|
|
599
|
+
* The directory and the archive are ONE command: nextest does not create the
|
|
600
|
+
* archive's parent, so the archive step consumes what the `mkdir` produced.
|
|
512
601
|
*/
|
|
513
602
|
function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
514
603
|
return {
|
|
@@ -517,12 +606,11 @@ function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
|
517
606
|
inputs: CARGO_INPUTS,
|
|
518
607
|
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`],
|
|
519
608
|
options: {
|
|
520
|
-
|
|
609
|
+
command: sequence([
|
|
521
610
|
`mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`,
|
|
522
611
|
cargoFrozen(`nextest archive --workspace --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`),
|
|
523
|
-
],
|
|
612
|
+
]),
|
|
524
613
|
cwd: projectRoot,
|
|
525
|
-
parallel: false,
|
|
526
614
|
},
|
|
527
615
|
};
|
|
528
616
|
}
|
|
@@ -559,9 +647,15 @@ function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
|
559
647
|
function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archiveInputs) {
|
|
560
648
|
const { target: triple, cargo } = crossTarget;
|
|
561
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';
|
|
562
656
|
return {
|
|
563
657
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
564
|
-
executor:
|
|
658
|
+
executor: archiveExecutor,
|
|
565
659
|
cache: true,
|
|
566
660
|
// The toolchain inputs every cached cargo target carries, plus the
|
|
567
661
|
// declared driver's own bytes. Those toolchain inputs are attached
|
|
@@ -573,23 +667,19 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
573
667
|
// must never hash equal to the same sources built under another. The
|
|
574
668
|
// declared driver is hashed by its own bytes; nothing samples the shell
|
|
575
669
|
// that supplies it, which is why this hash is the same bare and inside
|
|
576
|
-
// the cross profile.
|
|
670
|
+
// the cross profile. For the same reason it names its npm packages here.
|
|
577
671
|
inputs: [
|
|
578
672
|
...archiveInputs,
|
|
579
673
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
580
674
|
...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
|
|
581
675
|
cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
|
|
676
|
+
{ externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand) },
|
|
582
677
|
],
|
|
583
678
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
584
679
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
585
680
|
options: {
|
|
586
|
-
|
|
587
|
-
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
588
|
-
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
589
|
-
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
590
|
-
],
|
|
681
|
+
command: archiveCommand,
|
|
591
682
|
cwd: projectRoot,
|
|
592
|
-
parallel: false,
|
|
593
683
|
// `CARGO` is cargo's own driver variable and the only seam nextest
|
|
594
684
|
// offers: it shells out to `$CARGO metadata` and
|
|
595
685
|
// `$CARGO test --no-run --target <triple>`, so the declared script
|
|
@@ -609,7 +699,7 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
609
699
|
command: `cargo-nextest nextest run --archive-file ${archiveFile} --workspace-remap . ` +
|
|
610
700
|
`--no-tests=pass --user-config-file none ${toolConfig}`,
|
|
611
701
|
cwd: projectRoot,
|
|
612
|
-
|
|
702
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
613
703
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
614
704
|
},
|
|
615
705
|
},
|
|
@@ -624,12 +714,39 @@ function createCargoTestTarget(projectRoot) {
|
|
|
624
714
|
options: {
|
|
625
715
|
command: cargoFrozen('test --workspace'),
|
|
626
716
|
cwd: projectRoot,
|
|
627
|
-
|
|
717
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
628
718
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
629
719
|
},
|
|
630
720
|
};
|
|
631
721
|
}
|
|
632
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
|
+
}
|
|
633
750
|
function versionlessManifestPolicy(context) {
|
|
634
751
|
if (!supportsJsonInputs())
|
|
635
752
|
return null;
|
|
@@ -675,8 +792,10 @@ function createNodesHandler(hostPlatform) {
|
|
|
675
792
|
const results = [];
|
|
676
793
|
const errors = [];
|
|
677
794
|
let cargoWorkspaces;
|
|
795
|
+
let eslintSources;
|
|
678
796
|
try {
|
|
679
|
-
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot);
|
|
797
|
+
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
|
|
798
|
+
eslintSources = await indexedEslintSources(context.workspaceRoot);
|
|
680
799
|
}
|
|
681
800
|
catch (error) {
|
|
682
801
|
throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
|
|
@@ -696,16 +815,13 @@ function createNodesHandler(hostPlatform) {
|
|
|
696
815
|
}
|
|
697
816
|
results.push([
|
|
698
817
|
packageJsonPath,
|
|
699
|
-
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, cargoWorkspaces, versionless),
|
|
818
|
+
await createProjectTargets(packageJsonPath, context.workspaceRoot, hostPlatform, cargoWorkspaces, eslintSources, versionless),
|
|
700
819
|
]);
|
|
701
820
|
}
|
|
702
821
|
catch (error) {
|
|
703
822
|
errors.push([packageJsonPath, error instanceof Error ? error : new Error(String(error))]);
|
|
704
823
|
}
|
|
705
824
|
}));
|
|
706
|
-
// A project that failed before reaching its closure never awaited Cargo;
|
|
707
|
-
// no process this call started may outlive it.
|
|
708
|
-
await Promise.all(cargoWorkspaces.map((workspace) => workspace.closureSource));
|
|
709
825
|
if (errors.length > 0) {
|
|
710
826
|
throw new AggregateCreateNodesError(errors, results);
|
|
711
827
|
}
|
|
@@ -729,7 +845,7 @@ function isBuildOutputPackageJson(packageJsonPath) {
|
|
|
729
845
|
const normalized = `/${packageJsonPath.replaceAll('\\', '/')}`;
|
|
730
846
|
return BUILD_OUTPUT_SEGMENTS.some((segment) => normalized.includes(segment));
|
|
731
847
|
}
|
|
732
|
-
export default { createNodesV2 };
|
|
848
|
+
export default { createNodesV2, postTasksExecution, preTasksExecution };
|
|
733
849
|
function packageBinOutputs(packageJson, packageJsonPath) {
|
|
734
850
|
if (packageJson.bin === undefined) {
|
|
735
851
|
return [];
|
|
@@ -791,7 +907,7 @@ const WRANGLER_CONFIG_FILES = ['wrangler.jsonc', 'wrangler.json', 'wrangler.toml
|
|
|
791
907
|
* `--stage` refuses it, which is the failure we want at the boundary.
|
|
792
908
|
*/
|
|
793
909
|
const WRANGLER_DEPLOY_COMMAND = 'smoo wrangler deploy-stage --stage {args.stage}';
|
|
794
|
-
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, cargoWorkspaces, versionless) {
|
|
910
|
+
async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform, cargoWorkspaces, eslintSources, versionless) {
|
|
795
911
|
const projectRoot = dirname(packageJsonPath);
|
|
796
912
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
797
913
|
const packageJson = await readPackageJson(join(workspaceRoot, packageJsonPath));
|
|
@@ -865,11 +981,17 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
865
981
|
targets.typecheck = {
|
|
866
982
|
executor: 'nx:run-commands',
|
|
867
983
|
cache: true,
|
|
868
|
-
inputs: [
|
|
984
|
+
inputs: [
|
|
985
|
+
selfProduction,
|
|
986
|
+
dependencyProduction,
|
|
987
|
+
...checkInputs,
|
|
988
|
+
TYPECHECK_COMPILER_INPUT,
|
|
989
|
+
'{projectRoot}/tsconfig.lib.json',
|
|
990
|
+
],
|
|
869
991
|
outputs: [],
|
|
870
992
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
871
993
|
options: {
|
|
872
|
-
command: '
|
|
994
|
+
command: typecheckCommand('-p tsconfig.lib.json --noEmit'),
|
|
873
995
|
cwd: projectRoot,
|
|
874
996
|
},
|
|
875
997
|
};
|
|
@@ -878,10 +1000,16 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
878
1000
|
targets['typecheck-tests'] = {
|
|
879
1001
|
executor: 'nx:run-commands',
|
|
880
1002
|
cache: true,
|
|
881
|
-
inputs: [
|
|
1003
|
+
inputs: [
|
|
1004
|
+
selfDefault,
|
|
1005
|
+
dependencyProduction,
|
|
1006
|
+
...checkInputs,
|
|
1007
|
+
TYPECHECK_COMPILER_INPUT,
|
|
1008
|
+
'{projectRoot}/tsconfig.test.json',
|
|
1009
|
+
],
|
|
882
1010
|
dependsOn: ['typecheck'],
|
|
883
1011
|
options: {
|
|
884
|
-
command: '
|
|
1012
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit'),
|
|
885
1013
|
cwd: projectRoot,
|
|
886
1014
|
},
|
|
887
1015
|
};
|
|
@@ -889,7 +1017,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
889
1017
|
executor: 'nx:run-commands',
|
|
890
1018
|
continuous: true,
|
|
891
1019
|
options: {
|
|
892
|
-
command: '
|
|
1020
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit --watch'),
|
|
893
1021
|
cwd: projectRoot,
|
|
894
1022
|
},
|
|
895
1023
|
};
|
|
@@ -952,13 +1080,12 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
952
1080
|
// inferred list here, once when Nx merges the same declaration over this
|
|
953
1081
|
// result — duplicating the very edges the spread exists to add.
|
|
954
1082
|
//
|
|
955
|
-
// `dependsOn` REPLACES rather than unions. These lists
|
|
956
|
-
//
|
|
957
|
-
//
|
|
958
|
-
//
|
|
959
|
-
//
|
|
960
|
-
//
|
|
961
|
-
// make every inferred edge unremovable and a corrected order unrepresentable.
|
|
1083
|
+
// `dependsOn` REPLACES rather than unions. These lists state what each target
|
|
1084
|
+
// consumes — the fetched registry, the archive, the debug addon — and a
|
|
1085
|
+
// package that must re-route one (build its artifact ahead of the test run,
|
|
1086
|
+
// or drop `cargo-test-compile` because it compiles differently) can only say
|
|
1087
|
+
// so by replacing the list; a union would make every inferred edge
|
|
1088
|
+
// unremovable and a corrected order unrepresentable.
|
|
962
1089
|
// Additive intent already has a spelling (`"..."` above), so a plugin-local
|
|
963
1090
|
// additive key would be a second convention beside a working one.
|
|
964
1091
|
//
|
|
@@ -993,7 +1120,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
993
1120
|
{ dependentTasksOutputFiles: '**/*', transitive: false },
|
|
994
1121
|
];
|
|
995
1122
|
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
996
|
-
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(
|
|
1123
|
+
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot));
|
|
997
1124
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
998
1125
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
999
1126
|
targets[CARGO_TEST_ARCHIVE_TARGET].inputs = [...workspaceCargoInputs, `{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`];
|
|
@@ -1002,8 +1129,21 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1002
1129
|
// binaries whichever machine they are for, so a change that invalidates
|
|
1003
1130
|
// the host archive must invalidate every cross one.
|
|
1004
1131
|
for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
|
|
1005
|
-
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);
|
|
1006
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.
|
|
1007
1147
|
const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) => plan.pieces.map((piece) => cargoTargetDependency(projectName, {
|
|
1008
1148
|
projectName: plan.package.projectName,
|
|
1009
1149
|
targetName: piece.targetName,
|
|
@@ -1027,7 +1167,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1027
1167
|
options: {
|
|
1028
1168
|
commands: ['cargo fmt --all --check', CARGO_LINT_CLIPPY_COMMAND],
|
|
1029
1169
|
cwd: cargoWorkspaceRoot,
|
|
1030
|
-
parallel: false,
|
|
1031
1170
|
},
|
|
1032
1171
|
};
|
|
1033
1172
|
validationTargets.push('cargo-lint');
|
|
@@ -1068,13 +1207,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1068
1207
|
cwd: cargoWorkspaceRoot,
|
|
1069
1208
|
},
|
|
1070
1209
|
};
|
|
1071
|
-
if (!targets.test && !('test' in declaredTargets) && typeof packageJson.scripts?.test !== 'string') {
|
|
1072
|
-
targets.test = {
|
|
1073
|
-
executor: 'nx:noop',
|
|
1074
|
-
cache: true,
|
|
1075
|
-
dependsOn: [CARGO_TEST_TARGET],
|
|
1076
|
-
};
|
|
1077
|
-
}
|
|
1078
1210
|
// Mutation runs are minutes-to-hours: never cached, never part of build/lint.
|
|
1079
1211
|
// CI runs these per-PR via `cargo mutants --in-diff` (see mutants.toml docs).
|
|
1080
1212
|
targets.mutation = {
|
|
@@ -1100,6 +1232,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1100
1232
|
}
|
|
1101
1233
|
if (cargoWorkspace) {
|
|
1102
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.
|
|
1103
1237
|
if (!isCargoWorkspaceRoot) {
|
|
1104
1238
|
targets[CARGO_TEST_TARGET] = {
|
|
1105
1239
|
executor: 'nx:noop',
|
|
@@ -1128,6 +1262,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1128
1262
|
targets.test = {
|
|
1129
1263
|
executor: 'nx:noop',
|
|
1130
1264
|
cache: true,
|
|
1265
|
+
// Ordinary tests never infer an edge to a serial group; host aggregates are explicit repository config.
|
|
1131
1266
|
dependsOn: [CARGO_TEST_TARGET],
|
|
1132
1267
|
};
|
|
1133
1268
|
}
|
|
@@ -1160,8 +1295,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1160
1295
|
// Derived from the command text rather than a curated list of target names:
|
|
1161
1296
|
// the fact that makes a target need this is that it runs frozen cargo, so a
|
|
1162
1297
|
// frozen target added later is covered without anyone remembering to. The edge
|
|
1163
|
-
// goes on EVERY frozen target,
|
|
1164
|
-
//
|
|
1298
|
+
// goes on EVERY frozen target, so re-routing one target's `dependsOn` cannot
|
|
1299
|
+
// strip another's precondition.
|
|
1165
1300
|
// Package-rooted workspaces fetch beside their package.json; members of a
|
|
1166
1301
|
// repository-root workspace all depend on the root project's one fetch.
|
|
1167
1302
|
//
|
|
@@ -1184,15 +1319,14 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1184
1319
|
// there is nothing for Nx to restore in its place.
|
|
1185
1320
|
cache: false,
|
|
1186
1321
|
options: {
|
|
1322
|
+
// One fetch per manifest, independent of the others: Cargo's own
|
|
1323
|
+
// package-cache lock arbitrates the CARGO_HOME they share.
|
|
1187
1324
|
commands: [...frozenCargoManifests]
|
|
1188
1325
|
.sort()
|
|
1189
1326
|
.map((manifestPath) => manifestPath === 'Cargo.toml'
|
|
1190
1327
|
? CARGO_FETCH_COMMAND
|
|
1191
1328
|
: `${CARGO_FETCH_COMMAND} --manifest-path ${manifestPath}`),
|
|
1192
1329
|
cwd: projectRoot,
|
|
1193
|
-
// Two fetches into one CARGO_HOME contend on its package-cache flock;
|
|
1194
|
-
// serializing here spends the wait in Nx instead of inside cargo.
|
|
1195
|
-
parallel: false,
|
|
1196
1330
|
},
|
|
1197
1331
|
};
|
|
1198
1332
|
for (const [name, target] of Object.entries(targets)) {
|
|
@@ -1219,6 +1353,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1219
1353
|
}
|
|
1220
1354
|
// Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
|
|
1221
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.
|
|
1222
1358
|
for (const [name, target] of Object.entries(targets)) {
|
|
1223
1359
|
const text = targetCommandText(target);
|
|
1224
1360
|
if (!text.includes(CARGO_FROZEN_PREFIX))
|
|
@@ -1232,14 +1368,17 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1232
1368
|
: text.includes('nextest ')
|
|
1233
1369
|
? ' && cargo nextest --version'
|
|
1234
1370
|
: '';
|
|
1371
|
+
const inputs = target.inputs ?? CARGO_INPUTS;
|
|
1372
|
+
const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input);
|
|
1235
1373
|
target.inputs = [
|
|
1236
|
-
...
|
|
1374
|
+
...inputs,
|
|
1237
1375
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
1238
1376
|
cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
|
|
1377
|
+
...(namesPackages ? [] : [{ externalDependencies: cargoCommandNpmPackages(target, text) }]),
|
|
1239
1378
|
];
|
|
1240
1379
|
}
|
|
1241
|
-
//
|
|
1242
|
-
//
|
|
1380
|
+
// `build` warms the test executables' compile; in a nested package that names
|
|
1381
|
+
// the root workspace's one compile.
|
|
1243
1382
|
const cargoTestCompileDependency = targets[CARGO_TEST_COMPILE_TARGET]
|
|
1244
1383
|
? CARGO_TEST_COMPILE_TARGET
|
|
1245
1384
|
: isCargoProject && cargoWorkspace
|
|
@@ -1249,24 +1388,21 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1249
1388
|
})
|
|
1250
1389
|
: null;
|
|
1251
1390
|
const napiDebug = targets['napi-debug'];
|
|
1252
|
-
if (napiDebug && cargoTestCompileDependency) {
|
|
1253
|
-
const dependsOn = napiDebug.dependsOn ?? [];
|
|
1254
|
-
if (!hasCargoTargetDependency(dependsOn, cargoTestCompileDependency)) {
|
|
1255
|
-
napiDebug.dependsOn = [...dependsOn, cargoTestCompileDependency];
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
1391
|
if (napiDebug && cargoWorkspace) {
|
|
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
|
-
// and an archived test binary still loads it from this tree.
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1394
|
+
// and an archived test binary still loads it from this tree.
|
|
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'];
|
|
1270
1406
|
}
|
|
1271
1407
|
}
|
|
1272
1408
|
}
|
|
@@ -1277,7 +1413,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1277
1413
|
}
|
|
1278
1414
|
const dependsOn = target.dependsOn ?? [];
|
|
1279
1415
|
if (dependsOn.includes(CARGO_TEST_COMPILE_TARGET) && !dependsOn.includes('napi-debug')) {
|
|
1280
|
-
target.dependsOn = dependsOn
|
|
1416
|
+
target.dependsOn = [...dependsOn, 'napi-debug'];
|
|
1281
1417
|
}
|
|
1282
1418
|
}
|
|
1283
1419
|
const cargoTest = targets[CARGO_TEST_TARGET];
|
|
@@ -1290,33 +1426,9 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1290
1426
|
}
|
|
1291
1427
|
}
|
|
1292
1428
|
}
|
|
1293
|
-
//
|
|
1294
|
-
//
|
|
1295
|
-
|
|
1296
|
-
//
|
|
1297
|
-
// Only `cargo-napi` gets the ordering edge. A platform-suffixed target may NOT
|
|
1298
|
-
// have one: `validatePlatformTargetDependencies` (package-target-policy.ts:674)
|
|
1299
|
-
// walks each platform target's dependency closure and refuses any member of a
|
|
1300
|
-
// different family, because the publish flow builds and collects one platform
|
|
1301
|
-
// at a time — a `*-macos` collect that reached a familyless sibling would drag
|
|
1302
|
-
// in work the macOS runner has no business doing. `cargo-napi` carries no
|
|
1303
|
-
// platform suffix, so it is not scanned and the edge is legal there.
|
|
1304
|
-
//
|
|
1305
|
-
// The platform binaries therefore stay Nx siblings of cargo-test-compile and
|
|
1306
|
-
// serialize on cargo's flock instead of on a graph edge. That is the same
|
|
1307
|
-
// arrangement `cli-<arch>-<os>` and `napi-<arch>-<os>` already have with each
|
|
1308
|
-
// other — both `napi build` on one target dir — so this adds a third
|
|
1309
|
-
// participant to an existing wait, not a new hazard. The flock makes them wait;
|
|
1310
|
-
// it does not corrupt anything, and these are unbounded `nx:run-commands`
|
|
1311
|
-
// targets, so the wait is not charged against a test budget.
|
|
1312
|
-
const cargoWriterNames = hostPlatformTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)], hostPlatform);
|
|
1313
|
-
const cargoNapi = targets['cargo-napi'];
|
|
1314
|
-
if (cargoNapi && cargoTestCompileDependency) {
|
|
1315
|
-
const dependsOn = cargoNapi.dependsOn ?? [];
|
|
1316
|
-
if (!hasCargoTargetDependency(dependsOn, cargoTestCompileDependency)) {
|
|
1317
|
-
cargoNapi.dependsOn = [...dependsOn, cargoTestCompileDependency];
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1429
|
+
// The inferring host's own platform binaries join the aggregate `build`;
|
|
1430
|
+
// publish still owns foreign platforms.
|
|
1431
|
+
const hostPlatformBinaries = hostPlatformTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)], hostPlatform);
|
|
1320
1432
|
// A deploy is never cached; the build half beside it always is.
|
|
1321
1433
|
//
|
|
1322
1434
|
// Nx's cache answers "did this exact input set already produce an output". A deploy's real
|
|
@@ -1395,9 +1507,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1395
1507
|
executor: 'nx:noop',
|
|
1396
1508
|
cache: true,
|
|
1397
1509
|
outputs: [],
|
|
1398
|
-
//
|
|
1399
|
-
// the two sources overlap; the Set keeps one edge per target while holding
|
|
1400
|
-
// the order the families are listed in.
|
|
1510
|
+
// One edge per target, in the order the sources are listed.
|
|
1401
1511
|
dependsOn: [
|
|
1402
1512
|
...new Set([
|
|
1403
1513
|
'^build',
|
|
@@ -1405,7 +1515,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1405
1515
|
// reuses its incremental state; Nx never restores that shared state.
|
|
1406
1516
|
...(cargoTestCompileDependency ? [cargoTestCompileDependency] : []),
|
|
1407
1517
|
...buildOutputTargetNames([...Object.keys(declaredTargets), ...Object.keys(targets)]),
|
|
1408
|
-
...
|
|
1518
|
+
...hostPlatformBinaries,
|
|
1409
1519
|
]),
|
|
1410
1520
|
],
|
|
1411
1521
|
};
|
|
@@ -1454,16 +1564,37 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1454
1564
|
targets['typecheck-tests'].dependsOn = ['build'];
|
|
1455
1565
|
}
|
|
1456
1566
|
}
|
|
1457
|
-
|
|
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);
|
|
1458
1586
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
1459
1587
|
targets.lint = {
|
|
1460
1588
|
executor: lintCommands.length > 0 ? 'nx:run-commands' : 'nx:noop',
|
|
1589
|
+
...(eslintFileSet === null ? {} : { metadata: { eslintFileSet } }),
|
|
1461
1590
|
cache: true,
|
|
1462
1591
|
dependsOn: validationTargets,
|
|
1463
1592
|
outputs: [],
|
|
1464
1593
|
inputs: [
|
|
1465
1594
|
selfDefault,
|
|
1595
|
+
dependencyProduction,
|
|
1466
1596
|
...checkInputs,
|
|
1597
|
+
...lintProgramInputs,
|
|
1467
1598
|
...[...BIOME_CONFIG_FILES, ...ESLINT_CONFIG_FILES].flatMap((name) => [
|
|
1468
1599
|
`{workspaceRoot}/${name}`,
|
|
1469
1600
|
`{projectRoot}/${name}`,
|
|
@@ -1472,7 +1603,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1472
1603
|
],
|
|
1473
1604
|
...(lintCommands.length > 0
|
|
1474
1605
|
? {
|
|
1475
|
-
options: { commands: lintCommands, cwd: '.'
|
|
1606
|
+
options: { commands: lintCommands, cwd: '.' },
|
|
1476
1607
|
}
|
|
1477
1608
|
: {}),
|
|
1478
1609
|
};
|
|
@@ -1507,7 +1638,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1507
1638
|
return projectRoot === '.' || crate === projectRoot || crate.startsWith(`${projectRoot}/`);
|
|
1508
1639
|
}));
|
|
1509
1640
|
if (closureSources.length > 0) {
|
|
1510
|
-
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot,
|
|
1641
|
+
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot, closureSources.map((workspace) => workspace.closureSource));
|
|
1511
1642
|
}
|
|
1512
1643
|
return {
|
|
1513
1644
|
projects: {
|
|
@@ -1808,8 +1939,8 @@ function createNapiTestTarget(projectRoot, hasDedicatedBunfig) {
|
|
|
1808
1939
|
// Routes the package's native loader to the napi-debug artifact under
|
|
1809
1940
|
// .cache/native-debug instead of the packaged dist/native tree.
|
|
1810
1941
|
env: { NAPI_DEBUG_ADDON: '1' },
|
|
1811
|
-
|
|
1812
|
-
killAfterMs:
|
|
1942
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
1943
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
1813
1944
|
},
|
|
1814
1945
|
};
|
|
1815
1946
|
}
|
|
@@ -1889,7 +2020,7 @@ function cargoTargetDependency(currentProjectName, target) {
|
|
|
1889
2020
|
? target.targetName
|
|
1890
2021
|
: { projects: [target.projectName], target: target.targetName };
|
|
1891
2022
|
}
|
|
1892
|
-
async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
2023
|
+
async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot, hostPlatform) {
|
|
1893
2024
|
const projects = [];
|
|
1894
2025
|
for (const packageJsonPath of packageJsonPaths) {
|
|
1895
2026
|
if (isManagedPackageJsonSource(packageJsonPath) || isBuildOutputPackageJson(packageJsonPath)) {
|
|
@@ -1919,26 +2050,36 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1919
2050
|
})), projects).map((pkg) => ({ ...pkg, dir: posix.relative(rootProject.root, pkg.dir) || '.' }));
|
|
1920
2051
|
const packages = [];
|
|
1921
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})`];
|
|
1922
2062
|
for (const pkg of attributed) {
|
|
1923
2063
|
const pieces = [];
|
|
1924
2064
|
const sharded = pkg.testShards > 1;
|
|
1925
2065
|
const pin = sharded && exceptional !== null ? exceptional : null;
|
|
1926
|
-
const
|
|
2066
|
+
const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
|
|
1927
2067
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
1928
2068
|
const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
|
|
1929
2069
|
pieces.push({
|
|
1930
2070
|
extra: sharded ? ` --partition hash:${index}/${pkg.testShards}` : '',
|
|
1931
|
-
selector:
|
|
2071
|
+
selector: ordinary,
|
|
1932
2072
|
targetName,
|
|
1933
2073
|
});
|
|
1934
2074
|
}
|
|
1935
2075
|
if (pin !== null) {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2076
|
+
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2077
|
+
pieces.push({
|
|
2078
|
+
extra: ` --partition hash:${index}/${pkg.testShards}`,
|
|
2079
|
+
selector: [`package(${pkg.name}) and (${pin})`, ...notSerial].join(' and '),
|
|
2080
|
+
targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
1942
2083
|
}
|
|
1943
2084
|
packages.push({ package: pkg, pieces });
|
|
1944
2085
|
}
|
|
@@ -1947,6 +2088,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1947
2088
|
rootProjectName: rootProject.name,
|
|
1948
2089
|
projectRoot: rootProject.root,
|
|
1949
2090
|
inputsCache: createCargoInputsCache(),
|
|
2091
|
+
serialGroups,
|
|
1950
2092
|
});
|
|
1951
2093
|
}
|
|
1952
2094
|
if (found.length === 0)
|
|
@@ -1954,14 +2096,15 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1954
2096
|
// Started only once every workspace listed cleanly, so a listing that throws
|
|
1955
2097
|
// leaves no Cargo process behind.
|
|
1956
2098
|
const indexedManifests = indexedCargoManifests(workspaceRoot);
|
|
1957
|
-
return found.map((workspace) => ({
|
|
2099
|
+
return Promise.all(found.map(async (workspace) => ({
|
|
1958
2100
|
...workspace,
|
|
1959
|
-
closureSource: resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests),
|
|
1960
|
-
}));
|
|
2101
|
+
closureSource: await resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests, workspace.inputsCache.compiledInFiles),
|
|
2102
|
+
})));
|
|
1961
2103
|
}
|
|
1962
2104
|
/**
|
|
1963
2105
|
* One bounded target per crate; a crate that declares `smoothbricks.test.shards`
|
|
1964
|
-
* gets
|
|
2106
|
+
* gets that many ordinary and exceptional shards, so a class of tests with its
|
|
2107
|
+
* own time bound never delays an ordinary shard.
|
|
1965
2108
|
*
|
|
1966
2109
|
* Every piece EXECUTES, it never builds: it runs the binaries
|
|
1967
2110
|
* `cargo-test-archive` compiled once for the whole workspace. That is what
|
|
@@ -1988,9 +2131,11 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1988
2131
|
* from `--archive-file` is the Rust standard library directory: nextest has no
|
|
1989
2132
|
* flag to remap it, so a run uses the producing toolchain's own sysroot rather
|
|
1990
2133
|
* than the archived copy of it — the same toolchain, because the archive's hash
|
|
1991
|
-
* covers the toolchain pin. The extraction lives
|
|
1992
|
-
* in an Nx output: it
|
|
1993
|
-
* 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.
|
|
1994
2139
|
*
|
|
1995
2140
|
* `--workspace-remap .` is not cosmetic. An archive records the ABSOLUTE paths
|
|
1996
2141
|
* of the tree that produced it; without the remap, a restored archive hands
|
|
@@ -2003,17 +2148,16 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
2003
2148
|
* time: a test that spawns `env!("CARGO_BIN_EXE_x")` holds the producing tree's
|
|
2004
2149
|
* path and must read the runtime variable instead to survive relocation.
|
|
2005
2150
|
*
|
|
2006
|
-
* nextest.toml singles some tests out with an override
|
|
2007
|
-
*
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
* depending on how the hash happened to fall.
|
|
2151
|
+
* nextest.toml singles some tests out with an override: a raised `slow-timeout`
|
|
2152
|
+
* marks a test whose cost is not the suite's. Those are lifted OUT of the hash
|
|
2153
|
+
* into their own hash-partitioned targets and the ordinary shards run the exact
|
|
2154
|
+
* complement, so which tests a shard holds stops depending on how the hash
|
|
2155
|
+
* happened to fall.
|
|
2012
2156
|
*
|
|
2013
2157
|
* The two filtersets are exact complements, so their union is the crate whatever
|
|
2014
|
-
* either one matches. Every piece uses `--no-
|
|
2015
|
-
* member may expose no nextest tests, a small suite can
|
|
2016
|
-
* 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.
|
|
2017
2161
|
* Manifest discovery proves the package exists and generates the selector from
|
|
2018
2162
|
* its Cargo name, so accepting an empty run cannot hide a misspelled package.
|
|
2019
2163
|
*
|
|
@@ -2022,71 +2166,132 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
2022
2166
|
* Detecting that regression requires a separate coverage policy rather than
|
|
2023
2167
|
* making valid empty crates and shards fail execution.
|
|
2024
2168
|
*
|
|
2025
|
-
* Pieces fan out rather than chain
|
|
2026
|
-
*
|
|
2027
|
-
*
|
|
2169
|
+
* Pieces fan out rather than chain: a reused-build run writes nothing to cargo's
|
|
2170
|
+
* `target/`, so no piece waits on another. The one extraction per archive is
|
|
2171
|
+
* coordinated by `smoo-nx-nextest-extract` itself.
|
|
2028
2172
|
*/
|
|
2029
2173
|
async function addCargoTestTargets(targets, currentProjectName, projectRoot, workspaceRoot, workspace) {
|
|
2030
2174
|
const targetNames = [];
|
|
2031
|
-
const toolConfig = nextestToolConfigArg(workspaceRoot, workspace.projectRoot, PLUGIN_NEXTEST_CONFIG);
|
|
2032
|
-
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2033
|
-
const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
|
|
2034
|
-
const reuseExtraction = `--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2035
|
-
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2036
|
-
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2037
2175
|
for (const plan of workspace.packages) {
|
|
2038
2176
|
if (plan.package.projectRoot !== projectRoot) {
|
|
2039
2177
|
continue;
|
|
2040
2178
|
}
|
|
2041
|
-
|
|
2042
|
-
// `{projectRoot}` glob hashes only files this project owns, and sibling
|
|
2043
|
-
// manifests belong to whichever nested project holds them.
|
|
2044
|
-
const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
|
|
2045
|
-
// A workspace nextest build unifies features across every selected member.
|
|
2046
|
-
// A sibling manifest can therefore change this crate's tests without being
|
|
2047
|
-
// a path dependency. Track those manifests, not unrelated sibling sources.
|
|
2048
|
-
//
|
|
2049
|
-
// The repository's own nextest config layers OVER the plugin's tool config,
|
|
2050
|
-
// so it decides timeouts, groups and archive contents: a cached verdict that
|
|
2051
|
-
// ignored it would survive the change that invalidates it.
|
|
2052
|
-
const inputs = [
|
|
2053
|
-
...new Set([
|
|
2054
|
-
...(await cargoPackageTestInputs({
|
|
2055
|
-
workspaceRoot,
|
|
2056
|
-
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2057
|
-
memberDir: plan.package.dir,
|
|
2058
|
-
cache: workspace.inputsCache,
|
|
2059
|
-
})),
|
|
2060
|
-
...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
|
|
2061
|
-
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2062
|
-
]),
|
|
2063
|
-
{
|
|
2064
|
-
runtime: `bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' '${PLUGIN_NEXTEST_CONFIG.replaceAll("'", "'\"'\"'")}'`,
|
|
2065
|
-
},
|
|
2066
|
-
];
|
|
2179
|
+
const inputs = await cargoTestRunnerInputs(workspaceRoot, workspace, [plan.package.dir]);
|
|
2067
2180
|
const archive = cargoTargetDependency(currentProjectName, {
|
|
2068
2181
|
projectName: workspace.rootProjectName,
|
|
2069
2182
|
targetName: CARGO_TEST_ARCHIVE_TARGET,
|
|
2070
2183
|
});
|
|
2071
2184
|
for (const piece of plan.pieces) {
|
|
2072
2185
|
targetNames.push(piece.targetName);
|
|
2073
|
-
targets[piece.targetName] =
|
|
2074
|
-
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2075
|
-
cache: true,
|
|
2076
|
-
inputs,
|
|
2077
|
-
dependsOn: [archive],
|
|
2078
|
-
options: {
|
|
2079
|
-
command: `extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2080
|
-
cargoFrozen(`nextest run ${reuseExtraction} --workspace-remap . -E '${piece.selector}'${piece.extra} --no-tests=pass --user-config-file none ${toolConfig}`),
|
|
2081
|
-
cwd: workspace.projectRoot,
|
|
2082
|
-
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
2083
|
-
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2084
|
-
},
|
|
2085
|
-
};
|
|
2186
|
+
targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
|
|
2086
2187
|
}
|
|
2087
2188
|
}
|
|
2088
2189
|
return targetNames;
|
|
2089
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
|
+
}
|
|
2090
2295
|
function hasCargoTargetDependency(dependencies, expected) {
|
|
2091
2296
|
if (typeof expected === 'string') {
|
|
2092
2297
|
return dependencies.includes(expected);
|