@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/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
|
7
7
|
import {
|
|
@@ -13,8 +13,9 @@ import {
|
|
|
13
13
|
} from 'nx/src/devkit-exports.js';
|
|
14
14
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
15
15
|
import { parse as parseToml } from 'smol-toml';
|
|
16
|
+
import { type ParsedCommandLine, parseJsonConfigFileContent, readConfigFile, sys as typescriptSys } from 'typescript';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { BOUNDED_TEST_IDLE_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './bounded-test-policy.js';
|
|
18
19
|
import {
|
|
19
20
|
CARGO_CLOSURE_INPUT,
|
|
20
21
|
type CargoClosureSource,
|
|
@@ -22,7 +23,11 @@ import {
|
|
|
22
23
|
indexedCargoManifests,
|
|
23
24
|
resolveCargoClosureSource,
|
|
24
25
|
} from './cargo-closure-input.js';
|
|
25
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
CARGO_TOOLCHAIN_NAMED_INPUT,
|
|
28
|
+
CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
29
|
+
cargoRuntimeInput,
|
|
30
|
+
} from './cargo-toolchain-policy.js';
|
|
26
31
|
import {
|
|
27
32
|
type AttributedCargoWorkspacePackage,
|
|
28
33
|
attributeCargoWorkspacePackages,
|
|
@@ -34,6 +39,7 @@ import {
|
|
|
34
39
|
type CargoCrossTestTarget,
|
|
35
40
|
type CargoInputsCache,
|
|
36
41
|
cargoPackageTestInputs,
|
|
42
|
+
cargoTestGroupTargetName,
|
|
37
43
|
cargoTestPackageTargetName,
|
|
38
44
|
createCargoInputsCache,
|
|
39
45
|
exceptionalTestFilter,
|
|
@@ -41,6 +47,9 @@ import {
|
|
|
41
47
|
listCargoWorkspacePackages,
|
|
42
48
|
NEXTEST_REPO_CONFIG_PATH,
|
|
43
49
|
nextestToolConfigArg,
|
|
50
|
+
PLUGIN_NEXTEST_CONFIG_PATH,
|
|
51
|
+
type SerialTestGroup,
|
|
52
|
+
serialTestGroups,
|
|
44
53
|
} from './cargo-workspace.js';
|
|
45
54
|
import {
|
|
46
55
|
CARGO_CROSS_LINT_COMMAND,
|
|
@@ -54,6 +63,7 @@ import {
|
|
|
54
63
|
cargoCrossTestTargetName,
|
|
55
64
|
cargoFrozen,
|
|
56
65
|
} from './cross-check-policy.js';
|
|
66
|
+
import type { EslintFileSet } from './eslint-file-set.js';
|
|
57
67
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
58
68
|
import {
|
|
59
69
|
EXTRACTED_BINARIES_METADATA,
|
|
@@ -61,15 +71,19 @@ import {
|
|
|
61
71
|
EXTRACTED_TARGET_DIR,
|
|
62
72
|
NEXTEST_EXTRACT_BIN,
|
|
63
73
|
} from './nextest-extraction.js';
|
|
74
|
+
import { runtimeInput, shellWord } from './runtime-input.js';
|
|
64
75
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
76
|
+
import { postTasksExecution, preTasksExecution } from './task-results.js';
|
|
77
|
+
import { SHARD_TIMINGS_EXECUTOR, SHARD_TIMINGS_TARGET, timingsShardedSuite } from './test-timings.js';
|
|
65
78
|
import {
|
|
66
79
|
isBuildOutputTargetName,
|
|
67
80
|
isTestRunnerTargetName,
|
|
68
81
|
PLATFORM_TARGET_GLOBS,
|
|
69
82
|
RELEASE_CONFIGURATION,
|
|
70
83
|
} from './workspace-config-policy.js';
|
|
84
|
+
import { globIndexedFiles } from './workspace-index.js';
|
|
71
85
|
|
|
72
|
-
export { CARGO_TEST_COMPILE_TARGET };
|
|
86
|
+
export { CARGO_TEST_COMPILE_TARGET, postTasksExecution, preTasksExecution };
|
|
73
87
|
|
|
74
88
|
/** Makes a version live and proves it answers; never cached. */
|
|
75
89
|
export const DEPLOY_TARGET = 'deploy';
|
|
@@ -78,8 +92,8 @@ export const DEPLOY_BUILD_TARGET = 'deploy-build';
|
|
|
78
92
|
|
|
79
93
|
/** The workspace-wide manifests a release rewrites: the version of every member, and the lockfile mirror of it. */
|
|
80
94
|
const RELEASE_REWRITTEN_WORKSPACE_INPUTS = ['{workspaceRoot}/package.json', '{workspaceRoot}/bun.lock'];
|
|
81
|
-
/** Installed
|
|
82
|
-
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
95
|
+
/** Installed patch bytes and pins affect the compiler; Markdown explains them but is not loaded. */
|
|
96
|
+
const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*', '!{workspaceRoot}/patches/**/*.md'];
|
|
83
97
|
/**
|
|
84
98
|
* The workspace's own base config, hashed for every TypeScript task whether or
|
|
85
99
|
* not this project's chain reaches it: it is where a workspace puts the options
|
|
@@ -88,6 +102,23 @@ const TYPESCRIPT_PATCH_INPUTS = ['{workspaceRoot}/patches/**/*'];
|
|
|
88
102
|
*/
|
|
89
103
|
const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
90
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The native compiler a typecheck runs, apart from the one emit runs: devenv.smoo.nix builds it
|
|
107
|
+
* from a pinned source revision and exports its path. The typecheck targets run it directly,
|
|
108
|
+
* not through ttsc: ttsc auto-loads a dependency's transform plugin (typia) and then checks
|
|
109
|
+
* inside that plugin's host, which links ttsc's own compiler and never runs the pinned one.
|
|
110
|
+
* Transform diagnostics stay enforced where the transform runs: for the lib program in `tsc-js`'s
|
|
111
|
+
* emit, for test files when the test runner transforms them. A test file no test executes has
|
|
112
|
+
* its types checked here but its transform calls checked nowhere. Hashed by the store path,
|
|
113
|
+
* which carries the revision, so a compiler bump misses the cache. The command refuses an unset
|
|
114
|
+
* variable: falling back would check with another compiler under the same key.
|
|
115
|
+
*/
|
|
116
|
+
const TYPECHECK_COMPILER_ENV = 'SMOO_TYPECHECK_TSC';
|
|
117
|
+
const TYPECHECK_COMPILER_INPUT = { env: TYPECHECK_COMPILER_ENV };
|
|
118
|
+
function typecheckCommand(args: string): string {
|
|
119
|
+
return `"\${${TYPECHECK_COMPILER_ENV}:?is unset, enter the devenv shell (devenv.smoo.nix builds the typecheck compiler)}" ${args}`;
|
|
120
|
+
}
|
|
121
|
+
|
|
91
122
|
/**
|
|
92
123
|
* The two release-rewritten files hashed by field instead of by byte, for a
|
|
93
124
|
* check that only reads them.
|
|
@@ -97,9 +128,18 @@ const WORKSPACE_TSCONFIG_BASE_INPUT = '{workspaceRoot}/tsconfig.base.json';
|
|
|
97
128
|
* name, version and dependency specifiers — and every one of those is already
|
|
98
129
|
* hashed from the member's own `package.json`. Dropping that section keeps the
|
|
99
130
|
* resolution table, which is the reason the lockfile is an input at all.
|
|
131
|
+
*
|
|
132
|
+
* The root manifest also drops `scripts`, `smoo` and `nx`. No lint or
|
|
133
|
+
* typecheck reads them: `scripts` are commands a developer runs, `smoo` holds
|
|
134
|
+
* the developer links whose linked bytes reach the hash only through their own
|
|
135
|
+
* inputs, and the root project's `nx` configuration is hashed as that
|
|
136
|
+
* project's configuration. Hashing them made a root `postinstall` edit or a
|
|
137
|
+
* developer-link edit re-key every lint task (74, measured in a consumer
|
|
138
|
+
* workspace). The dependency fields, `overrides`, `patchedDependencies` and
|
|
139
|
+
* `workspaces` stay hashed.
|
|
100
140
|
*/
|
|
101
141
|
const VERSIONLESS_TOOLCHAIN_MANIFEST_INPUTS = [
|
|
102
|
-
{ json: '{workspaceRoot}/package.json', excludeFields: ['version'] },
|
|
142
|
+
{ json: '{workspaceRoot}/package.json', excludeFields: ['version', 'scripts', 'smoo', 'nx'] },
|
|
103
143
|
{ json: '{workspaceRoot}/bun.lock', excludeFields: ['workspaces'] },
|
|
104
144
|
];
|
|
105
145
|
|
|
@@ -304,35 +344,95 @@ const ESLINT_CONFIG_FILES = [
|
|
|
304
344
|
'eslint.config.cts',
|
|
305
345
|
];
|
|
306
346
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
347
|
+
/** Every JavaScript and TypeScript module kind ESLint is handed. */
|
|
348
|
+
const ESLINT_SOURCES_GLOB = '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}';
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* The JavaScript and TypeScript files of Nx's workspace file index, listed once
|
|
352
|
+
* per graph computation; `null` when no workspace ESLint config enables ESLint.
|
|
353
|
+
*
|
|
354
|
+
* The ESLint file list is part of the lint target's command, metadata and
|
|
355
|
+
* inputs, and Nx hashes the whole target configuration into every task that
|
|
356
|
+
* reaches the project. A walk of the tree also listed gitignored generated
|
|
357
|
+
* modules a build had left on disk, so every such task's key depended on
|
|
358
|
+
* whether a build had run in that checkout: one workspace's graph listed them
|
|
359
|
+
* and a fresh fork's did not, which alone re-keyed 197 of 510 gate tasks.
|
|
360
|
+
* Drawing the list from the index makes the plugin and the hasher agree on one
|
|
361
|
+
* file set.
|
|
362
|
+
*/
|
|
363
|
+
async function indexedEslintSources(workspaceRoot: string): Promise<ReadonlySet<string> | null> {
|
|
364
|
+
if (!ESLINT_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) return null;
|
|
365
|
+
return new Set(await globIndexedFiles(workspaceRoot, [ESLINT_SOURCES_GLOB]));
|
|
320
366
|
}
|
|
321
367
|
|
|
322
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Read a tsconfig with this plugin's own TypeScript. `@nx/js`'s readTsConfig does an
|
|
370
|
+
* undeclared `require('typescript')` resolved from its own location: where that lands on the
|
|
371
|
+
* TypeScript 7 native package (whose entry exports only its version), `sys` is undefined and
|
|
372
|
+
* graph construction dies reading `sys.readFile`. The plugin declares TypeScript 6, whose
|
|
373
|
+
* `sys` this uses, so the resolution is the one this package's manifest promises.
|
|
374
|
+
*/
|
|
375
|
+
function readTestTsConfig(testConfig: string): ParsedCommandLine {
|
|
376
|
+
const readResult = readConfigFile(testConfig, typescriptSys.readFile);
|
|
377
|
+
return parseJsonConfigFileContent(readResult.config, typescriptSys, dirname(testConfig));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function projectLintCommands(
|
|
381
|
+
projectRoot: string,
|
|
382
|
+
workspaceRoot: string,
|
|
383
|
+
eslintSources: ReadonlySet<string> | null,
|
|
384
|
+
): { commands: string[]; inputs: string[]; eslintFileSet: EslintFileSet | null } {
|
|
323
385
|
const commands: string[] = [];
|
|
386
|
+
const inputs: string[] = [];
|
|
387
|
+
let eslintFileSet: EslintFileSet | null = null;
|
|
324
388
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
325
389
|
const quote = (path: string) => `'${path.replaceAll("'", "'\"'\"'")}'`;
|
|
326
390
|
if (BIOME_CONFIG_FILES.some((name) => existsSync(join(workspaceRoot, name)))) {
|
|
327
391
|
commands.push(`biome check --files-ignore-unknown=true ${quote(projectRoot)}`);
|
|
328
392
|
}
|
|
329
|
-
if (
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
393
|
+
if (eslintSources !== null) {
|
|
394
|
+
const sourcePrefix = projectRoot === '.' ? 'src/' : `${posix.normalize(projectRoot)}/src/`;
|
|
395
|
+
const sourceFiles = new Set<string>();
|
|
396
|
+
for (const path of eslintSources) {
|
|
397
|
+
if (
|
|
398
|
+
path.startsWith(sourcePrefix) &&
|
|
399
|
+
!path.slice(sourcePrefix.length).split('/').slice(0, -1).some(isNonSourceDirectory)
|
|
400
|
+
) {
|
|
401
|
+
sourceFiles.add(path);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const testConfig = join(absoluteProjectRoot, 'tsconfig.test.json');
|
|
405
|
+
if (existsSync(testConfig)) {
|
|
406
|
+
// A test program can live anywhere the declaration selects, not just src.
|
|
407
|
+
// Use the compiler's file set and the existing declaration-chain hasher,
|
|
408
|
+
// so inherited includes and files outside this project keep their keys.
|
|
409
|
+
const program: ParsedCommandLine = readTestTsConfig(testConfig);
|
|
410
|
+
const errors = program.errors.filter(({ code }) => code !== 18003);
|
|
411
|
+
if (errors.length > 0) {
|
|
412
|
+
throw new Error(
|
|
413
|
+
`${testConfig}: ${errors.map(({ code, messageText }) => `TS${code}: ${JSON.stringify(messageText)}`).join('; ')}`,
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
inputs.push('{projectRoot}/tsconfig.test.json');
|
|
417
|
+
for (const file of program.fileNames) {
|
|
418
|
+
const path = relative(workspaceRoot, file).split(sep).join('/');
|
|
419
|
+
if (path === '..' || path.startsWith('../') || isAbsolute(path)) {
|
|
420
|
+
throw new Error(`${testConfig}: test source ${file} is outside the workspace and cannot be hashed`);
|
|
421
|
+
}
|
|
422
|
+
// Only a module Nx indexes is linted and keyed. An ignored one is build
|
|
423
|
+
// output that a fresh checkout lacks; a JSON file is not ESLint's.
|
|
424
|
+
if (!eslintSources.has(path) || path.split('/').some(isNonSourceDirectory)) continue;
|
|
425
|
+
sourceFiles.add(path);
|
|
426
|
+
inputs.push(`{workspaceRoot}/${path}`);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (sourceFiles.size > 0) {
|
|
430
|
+
const files = [...sourceFiles].sort();
|
|
431
|
+
eslintFileSet = { command: `eslint ${files.map(quote).join(' ')}`, files };
|
|
432
|
+
commands.push(eslintFileSet.command);
|
|
333
433
|
}
|
|
334
434
|
}
|
|
335
|
-
return commands;
|
|
435
|
+
return { commands, inputs: [...new Set(inputs)], eslintFileSet };
|
|
336
436
|
}
|
|
337
437
|
|
|
338
438
|
type NapiArchitecture = 'arm64' | 'x64';
|
|
@@ -415,22 +515,16 @@ const CARGO_INPUTS = [
|
|
|
415
515
|
// build really reads is the package's `napi` block (binary name, targets) and
|
|
416
516
|
// the `@napi-rs/cli` it runs; those are hashed as such by napiInputs().
|
|
417
517
|
const CARGO_OUTPUT_INPUTS = CARGO_INPUTS;
|
|
418
|
-
const REPO_ROOT_CARGO_OUTPUT_INPUTS = [
|
|
419
|
-
'{workspaceRoot}/**/*.rs',
|
|
420
|
-
'{workspaceRoot}/**/Cargo.toml',
|
|
421
|
-
'{workspaceRoot}/Cargo.lock',
|
|
422
|
-
'{workspaceRoot}/**/.cargo/config.toml',
|
|
423
|
-
'{workspaceRoot}/scripts/*.sh',
|
|
424
|
-
'!{workspaceRoot}/**/target/**',
|
|
425
|
-
];
|
|
426
518
|
// The toolchain half of a cargo task's identity lives in its own module
|
|
427
519
|
// because `smoo monorepo validate` reads the same two constants to refuse a
|
|
428
520
|
// declaration that drops it. See cargo-toolchain-policy.ts for why it is the
|
|
429
521
|
// declared pin and not the ambient environment.
|
|
430
522
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return
|
|
523
|
+
/** A runtime input that changes when the file's bytes do: the runtime hashes the file itself. */
|
|
524
|
+
function fileHashInput(path: string): { runtime: string } {
|
|
525
|
+
return runtimeInput(
|
|
526
|
+
`bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' ${shellWord(path)}`,
|
|
527
|
+
);
|
|
434
528
|
}
|
|
435
529
|
|
|
436
530
|
/**
|
|
@@ -478,9 +572,11 @@ function napiInputs(projectRoot: string, repoRooted: boolean): TargetConfigurati
|
|
|
478
572
|
// by its path from there whichever way the Cargo invocation is rooted.
|
|
479
573
|
const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
|
|
480
574
|
return [
|
|
481
|
-
|
|
575
|
+
CARGO_CLOSURE_INPUT,
|
|
576
|
+
'{projectRoot}/scripts/*.sh',
|
|
577
|
+
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
482
578
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
483
|
-
|
|
579
|
+
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
484
580
|
{ externalDependencies: ['@napi-rs/cli'] },
|
|
485
581
|
];
|
|
486
582
|
}
|
|
@@ -564,11 +660,11 @@ function cargoWasmTargetDirectory(
|
|
|
564
660
|
): string {
|
|
565
661
|
const cwd = repoRooted ? '.' : projectRoot;
|
|
566
662
|
const crateDir = posix.join(cwd, posix.dirname(config.manifestPath));
|
|
567
|
-
const owner =
|
|
568
|
-
cargoWorkspace
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
663
|
+
const owner = cargoWorkspace?.packages.some(
|
|
664
|
+
(plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir,
|
|
665
|
+
)
|
|
666
|
+
? cargoWorkspace.projectRoot
|
|
667
|
+
: crateDir;
|
|
572
668
|
return posix.relative(cwd, posix.join(owner, 'target'));
|
|
573
669
|
}
|
|
574
670
|
|
|
@@ -593,7 +689,9 @@ function createCargoWasmTarget(
|
|
|
593
689
|
executor: 'nx:run-commands',
|
|
594
690
|
cache: true,
|
|
595
691
|
dependsOn: ['^build'],
|
|
596
|
-
inputs: repoRooted
|
|
692
|
+
inputs: repoRooted
|
|
693
|
+
? [CARGO_CLOSURE_INPUT, '{workspaceRoot}/scripts/*.sh', '{projectRoot}/scripts/*.sh']
|
|
694
|
+
: CARGO_OUTPUT_INPUTS,
|
|
597
695
|
outputs: [`{projectRoot}/${config.outputDirectory}`],
|
|
598
696
|
options: {
|
|
599
697
|
command: buildCommand('dev'),
|
|
@@ -718,9 +816,15 @@ function createCargoCrossTestTargets(
|
|
|
718
816
|
): Record<string, TargetConfiguration> {
|
|
719
817
|
const { target: triple, cargo } = crossTarget;
|
|
720
818
|
const archiveFile = cargoCrossTestArchiveFile(triple);
|
|
819
|
+
const archiveCommand = sequence([
|
|
820
|
+
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
821
|
+
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
822
|
+
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
823
|
+
]);
|
|
824
|
+
const archiveExecutor = 'nx:run-commands';
|
|
721
825
|
return {
|
|
722
826
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
723
|
-
executor:
|
|
827
|
+
executor: archiveExecutor,
|
|
724
828
|
cache: true,
|
|
725
829
|
// The toolchain inputs every cached cargo target carries, plus the
|
|
726
830
|
// declared driver's own bytes. Those toolchain inputs are attached
|
|
@@ -732,21 +836,18 @@ function createCargoCrossTestTargets(
|
|
|
732
836
|
// must never hash equal to the same sources built under another. The
|
|
733
837
|
// declared driver is hashed by its own bytes; nothing samples the shell
|
|
734
838
|
// that supplies it, which is why this hash is the same bare and inside
|
|
735
|
-
// the cross profile.
|
|
839
|
+
// the cross profile. For the same reason it names its npm packages here.
|
|
736
840
|
inputs: [
|
|
737
841
|
...archiveInputs,
|
|
738
842
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
739
843
|
...(cargo === undefined ? [] : [`{projectRoot}/${cargo}`]),
|
|
740
844
|
cargoRuntimeInput(projectRoot, 'rustc -vV && cargo -V && cargo nextest --version'),
|
|
845
|
+
{ externalDependencies: cargoCommandNpmPackages({ executor: archiveExecutor }, archiveCommand) },
|
|
741
846
|
],
|
|
742
847
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
743
848
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
744
849
|
options: {
|
|
745
|
-
command:
|
|
746
|
-
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
747
|
-
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
748
|
-
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
749
|
-
]),
|
|
850
|
+
command: archiveCommand,
|
|
750
851
|
cwd: projectRoot,
|
|
751
852
|
// `CARGO` is cargo's own driver variable and the only seam nextest
|
|
752
853
|
// offers: it shells out to `$CARGO metadata` and
|
|
@@ -768,7 +869,7 @@ function createCargoCrossTestTargets(
|
|
|
768
869
|
`cargo-nextest nextest run --archive-file ${archiveFile} --workspace-remap . ` +
|
|
769
870
|
`--no-tests=pass --user-config-file none ${toolConfig}`,
|
|
770
871
|
cwd: projectRoot,
|
|
771
|
-
|
|
872
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
772
873
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
773
874
|
},
|
|
774
875
|
},
|
|
@@ -784,13 +885,47 @@ function createCargoTestTarget(projectRoot: string): TargetConfiguration {
|
|
|
784
885
|
options: {
|
|
785
886
|
command: cargoFrozen('test --workspace'),
|
|
786
887
|
cwd: projectRoot,
|
|
787
|
-
|
|
888
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
788
889
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
789
890
|
},
|
|
790
891
|
};
|
|
791
892
|
}
|
|
792
893
|
|
|
793
894
|
const PLUGIN_NEXTEST_CONFIG = fileURLToPath(new URL('../nextest.toml', import.meta.url));
|
|
895
|
+
/**
|
|
896
|
+
* The nextest run-wrapper a serial group names to bound each test's code time.
|
|
897
|
+
* The group's target hashes it, so changing the wrapper reruns the group.
|
|
898
|
+
*/
|
|
899
|
+
const PLUGIN_NEXTEST_CODE_BOUND = fileURLToPath(new URL('../src/nextest-code-bound.ts', import.meta.url));
|
|
900
|
+
|
|
901
|
+
const PLUGIN_PACKAGE = '@smoothbricks/nx-plugin';
|
|
902
|
+
/**
|
|
903
|
+
* Whether this plugin runs as an installed npm package. Inside the repository
|
|
904
|
+
* that develops it, it is a workspace project, and Nx refuses a workspace
|
|
905
|
+
* project named as an `externalDependencies` entry.
|
|
906
|
+
*/
|
|
907
|
+
const PLUGIN_IS_INSTALLED = fileURLToPath(new URL('..', import.meta.url))
|
|
908
|
+
.split(sep)
|
|
909
|
+
.includes('node_modules');
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* The npm packages a cached cargo target runs, for its `externalDependencies`.
|
|
913
|
+
* Cargo runs none. A target this plugin's executor runs, or whose command reads
|
|
914
|
+
* the installed plugin's files (the nextest tool config, the archive
|
|
915
|
+
* extractor), runs the plugin. Without the input Nx keys every task whose
|
|
916
|
+
* executor is not an `@nx/` one on every package in the lockfile, so a
|
|
917
|
+
* lockfile-only commit re-ran every cargo verdict.
|
|
918
|
+
*/
|
|
919
|
+
export function cargoCommandNpmPackages(
|
|
920
|
+
target: TargetConfiguration,
|
|
921
|
+
commandText: string,
|
|
922
|
+
installed = PLUGIN_IS_INSTALLED,
|
|
923
|
+
): string[] {
|
|
924
|
+
const runsPlugin =
|
|
925
|
+
target.executor?.startsWith(`${PLUGIN_PACKAGE}:`) === true ||
|
|
926
|
+
commandText.includes(`node_modules/${PLUGIN_PACKAGE}/`);
|
|
927
|
+
return installed && runsPlugin ? [PLUGIN_PACKAGE] : [];
|
|
928
|
+
}
|
|
794
929
|
|
|
795
930
|
/**
|
|
796
931
|
* How far the versionless manifest treatment reaches in this workspace.
|
|
@@ -873,8 +1008,10 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
|
|
|
873
1008
|
const results: CreateNodesResultV2 = [];
|
|
874
1009
|
const errors: Array<[file: string | null, error: Error]> = [];
|
|
875
1010
|
let cargoWorkspaces: CargoWorkspace[];
|
|
1011
|
+
let eslintSources: ReadonlySet<string> | null;
|
|
876
1012
|
try {
|
|
877
|
-
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot);
|
|
1013
|
+
cargoWorkspaces = await resolveCargoWorkspaces(projectConfigurationFiles, context.workspaceRoot, hostPlatform);
|
|
1014
|
+
eslintSources = await indexedEslintSources(context.workspaceRoot);
|
|
878
1015
|
} catch (error) {
|
|
879
1016
|
throw new AggregateCreateNodesError([[null, error instanceof Error ? error : new Error(String(error))]], results);
|
|
880
1017
|
}
|
|
@@ -900,6 +1037,7 @@ function createNodesHandler(hostPlatform: NapiPlatform | null): CreateNodesHandl
|
|
|
900
1037
|
context.workspaceRoot,
|
|
901
1038
|
hostPlatform,
|
|
902
1039
|
cargoWorkspaces,
|
|
1040
|
+
eslintSources,
|
|
903
1041
|
versionless,
|
|
904
1042
|
),
|
|
905
1043
|
]);
|
|
@@ -939,7 +1077,7 @@ function isBuildOutputPackageJson(packageJsonPath: string): boolean {
|
|
|
939
1077
|
return BUILD_OUTPUT_SEGMENTS.some((segment) => normalized.includes(segment));
|
|
940
1078
|
}
|
|
941
1079
|
|
|
942
|
-
export default { createNodesV2 };
|
|
1080
|
+
export default { createNodesV2, postTasksExecution, preTasksExecution };
|
|
943
1081
|
|
|
944
1082
|
interface PackageJson {
|
|
945
1083
|
bin?: unknown;
|
|
@@ -1023,6 +1161,7 @@ async function createProjectTargets(
|
|
|
1023
1161
|
workspaceRoot: string,
|
|
1024
1162
|
hostPlatform: NapiPlatform | null,
|
|
1025
1163
|
cargoWorkspaces: readonly CargoWorkspace[],
|
|
1164
|
+
eslintSources: ReadonlySet<string> | null,
|
|
1026
1165
|
versionless: VersionlessManifestPolicy | null,
|
|
1027
1166
|
) {
|
|
1028
1167
|
const projectRoot = dirname(packageJsonPath);
|
|
@@ -1120,11 +1259,17 @@ async function createProjectTargets(
|
|
|
1120
1259
|
targets.typecheck = {
|
|
1121
1260
|
executor: 'nx:run-commands',
|
|
1122
1261
|
cache: true,
|
|
1123
|
-
inputs: [
|
|
1262
|
+
inputs: [
|
|
1263
|
+
selfProduction,
|
|
1264
|
+
dependencyProduction,
|
|
1265
|
+
...checkInputs,
|
|
1266
|
+
TYPECHECK_COMPILER_INPUT,
|
|
1267
|
+
'{projectRoot}/tsconfig.lib.json',
|
|
1268
|
+
],
|
|
1124
1269
|
outputs: [],
|
|
1125
1270
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
1126
1271
|
options: {
|
|
1127
|
-
command: '
|
|
1272
|
+
command: typecheckCommand('-p tsconfig.lib.json --noEmit'),
|
|
1128
1273
|
cwd: projectRoot,
|
|
1129
1274
|
},
|
|
1130
1275
|
};
|
|
@@ -1134,10 +1279,16 @@ async function createProjectTargets(
|
|
|
1134
1279
|
targets['typecheck-tests'] = {
|
|
1135
1280
|
executor: 'nx:run-commands',
|
|
1136
1281
|
cache: true,
|
|
1137
|
-
inputs: [
|
|
1282
|
+
inputs: [
|
|
1283
|
+
selfDefault,
|
|
1284
|
+
dependencyProduction,
|
|
1285
|
+
...checkInputs,
|
|
1286
|
+
TYPECHECK_COMPILER_INPUT,
|
|
1287
|
+
'{projectRoot}/tsconfig.test.json',
|
|
1288
|
+
],
|
|
1138
1289
|
dependsOn: ['typecheck'],
|
|
1139
1290
|
options: {
|
|
1140
|
-
command: '
|
|
1291
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit'),
|
|
1141
1292
|
cwd: projectRoot,
|
|
1142
1293
|
},
|
|
1143
1294
|
};
|
|
@@ -1145,7 +1296,7 @@ async function createProjectTargets(
|
|
|
1145
1296
|
executor: 'nx:run-commands',
|
|
1146
1297
|
continuous: true,
|
|
1147
1298
|
options: {
|
|
1148
|
-
command: '
|
|
1299
|
+
command: typecheckCommand('-p tsconfig.test.json --noEmit --watch'),
|
|
1149
1300
|
cwd: projectRoot,
|
|
1150
1301
|
},
|
|
1151
1302
|
};
|
|
@@ -1270,7 +1421,7 @@ async function createProjectTargets(
|
|
|
1270
1421
|
targets[CARGO_TEST_COMPILE_TARGET].inputs = workspaceCargoInputs;
|
|
1271
1422
|
targets[CARGO_TEST_ARCHIVE_TARGET] = createCargoTestArchiveTarget(
|
|
1272
1423
|
cargoWorkspaceRoot,
|
|
1273
|
-
nextestToolConfigArg(
|
|
1424
|
+
nextestToolConfigArg(cargoWorkspaceRoot),
|
|
1274
1425
|
);
|
|
1275
1426
|
// `archive.include` lives in the repository's nextest config, so that file
|
|
1276
1427
|
// decides what the archive CONTAINS, not merely how a run behaves.
|
|
@@ -1282,14 +1433,26 @@ async function createProjectTargets(
|
|
|
1282
1433
|
for (const crossTarget of listCargoCrossTestTargets(join(workspaceRoot, cargoWorkspaceRoot))) {
|
|
1283
1434
|
Object.assign(
|
|
1284
1435
|
targets,
|
|
1285
|
-
createCargoCrossTestTargets(
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1436
|
+
createCargoCrossTestTargets(cargoWorkspaceRoot, nextestToolConfigArg(cargoWorkspaceRoot), crossTarget, [
|
|
1437
|
+
...workspaceCargoInputs,
|
|
1438
|
+
`{projectRoot}/${NEXTEST_REPO_CONFIG_PATH}`,
|
|
1439
|
+
]),
|
|
1440
|
+
);
|
|
1441
|
+
}
|
|
1442
|
+
// A serial group's filter can span members, so no single crate owns it. The root
|
|
1443
|
+
// owns each group's runner beside the archive it executes, and gives it the inputs
|
|
1444
|
+
// of exactly the members its filter can select from (`filterScope`): a group scoped
|
|
1445
|
+
// to its packages reruns only when their sources or local dependencies change,
|
|
1446
|
+
// and an unscoped one hashes every member, as the archive itself does.
|
|
1447
|
+
for (const group of cargoWorkspace.serialGroups) {
|
|
1448
|
+
targets[cargoTestGroupTargetName(group.group)] = cargoTestGroupTarget(
|
|
1449
|
+
cargoWorkspace,
|
|
1450
|
+
await cargoTestRunnerInputs(workspaceRoot, cargoWorkspace, serialGroupMemberDirs(cargoWorkspace, group)),
|
|
1451
|
+
group,
|
|
1291
1452
|
);
|
|
1292
1453
|
}
|
|
1454
|
+
// Every project's crate pieces. The serial groups' runners are the gate's (`test`, below), so
|
|
1455
|
+
// `cargo-test` is the ordinary suite alone and a run of it never reaches a group's real-image tests.
|
|
1293
1456
|
const aggregateDependencies = cargoWorkspace.packages.flatMap((plan) =>
|
|
1294
1457
|
plan.pieces.map((piece) =>
|
|
1295
1458
|
cargoTargetDependency(projectName, {
|
|
@@ -1357,13 +1520,6 @@ async function createProjectTargets(
|
|
|
1357
1520
|
cwd: cargoWorkspaceRoot,
|
|
1358
1521
|
},
|
|
1359
1522
|
};
|
|
1360
|
-
if (!targets.test && !('test' in declaredTargets) && typeof packageJson.scripts?.test !== 'string') {
|
|
1361
|
-
targets.test = {
|
|
1362
|
-
executor: 'nx:noop',
|
|
1363
|
-
cache: true,
|
|
1364
|
-
dependsOn: [CARGO_TEST_TARGET],
|
|
1365
|
-
};
|
|
1366
|
-
}
|
|
1367
1523
|
// Mutation runs are minutes-to-hours: never cached, never part of build/lint.
|
|
1368
1524
|
// CI runs these per-PR via `cargo mutants --in-diff` (see mutants.toml docs).
|
|
1369
1525
|
targets.mutation = {
|
|
@@ -1396,6 +1552,8 @@ async function createProjectTargets(
|
|
|
1396
1552
|
workspaceRoot,
|
|
1397
1553
|
cargoWorkspace,
|
|
1398
1554
|
);
|
|
1555
|
+
// Serial-group runners belong to the workspace root, outside inferred ordinary tests. Explicit repository
|
|
1556
|
+
// aggregates can reach them; their own inputs decide whether each runner executes or replays from cache.
|
|
1399
1557
|
if (!isCargoWorkspaceRoot) {
|
|
1400
1558
|
targets[CARGO_TEST_TARGET] = {
|
|
1401
1559
|
executor: 'nx:noop',
|
|
@@ -1424,6 +1582,7 @@ async function createProjectTargets(
|
|
|
1424
1582
|
targets.test = {
|
|
1425
1583
|
executor: 'nx:noop',
|
|
1426
1584
|
cache: true,
|
|
1585
|
+
// Ordinary tests never infer an edge to a serial group; host aggregates are explicit repository config.
|
|
1427
1586
|
dependsOn: [CARGO_TEST_TARGET],
|
|
1428
1587
|
};
|
|
1429
1588
|
}
|
|
@@ -1517,6 +1676,8 @@ async function createProjectTargets(
|
|
|
1517
1676
|
|
|
1518
1677
|
// Cache verdicts and dedicated artifacts, never Cargo's shared mutable build
|
|
1519
1678
|
// directories. Resolve tool versions from the command's actual directory.
|
|
1679
|
+
// Name the npm packages the command runs (cargoCommandNpmPackages) unless
|
|
1680
|
+
// the target already does.
|
|
1520
1681
|
for (const [name, target] of Object.entries(targets)) {
|
|
1521
1682
|
const text = targetCommandText(target);
|
|
1522
1683
|
if (!text.includes(CARGO_FROZEN_PREFIX)) continue;
|
|
@@ -1528,10 +1689,13 @@ async function createProjectTargets(
|
|
|
1528
1689
|
: text.includes('nextest ')
|
|
1529
1690
|
? ' && cargo nextest --version'
|
|
1530
1691
|
: '';
|
|
1692
|
+
const inputs = target.inputs ?? CARGO_INPUTS;
|
|
1693
|
+
const namesPackages = inputs.some((input) => typeof input === 'object' && 'externalDependencies' in input);
|
|
1531
1694
|
target.inputs = [
|
|
1532
|
-
...
|
|
1695
|
+
...inputs,
|
|
1533
1696
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
1534
1697
|
cargoRuntimeInput(typeof cwd === 'string' ? cwd : projectRoot, `rustc -vV && cargo -V${versions}`),
|
|
1698
|
+
...(namesPackages ? [] : [{ externalDependencies: cargoCommandNpmPackages(target, text) }]),
|
|
1535
1699
|
];
|
|
1536
1700
|
}
|
|
1537
1701
|
|
|
@@ -1550,12 +1714,17 @@ async function createProjectTargets(
|
|
|
1550
1714
|
// A crate whose project also builds the debug cdylib runs its tests after
|
|
1551
1715
|
// that build: the tests dlopen what `napi-debug` writes into `target/debug`,
|
|
1552
1716
|
// and an archived test binary still loads it from this tree.
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1717
|
+
const runners = [
|
|
1718
|
+
...cargoPackagePlans.flatMap((plan) => plan.pieces.map((piece) => piece.targetName)),
|
|
1719
|
+
// The root owns the serial groups' runners, so they take its build as its pieces do.
|
|
1720
|
+
...(ownsCargoWorkspaceTargets
|
|
1721
|
+
? cargoWorkspace.serialGroups.map((group) => cargoTestGroupTargetName(group.group))
|
|
1722
|
+
: []),
|
|
1723
|
+
];
|
|
1724
|
+
for (const name of runners) {
|
|
1725
|
+
const target = targets[name];
|
|
1726
|
+
if (target && !hasCargoTargetDependency(target.dependsOn ?? [], 'napi-debug')) {
|
|
1727
|
+
target.dependsOn = [...(target.dependsOn ?? []), 'napi-debug'];
|
|
1559
1728
|
}
|
|
1560
1729
|
}
|
|
1561
1730
|
} else if (napiDebug) {
|
|
@@ -1731,16 +1900,42 @@ async function createProjectTargets(
|
|
|
1731
1900
|
}
|
|
1732
1901
|
}
|
|
1733
1902
|
|
|
1734
|
-
|
|
1903
|
+
// A Bun suite that `--shard` splits and a `--timings` manifest balances gets a
|
|
1904
|
+
// check, which `lint` depends on, that the manifest names every file the
|
|
1905
|
+
// shards run: Bun charges an unnamed file the median, and unnamed files
|
|
1906
|
+
// cluster into one shard. Uncached, because Bun's discovery also finds
|
|
1907
|
+
// gitignored files that no Nx input keys, and the check only walks a tree.
|
|
1908
|
+
const sharded = timingsShardedSuite(projectRoot, declaredTargets);
|
|
1909
|
+
if (!sharded.ok) {
|
|
1910
|
+
throw new Error(`${packageJsonPath}: ${sharded.error}`);
|
|
1911
|
+
}
|
|
1912
|
+
if (sharded.suite !== null) {
|
|
1913
|
+
targets[SHARD_TIMINGS_TARGET] = {
|
|
1914
|
+
executor: SHARD_TIMINGS_EXECUTOR,
|
|
1915
|
+
cache: false,
|
|
1916
|
+
outputs: [],
|
|
1917
|
+
options: { cwd: sharded.suite.cwd, args: sharded.suite.args },
|
|
1918
|
+
};
|
|
1919
|
+
validationTargets.push(SHARD_TIMINGS_TARGET);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
const {
|
|
1923
|
+
commands: lintCommands,
|
|
1924
|
+
inputs: lintProgramInputs,
|
|
1925
|
+
eslintFileSet,
|
|
1926
|
+
} = projectLintCommands(projectRoot, workspaceRoot, eslintSources);
|
|
1735
1927
|
if (validationTargets.length > 0 || lintCommands.length > 0) {
|
|
1736
1928
|
targets.lint = {
|
|
1737
1929
|
executor: lintCommands.length > 0 ? 'nx:run-commands' : 'nx:noop',
|
|
1930
|
+
...(eslintFileSet === null ? {} : { metadata: { eslintFileSet } }),
|
|
1738
1931
|
cache: true,
|
|
1739
1932
|
dependsOn: validationTargets,
|
|
1740
1933
|
outputs: [],
|
|
1741
1934
|
inputs: [
|
|
1742
1935
|
selfDefault,
|
|
1936
|
+
dependencyProduction,
|
|
1743
1937
|
...checkInputs,
|
|
1938
|
+
...lintProgramInputs,
|
|
1744
1939
|
...[...BIOME_CONFIG_FILES, ...ESLINT_CONFIG_FILES].flatMap((name) => [
|
|
1745
1940
|
`{workspaceRoot}/${name}`,
|
|
1746
1941
|
`{projectRoot}/${name}`,
|
|
@@ -2157,8 +2352,8 @@ function createNapiTestTarget(projectRoot: string, hasDedicatedBunfig: boolean):
|
|
|
2157
2352
|
// Routes the package's native loader to the napi-debug artifact under
|
|
2158
2353
|
// .cache/native-debug instead of the packaged dist/native tree.
|
|
2159
2354
|
env: { NAPI_DEBUG_ADDON: '1' },
|
|
2160
|
-
|
|
2161
|
-
killAfterMs:
|
|
2355
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2356
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2162
2357
|
},
|
|
2163
2358
|
};
|
|
2164
2359
|
}
|
|
@@ -2268,6 +2463,8 @@ interface CargoWorkspace {
|
|
|
2268
2463
|
packages: CargoPackagePlan[];
|
|
2269
2464
|
rootProjectName: string;
|
|
2270
2465
|
projectRoot: string;
|
|
2466
|
+
/** The repository's serial test groups, each with one runner beside the archive (see `serialTestGroups`). */
|
|
2467
|
+
serialGroups: SerialTestGroup[];
|
|
2271
2468
|
/** One derivation memo for the whole graph computation (see cargoPackageTestInputs). */
|
|
2272
2469
|
inputsCache: CargoInputsCache;
|
|
2273
2470
|
/** The content-keyed Cargo resolve, checked before publishing any project's closure. */
|
|
@@ -2285,6 +2482,7 @@ function cargoTargetDependency(currentProjectName: string, target: CargoTargetRe
|
|
|
2285
2482
|
async function resolveCargoWorkspaces(
|
|
2286
2483
|
packageJsonPaths: readonly string[],
|
|
2287
2484
|
workspaceRoot: string,
|
|
2485
|
+
hostPlatform: NapiPlatform | null,
|
|
2288
2486
|
): Promise<CargoWorkspace[]> {
|
|
2289
2487
|
const projects: Array<{ name: string; root: string }> = [];
|
|
2290
2488
|
for (const packageJsonPath of packageJsonPaths) {
|
|
@@ -2317,16 +2515,26 @@ async function resolveCargoWorkspaces(
|
|
|
2317
2515
|
).map((pkg) => ({ ...pkg, dir: posix.relative(rootProject.root, pkg.dir) || '.' }));
|
|
2318
2516
|
const packages: CargoPackagePlan[] = [];
|
|
2319
2517
|
const exceptional = exceptionalTestFilter(PLUGIN_NEXTEST_CONFIG);
|
|
2518
|
+
// A serial group runs only where its declared cfg holds, macOS. Elsewhere it is not inferred and
|
|
2519
|
+
// no piece excludes its tests: nextest does not apply the group there, so the pieces select them.
|
|
2520
|
+
const serialGroups =
|
|
2521
|
+
hostPlatform?.targetFamily === 'macos'
|
|
2522
|
+
? serialTestGroups(join(workspaceRoot, rootProject.root, NEXTEST_REPO_CONFIG_PATH))
|
|
2523
|
+
: [];
|
|
2524
|
+
// A serial group's tests belong to that group's one runner, so every per-crate
|
|
2525
|
+
// piece excludes them: each test is selected by exactly one target.
|
|
2526
|
+
const serialExclusion = serialGroups.length === 0 ? null : serialGroups.map((group) => group.filter).join(' or ');
|
|
2527
|
+
const notSerial = serialExclusion === null ? [] : [`not (${serialExclusion})`];
|
|
2320
2528
|
for (const pkg of attributed) {
|
|
2321
2529
|
const pieces: CargoTestPiece[] = [];
|
|
2322
2530
|
const sharded = pkg.testShards > 1;
|
|
2323
2531
|
const pin = sharded && exceptional !== null ? exceptional : null;
|
|
2324
|
-
const
|
|
2532
|
+
const ordinary = [`package(${pkg.name})`, ...(pin === null ? [] : [`not (${pin})`]), ...notSerial].join(' and ');
|
|
2325
2533
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2326
2534
|
const targetName = cargoTestPackageTargetName(pkg.name, sharded ? `shard${index}` : undefined);
|
|
2327
2535
|
pieces.push({
|
|
2328
2536
|
extra: sharded ? ` --partition hash:${index}/${pkg.testShards}` : '',
|
|
2329
|
-
selector:
|
|
2537
|
+
selector: ordinary,
|
|
2330
2538
|
targetName,
|
|
2331
2539
|
});
|
|
2332
2540
|
}
|
|
@@ -2334,7 +2542,7 @@ async function resolveCargoWorkspaces(
|
|
|
2334
2542
|
for (let index = 1; index <= pkg.testShards; index += 1) {
|
|
2335
2543
|
pieces.push({
|
|
2336
2544
|
extra: ` --partition hash:${index}/${pkg.testShards}`,
|
|
2337
|
-
selector: `package(${pkg.name}) and (${pin})`,
|
|
2545
|
+
selector: [`package(${pkg.name}) and (${pin})`, ...notSerial].join(' and '),
|
|
2338
2546
|
targetName: cargoTestPackageTargetName(pkg.name, `${CARGO_TEST_EXCEPTIONS_SUFFIX}-shard${index}`),
|
|
2339
2547
|
});
|
|
2340
2548
|
}
|
|
@@ -2346,6 +2554,7 @@ async function resolveCargoWorkspaces(
|
|
|
2346
2554
|
rootProjectName: rootProject.name,
|
|
2347
2555
|
projectRoot: rootProject.root,
|
|
2348
2556
|
inputsCache: createCargoInputsCache(),
|
|
2557
|
+
serialGroups,
|
|
2349
2558
|
});
|
|
2350
2559
|
}
|
|
2351
2560
|
if (found.length === 0) return [];
|
|
@@ -2359,6 +2568,7 @@ async function resolveCargoWorkspaces(
|
|
|
2359
2568
|
posix.join(workspace.projectRoot, 'Cargo.toml'),
|
|
2360
2569
|
workspaceRoot,
|
|
2361
2570
|
indexedManifests,
|
|
2571
|
+
workspace.inputsCache.compiledInFiles,
|
|
2362
2572
|
),
|
|
2363
2573
|
})),
|
|
2364
2574
|
);
|
|
@@ -2394,9 +2604,11 @@ async function resolveCargoWorkspaces(
|
|
|
2394
2604
|
* from `--archive-file` is the Rust standard library directory: nextest has no
|
|
2395
2605
|
* flag to remap it, so a run uses the producing toolchain's own sysroot rather
|
|
2396
2606
|
* than the archived copy of it — the same toolchain, because the archive's hash
|
|
2397
|
-
* covers the toolchain pin. The extraction lives
|
|
2398
|
-
* in an Nx output: it
|
|
2399
|
-
* outputs
|
|
2607
|
+
* covers the toolchain pin. The extraction lives in Cargo's own target
|
|
2608
|
+
* directory (`<target_directory>/nextest-extracted`), never in an Nx output: it
|
|
2609
|
+
* is a multi-GB tree for a cached verdict that has no outputs, rebuilt from the
|
|
2610
|
+
* archive like the rest of the build tree, and a checkout that keeps its build
|
|
2611
|
+
* state off its source tree keeps the extraction there with it.
|
|
2400
2612
|
*
|
|
2401
2613
|
* `--workspace-remap .` is not cosmetic. An archive records the ABSOLUTE paths
|
|
2402
2614
|
* of the tree that produced it; without the remap, a restored archive hands
|
|
@@ -2416,9 +2628,9 @@ async function resolveCargoWorkspaces(
|
|
|
2416
2628
|
* happened to fall.
|
|
2417
2629
|
*
|
|
2418
2630
|
* The two filtersets are exact complements, so their union is the crate whatever
|
|
2419
|
-
* either one matches. Every piece uses `--no-
|
|
2420
|
-
* member may expose no nextest tests, a small suite can
|
|
2421
|
-
* shard empty, and platform-specific exceptions may not exist on this host.
|
|
2631
|
+
* either one matches. Every piece uses `--no-fail-fast`, so one failing test does not stop the rest of its
|
|
2632
|
+
* piece, and `--no-tests=pass`: a valid workspace member may expose no nextest tests, a small suite can
|
|
2633
|
+
* leave a declared hash shard empty, and platform-specific exceptions may not exist on this host.
|
|
2422
2634
|
* Manifest discovery proves the package exists and generates the selector from
|
|
2423
2635
|
* its Cargo name, so accepting an empty run cannot hide a misspelled package.
|
|
2424
2636
|
*
|
|
@@ -2439,70 +2651,156 @@ async function addCargoTestTargets(
|
|
|
2439
2651
|
workspace: CargoWorkspace,
|
|
2440
2652
|
): Promise<string[]> {
|
|
2441
2653
|
const targetNames: string[] = [];
|
|
2442
|
-
const toolConfig = nextestToolConfigArg(workspaceRoot, workspace.projectRoot, PLUGIN_NEXTEST_CONFIG);
|
|
2443
|
-
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2444
|
-
const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
|
|
2445
|
-
const reuseExtraction =
|
|
2446
|
-
`--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2447
|
-
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2448
|
-
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2449
2654
|
for (const plan of workspace.packages) {
|
|
2450
2655
|
if (plan.package.projectRoot !== projectRoot) {
|
|
2451
2656
|
continue;
|
|
2452
2657
|
}
|
|
2453
|
-
|
|
2454
|
-
// `{projectRoot}` glob hashes only files this project owns, and sibling
|
|
2455
|
-
// manifests belong to whichever nested project holds them.
|
|
2456
|
-
const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
|
|
2457
|
-
// A workspace nextest build unifies features across every selected member.
|
|
2458
|
-
// A sibling manifest can therefore change this crate's tests without being
|
|
2459
|
-
// a path dependency. Track those manifests, not unrelated sibling sources.
|
|
2460
|
-
//
|
|
2461
|
-
// The repository's own nextest config layers OVER the plugin's tool config,
|
|
2462
|
-
// so it decides timeouts, groups and archive contents: a cached verdict that
|
|
2463
|
-
// ignored it would survive the change that invalidates it.
|
|
2464
|
-
const inputs: NonNullable<TargetConfiguration['inputs']> = [
|
|
2465
|
-
...new Set([
|
|
2466
|
-
...(await cargoPackageTestInputs({
|
|
2467
|
-
workspaceRoot,
|
|
2468
|
-
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2469
|
-
memberDir: plan.package.dir,
|
|
2470
|
-
cache: workspace.inputsCache,
|
|
2471
|
-
})),
|
|
2472
|
-
...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
|
|
2473
|
-
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2474
|
-
]),
|
|
2475
|
-
{
|
|
2476
|
-
runtime: `bun -e 'console.log(new Bun.CryptoHasher("sha256").update(require("node:fs").readFileSync(process.argv[1])).digest("hex"))' '${PLUGIN_NEXTEST_CONFIG.replaceAll("'", "'\"'\"'")}'`,
|
|
2477
|
-
},
|
|
2478
|
-
];
|
|
2658
|
+
const inputs = await cargoTestRunnerInputs(workspaceRoot, workspace, [plan.package.dir]);
|
|
2479
2659
|
const archive = cargoTargetDependency(currentProjectName, {
|
|
2480
2660
|
projectName: workspace.rootProjectName,
|
|
2481
2661
|
targetName: CARGO_TEST_ARCHIVE_TARGET,
|
|
2482
2662
|
});
|
|
2483
2663
|
for (const piece of plan.pieces) {
|
|
2484
2664
|
targetNames.push(piece.targetName);
|
|
2485
|
-
targets[piece.targetName] =
|
|
2486
|
-
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2487
|
-
cache: true,
|
|
2488
|
-
inputs,
|
|
2489
|
-
dependsOn: [archive],
|
|
2490
|
-
options: {
|
|
2491
|
-
command:
|
|
2492
|
-
`extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2493
|
-
cargoFrozen(
|
|
2494
|
-
`nextest run ${reuseExtraction} --workspace-remap . -E '${piece.selector}'${piece.extra} --no-tests=pass --user-config-file none ${toolConfig}`,
|
|
2495
|
-
),
|
|
2496
|
-
cwd: workspace.projectRoot,
|
|
2497
|
-
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
2498
|
-
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2499
|
-
},
|
|
2500
|
-
};
|
|
2665
|
+
targets[piece.targetName] = cargoTestRunnerTarget(workspace, archive, inputs, piece);
|
|
2501
2666
|
}
|
|
2502
2667
|
}
|
|
2503
2668
|
return targetNames;
|
|
2504
2669
|
}
|
|
2505
2670
|
|
|
2671
|
+
/**
|
|
2672
|
+
* The member directories a serial group's runner hashes: the packages its filter is scoped to,
|
|
2673
|
+
* or every member when it is not. A scope naming a package that is not a member is a config
|
|
2674
|
+
* error, refused rather than hashed as nothing.
|
|
2675
|
+
*/
|
|
2676
|
+
function serialGroupMemberDirs(workspace: CargoWorkspace, group: SerialTestGroup): string[] {
|
|
2677
|
+
if (group.scope.kind === 'workspace') {
|
|
2678
|
+
return workspace.packages.map((plan) => plan.package.dir);
|
|
2679
|
+
}
|
|
2680
|
+
return group.scope.packages.map((name) => {
|
|
2681
|
+
const member = workspace.packages.find((plan) => plan.package.name === name);
|
|
2682
|
+
if (member === undefined) {
|
|
2683
|
+
throw new Error(
|
|
2684
|
+
`test-group "${group.group}" selects package(${name}), which is not a member of the Cargo workspace at ` +
|
|
2685
|
+
`${workspace.projectRoot || '.'}`,
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
return member.package.dir;
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
/**
|
|
2693
|
+
* The inputs of the runners that select crates from one cargo workspace: the
|
|
2694
|
+
* sources of the crates they select, every member manifest, and the repository's
|
|
2695
|
+
* nextest config.
|
|
2696
|
+
*
|
|
2697
|
+
* Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
|
|
2698
|
+
* `{projectRoot}` glob hashes only files this project owns, and sibling manifests
|
|
2699
|
+
* belong to whichever nested project holds them. A workspace nextest build unifies
|
|
2700
|
+
* features across every selected member, so a sibling manifest can change a crate's
|
|
2701
|
+
* tests without being a path dependency: track those manifests, not unrelated
|
|
2702
|
+
* sibling sources.
|
|
2703
|
+
*
|
|
2704
|
+
* The repository's own nextest config layers OVER the plugin's tool config, so it
|
|
2705
|
+
* decides timeouts, groups and archive contents: a cached verdict that ignored it
|
|
2706
|
+
* would survive the change that invalidates it.
|
|
2707
|
+
*/
|
|
2708
|
+
async function cargoTestRunnerInputs(
|
|
2709
|
+
workspaceRoot: string,
|
|
2710
|
+
workspace: CargoWorkspace,
|
|
2711
|
+
memberDirs: readonly string[],
|
|
2712
|
+
): Promise<NonNullable<TargetConfiguration['inputs']>> {
|
|
2713
|
+
const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
|
|
2714
|
+
const sources = await Promise.all(
|
|
2715
|
+
memberDirs.map((memberDir) =>
|
|
2716
|
+
cargoPackageTestInputs({
|
|
2717
|
+
workspaceRoot,
|
|
2718
|
+
absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
|
|
2719
|
+
memberDir,
|
|
2720
|
+
cache: workspace.inputsCache,
|
|
2721
|
+
}),
|
|
2722
|
+
),
|
|
2723
|
+
);
|
|
2724
|
+
return [
|
|
2725
|
+
...new Set([
|
|
2726
|
+
...sources.flat(),
|
|
2727
|
+
...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
|
|
2728
|
+
posix.join(inputRoot, NEXTEST_REPO_CONFIG_PATH),
|
|
2729
|
+
]),
|
|
2730
|
+
fileHashInput(PLUGIN_NEXTEST_CONFIG_PATH),
|
|
2731
|
+
];
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/**
|
|
2735
|
+
* One `nextest run` over a filterset against the workspace's archive. Every runner of the
|
|
2736
|
+
* workspace builds its command here, so the extraction, reuse-build, tool config and cwd cannot
|
|
2737
|
+
* drift between the per-crate pieces and the serial groups.
|
|
2738
|
+
*/
|
|
2739
|
+
function nextestRunnerCommand(workspace: CargoWorkspace, selector: string, flags: string): string {
|
|
2740
|
+
const toolConfig = nextestToolConfigArg(workspace.projectRoot);
|
|
2741
|
+
// Relative to the runner's cwd, so the hashed command is the same in every checkout.
|
|
2742
|
+
const extractBin = posix.join(posix.relative(workspace.projectRoot, '.'), NEXTEST_EXTRACT_BIN);
|
|
2743
|
+
const reuseExtraction =
|
|
2744
|
+
`--binaries-metadata "$extracted/${EXTRACTED_BINARIES_METADATA}" ` +
|
|
2745
|
+
`--cargo-metadata "$extracted/${EXTRACTED_CARGO_METADATA}" ` +
|
|
2746
|
+
`--target-dir-remap "$extracted/${EXTRACTED_TARGET_DIR}"`;
|
|
2747
|
+
return (
|
|
2748
|
+
`extracted="$(node ${extractBin} ${CARGO_TEST_ARCHIVE_FILE})" && ` +
|
|
2749
|
+
cargoFrozen(
|
|
2750
|
+
`nextest run ${reuseExtraction} --workspace-remap . -E ${shellWord(selector)}${flags} --user-config-file none ${toolConfig}`,
|
|
2751
|
+
)
|
|
2752
|
+
);
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
/** One per-crate piece: a bounded run of its partition of the archive's tests. */
|
|
2756
|
+
function cargoTestRunnerTarget(
|
|
2757
|
+
workspace: CargoWorkspace,
|
|
2758
|
+
archive: CargoTargetDependency,
|
|
2759
|
+
inputs: NonNullable<TargetConfiguration['inputs']>,
|
|
2760
|
+
piece: CargoTestPiece,
|
|
2761
|
+
): TargetConfiguration {
|
|
2762
|
+
return {
|
|
2763
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2764
|
+
cache: true,
|
|
2765
|
+
inputs,
|
|
2766
|
+
dependsOn: [archive],
|
|
2767
|
+
options: {
|
|
2768
|
+
command: nextestRunnerCommand(workspace, piece.selector, `${piece.extra} --no-fail-fast --no-tests=pass`),
|
|
2769
|
+
cwd: workspace.projectRoot,
|
|
2770
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2771
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2772
|
+
},
|
|
2773
|
+
};
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
/**
|
|
2777
|
+
* A serial group's runner: a nextest run of the group's selection with no partition and no thread
|
|
2778
|
+
* flag, the group being serial because its test-group declares `max-threads = 1`, so it asks for one
|
|
2779
|
+
* CPU token. It is bounded by progress like every test target: a group of slow tests runs as long as
|
|
2780
|
+
* it keeps finishing them. It runs `--no-fail-fast`, so an ordinary failure runs the group's remaining
|
|
2781
|
+
* tests and a failed verdict lists the failed ones, and `--no-tests=fail`, so a filter that selects
|
|
2782
|
+
* nothing fails rather than passing a group that ran no test.
|
|
2783
|
+
*/
|
|
2784
|
+
function cargoTestGroupTarget(
|
|
2785
|
+
workspace: CargoWorkspace,
|
|
2786
|
+
inputs: NonNullable<TargetConfiguration['inputs']>,
|
|
2787
|
+
group: SerialTestGroup,
|
|
2788
|
+
): TargetConfiguration {
|
|
2789
|
+
return {
|
|
2790
|
+
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
2791
|
+
cache: true,
|
|
2792
|
+
inputs: [...inputs, fileHashInput(PLUGIN_NEXTEST_CODE_BOUND)],
|
|
2793
|
+
dependsOn: [CARGO_TEST_ARCHIVE_TARGET],
|
|
2794
|
+
options: {
|
|
2795
|
+
command: nextestRunnerCommand(workspace, group.filter, ' --no-fail-fast --no-tests=fail'),
|
|
2796
|
+
cwd: workspace.projectRoot,
|
|
2797
|
+
idleTimeoutMs: BOUNDED_TEST_IDLE_TIMEOUT_MS,
|
|
2798
|
+
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2799
|
+
parallelism: 1,
|
|
2800
|
+
},
|
|
2801
|
+
};
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2506
2804
|
function hasCargoTargetDependency(
|
|
2507
2805
|
dependencies: readonly CargoTargetDependency[],
|
|
2508
2806
|
expected: CargoTargetDependency,
|