@convesoft/nx-rust 0.0.0 → 1.0.0-rc.2
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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/PLUGIN.md +106 -0
- package/README.md +51 -1
- package/docs/artifacts.mara.md +374 -0
- package/docs/caching.mara.md +999 -0
- package/docs/ci.mara.md +308 -0
- package/docs/configuration.mara.md +508 -0
- package/docs/decisions.mara.md +3267 -0
- package/docs/execution.mara.md +533 -0
- package/docs/index.mara.md +51 -0
- package/docs/product.mara.md +366 -0
- package/docs/release.mara.md +493 -0
- package/docs/setup.mara.md +486 -0
- package/docs/targets.mara.md +704 -0
- package/docs/testing.mara.md +431 -0
- package/docs/verification.mara.md +465 -0
- package/docs/workspaces.mara.md +445 -0
- package/executors.json +35 -0
- package/generators.json +19 -0
- package/package.json +17 -4
- package/src/cargo/build-settings.d.ts +61 -0
- package/src/cargo/build-settings.js +103 -0
- package/src/cargo/build-settings.js.map +1 -0
- package/src/cargo/configured-runner.d.ts +36 -0
- package/src/cargo/configured-runner.js +99 -0
- package/src/cargo/configured-runner.js.map +1 -0
- package/src/cargo/configured-tools.d.ts +35 -0
- package/src/cargo/configured-tools.js +46 -0
- package/src/cargo/configured-tools.js.map +1 -0
- package/src/cargo/dep-info-basedir.d.ts +18 -0
- package/src/cargo/dep-info-basedir.js +38 -0
- package/src/cargo/dep-info-basedir.js.map +1 -0
- package/src/cargo/directories.d.ts +40 -0
- package/src/cargo/directories.js +89 -0
- package/src/cargo/directories.js.map +1 -0
- package/src/cargo/host-triple.d.ts +7 -0
- package/src/cargo/host-triple.js +21 -0
- package/src/cargo/host-triple.js.map +1 -0
- package/src/cargo/lockfile.d.ts +63 -0
- package/src/cargo/lockfile.js +157 -0
- package/src/cargo/lockfile.js.map +1 -0
- package/src/cargo/metadata.d.ts +114 -0
- package/src/cargo/metadata.js +37 -0
- package/src/cargo/metadata.js.map +1 -0
- package/src/cargo/package-specs.d.ts +54 -0
- package/src/cargo/package-specs.js +109 -0
- package/src/cargo/package-specs.js.map +1 -0
- package/src/cargo/paths-crates.d.ts +27 -0
- package/src/cargo/paths-crates.js +69 -0
- package/src/cargo/paths-crates.js.map +1 -0
- package/src/cargo/print-artifact-folders.d.ts +1 -0
- package/src/cargo/print-artifact-folders.js +58 -0
- package/src/cargo/print-artifact-folders.js.map +1 -0
- package/src/cargo/redirections.d.ts +90 -0
- package/src/cargo/redirections.js +200 -0
- package/src/cargo/redirections.js.map +1 -0
- package/src/cargo/run-cargo.d.ts +31 -0
- package/src/cargo/run-cargo.js +75 -0
- package/src/cargo/run-cargo.js.map +1 -0
- package/src/cargo/target-triples.d.ts +98 -0
- package/src/cargo/target-triples.js +265 -0
- package/src/cargo/target-triples.js.map +1 -0
- package/src/cargo/version-req.d.ts +12 -0
- package/src/cargo/version-req.js +122 -0
- package/src/cargo/version-req.js.map +1 -0
- package/src/cargo/warnings-setting.d.ts +24 -0
- package/src/cargo/warnings-setting.js +81 -0
- package/src/cargo/warnings-setting.js.map +1 -0
- package/src/compatibility/cargo-version.d.ts +43 -0
- package/src/compatibility/cargo-version.js +83 -0
- package/src/compatibility/cargo-version.js.map +1 -0
- package/src/compatibility/nx-bridge.d.ts +312 -0
- package/src/compatibility/nx-bridge.js +407 -0
- package/src/compatibility/nx-bridge.js.map +1 -0
- package/src/compatibility/nx-version.d.ts +104 -0
- package/src/compatibility/nx-version.js +272 -0
- package/src/compatibility/nx-version.js.map +1 -0
- package/src/executors/affected-inputs.d.ts +29 -0
- package/src/executors/affected-inputs.js +259 -0
- package/src/executors/affected-inputs.js.map +1 -0
- package/src/executors/affected-run.d.ts +54 -0
- package/src/executors/affected-run.js +394 -0
- package/src/executors/affected-run.js.map +1 -0
- package/src/executors/affected.d.ts +239 -0
- package/src/executors/affected.js +589 -0
- package/src/executors/affected.js.map +1 -0
- package/src/executors/baseline-context.d.ts +85 -0
- package/src/executors/baseline-context.js +227 -0
- package/src/executors/baseline-context.js.map +1 -0
- package/src/executors/baseline.d.ts +123 -0
- package/src/executors/baseline.js +356 -0
- package/src/executors/baseline.js.map +1 -0
- package/src/executors/batch.d.ts +75 -0
- package/src/executors/batch.js +434 -0
- package/src/executors/batch.js.map +1 -0
- package/src/executors/build-records.d.ts +110 -0
- package/src/executors/build-records.js +267 -0
- package/src/executors/build-records.js.map +1 -0
- package/src/executors/cargo/executor.d.ts +28 -0
- package/src/executors/cargo/executor.js +58 -0
- package/src/executors/cargo/executor.js.map +1 -0
- package/src/executors/cargo/schema.json +58 -0
- package/src/executors/cargo-invocation.d.ts +81 -0
- package/src/executors/cargo-invocation.js +109 -0
- package/src/executors/cargo-invocation.js.map +1 -0
- package/src/executors/cargo-output.d.ts +218 -0
- package/src/executors/cargo-output.js +660 -0
- package/src/executors/cargo-output.js.map +1 -0
- package/src/executors/command.d.ts +331 -0
- package/src/executors/command.js +547 -0
- package/src/executors/command.js.map +1 -0
- package/src/executors/coverage-baseline.d.ts +23 -0
- package/src/executors/coverage-baseline.js +284 -0
- package/src/executors/coverage-baseline.js.map +1 -0
- package/src/executors/declared-options.d.ts +21 -0
- package/src/executors/declared-options.js +58 -0
- package/src/executors/declared-options.js.map +1 -0
- package/src/executors/denied-warnings.d.ts +99 -0
- package/src/executors/denied-warnings.js +188 -0
- package/src/executors/denied-warnings.js.map +1 -0
- package/src/executors/digests.d.ts +94 -0
- package/src/executors/digests.js +190 -0
- package/src/executors/digests.js.map +1 -0
- package/src/executors/dotenv-check.d.ts +79 -0
- package/src/executors/dotenv-check.js +553 -0
- package/src/executors/dotenv-check.js.map +1 -0
- package/src/executors/group-invocations.d.ts +80 -0
- package/src/executors/group-invocations.js +253 -0
- package/src/executors/group-invocations.js.map +1 -0
- package/src/executors/group-run.d.ts +114 -0
- package/src/executors/group-run.js +601 -0
- package/src/executors/group-run.js.map +1 -0
- package/src/executors/groups.d.ts +118 -0
- package/src/executors/groups.js +304 -0
- package/src/executors/groups.js.map +1 -0
- package/src/executors/input-check.d.ts +52 -0
- package/src/executors/input-check.js +271 -0
- package/src/executors/input-check.js.map +1 -0
- package/src/executors/kept-files.d.ts +98 -0
- package/src/executors/kept-files.js +341 -0
- package/src/executors/kept-files.js.map +1 -0
- package/src/executors/lockfile/executor.d.ts +16 -0
- package/src/executors/lockfile/executor.js +37 -0
- package/src/executors/lockfile/executor.js.map +1 -0
- package/src/executors/lockfile/schema.json +50 -0
- package/src/executors/napi-build.d.ts +73 -0
- package/src/executors/napi-build.js +420 -0
- package/src/executors/napi-build.js.map +1 -0
- package/src/executors/nextest.d.ts +189 -0
- package/src/executors/nextest.js +504 -0
- package/src/executors/nextest.js.map +1 -0
- package/src/executors/nx-command.d.ts +95 -0
- package/src/executors/nx-command.js +205 -0
- package/src/executors/nx-command.js.map +1 -0
- package/src/executors/nx-task-files.d.ts +82 -0
- package/src/executors/nx-task-files.js +156 -0
- package/src/executors/nx-task-files.js.map +1 -0
- package/src/executors/print-test-mode.d.ts +1 -0
- package/src/executors/print-test-mode.js +25 -0
- package/src/executors/print-test-mode.js.map +1 -0
- package/src/executors/release-publish/executor.d.ts +24 -0
- package/src/executors/release-publish/executor.js +165 -0
- package/src/executors/release-publish/executor.js.map +1 -0
- package/src/executors/release-publish/schema.json +30 -0
- package/src/executors/run/executor.d.ts +12 -0
- package/src/executors/run/executor.js +27 -0
- package/src/executors/run/executor.js.map +1 -0
- package/src/executors/run/schema.json +45 -0
- package/src/executors/runner-script.d.ts +12 -0
- package/src/executors/runner-script.js +22 -0
- package/src/executors/runner-script.js.map +1 -0
- package/src/executors/runtime-input-check.d.ts +24 -0
- package/src/executors/runtime-input-check.js +87 -0
- package/src/executors/runtime-input-check.js.map +1 -0
- package/src/executors/shared-artifacts.d.ts +44 -0
- package/src/executors/shared-artifacts.js +132 -0
- package/src/executors/shared-artifacts.js.map +1 -0
- package/src/executors/split-words.d.ts +24 -0
- package/src/executors/split-words.js +111 -0
- package/src/executors/split-words.js.map +1 -0
- package/src/executors/stage.d.ts +163 -0
- package/src/executors/stage.js +526 -0
- package/src/executors/stage.js.map +1 -0
- package/src/executors/staged-run.d.ts +24 -0
- package/src/executors/staged-run.js +110 -0
- package/src/executors/staged-run.js.map +1 -0
- package/src/executors/task-env.d.ts +271 -0
- package/src/executors/task-env.js +494 -0
- package/src/executors/task-env.js.map +1 -0
- package/src/executors/task-execution.d.ts +61 -0
- package/src/executors/task-execution.js +122 -0
- package/src/executors/task-execution.js.map +1 -0
- package/src/executors/task-guards.d.ts +112 -0
- package/src/executors/task-guards.js +435 -0
- package/src/executors/task-guards.js.map +1 -0
- package/src/executors/task-options.d.ts +114 -0
- package/src/executors/task-options.js +258 -0
- package/src/executors/task-options.js.map +1 -0
- package/src/executors/task.d.ts +166 -0
- package/src/executors/task.js +527 -0
- package/src/executors/task.js.map +1 -0
- package/src/executors/test-mode.d.ts +185 -0
- package/src/executors/test-mode.js +397 -0
- package/src/executors/test-mode.js.map +1 -0
- package/src/executors/test-runner.d.ts +44 -0
- package/src/executors/test-runner.js +159 -0
- package/src/executors/test-runner.js.map +1 -0
- package/src/executors/test-steps.d.ts +121 -0
- package/src/executors/test-steps.js +566 -0
- package/src/executors/test-steps.js.map +1 -0
- package/src/executors/wasm-build.d.ts +56 -0
- package/src/executors/wasm-build.js +216 -0
- package/src/executors/wasm-build.js.map +1 -0
- package/src/generators/crate/binary.schema.json +28 -0
- package/src/generators/crate/crate.d.ts +24 -0
- package/src/generators/crate/crate.js +108 -0
- package/src/generators/crate/crate.js.map +1 -0
- package/src/generators/crate/enclosing-workspace.d.ts +25 -0
- package/src/generators/crate/enclosing-workspace.js +58 -0
- package/src/generators/crate/enclosing-workspace.js.map +1 -0
- package/src/generators/crate/library.schema.json +28 -0
- package/src/generators/init/graph-check.d.ts +81 -0
- package/src/generators/init/graph-check.js +299 -0
- package/src/generators/init/graph-check.js.map +1 -0
- package/src/generators/init/init.d.ts +23 -0
- package/src/generators/init/init.js +113 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/report.d.ts +19 -0
- package/src/generators/init/report.js +93 -0
- package/src/generators/init/report.js.map +1 -0
- package/src/generators/init/schema.json +9 -0
- package/src/graph/artifact-kinds.d.ts +29 -0
- package/src/graph/artifact-kinds.js +50 -0
- package/src/graph/artifact-kinds.js.map +1 -0
- package/src/graph/artifact-names.d.ts +97 -0
- package/src/graph/artifact-names.js +276 -0
- package/src/graph/artifact-names.js.map +1 -0
- package/src/graph/build-records.d.ts +74 -0
- package/src/graph/build-records.js +104 -0
- package/src/graph/build-records.js.map +1 -0
- package/src/graph/caching.d.ts +148 -0
- package/src/graph/caching.js +681 -0
- package/src/graph/caching.js.map +1 -0
- package/src/graph/clippy-input.d.ts +53 -0
- package/src/graph/clippy-input.js +107 -0
- package/src/graph/clippy-input.js.map +1 -0
- package/src/graph/collisions.d.ts +113 -0
- package/src/graph/collisions.js +156 -0
- package/src/graph/collisions.js.map +1 -0
- package/src/graph/computation-reports.d.ts +89 -0
- package/src/graph/computation-reports.js +216 -0
- package/src/graph/computation-reports.js.map +1 -0
- package/src/graph/declared-files.d.ts +190 -0
- package/src/graph/declared-files.js +600 -0
- package/src/graph/declared-files.js.map +1 -0
- package/src/graph/discovery.d.ts +190 -0
- package/src/graph/discovery.js +661 -0
- package/src/graph/discovery.js.map +1 -0
- package/src/graph/edges.d.ts +25 -0
- package/src/graph/edges.js +94 -0
- package/src/graph/edges.js.map +1 -0
- package/src/graph/entries.d.ts +83 -0
- package/src/graph/entries.js +259 -0
- package/src/graph/entries.js.map +1 -0
- package/src/graph/inputs.d.ts +422 -0
- package/src/graph/inputs.js +756 -0
- package/src/graph/inputs.js.map +1 -0
- package/src/graph/lockfile-task.d.ts +74 -0
- package/src/graph/lockfile-task.js +105 -0
- package/src/graph/lockfile-task.js.map +1 -0
- package/src/graph/names.d.ts +41 -0
- package/src/graph/names.js +34 -0
- package/src/graph/names.js.map +1 -0
- package/src/graph/napi.d.ts +107 -0
- package/src/graph/napi.js +206 -0
- package/src/graph/napi.js.map +1 -0
- package/src/graph/nx-glob.d.ts +36 -0
- package/src/graph/nx-glob.js +152 -0
- package/src/graph/nx-glob.js.map +1 -0
- package/src/graph/nx-internals.d.ts +57 -0
- package/src/graph/nx-internals.js +128 -0
- package/src/graph/nx-internals.js.map +1 -0
- package/src/graph/options.d.ts +32 -0
- package/src/graph/options.js +80 -0
- package/src/graph/options.js.map +1 -0
- package/src/graph/outputs.d.ts +75 -0
- package/src/graph/outputs.js +140 -0
- package/src/graph/outputs.js.map +1 -0
- package/src/graph/path-dependencies.d.ts +122 -0
- package/src/graph/path-dependencies.js +459 -0
- package/src/graph/path-dependencies.js.map +1 -0
- package/src/graph/plugin-package.d.ts +36 -0
- package/src/graph/plugin-package.js +132 -0
- package/src/graph/plugin-package.js.map +1 -0
- package/src/graph/plugin-version.d.ts +20 -0
- package/src/graph/plugin-version.js +153 -0
- package/src/graph/plugin-version.js.map +1 -0
- package/src/graph/projects.d.ts +141 -0
- package/src/graph/projects.js +193 -0
- package/src/graph/projects.js.map +1 -0
- package/src/graph/reached-projects.d.ts +46 -0
- package/src/graph/reached-projects.js +102 -0
- package/src/graph/reached-projects.js.map +1 -0
- package/src/graph/real-path.d.ts +47 -0
- package/src/graph/real-path.js +113 -0
- package/src/graph/real-path.js.map +1 -0
- package/src/graph/redirected-uses.d.ts +98 -0
- package/src/graph/redirected-uses.js +434 -0
- package/src/graph/redirected-uses.js.map +1 -0
- package/src/graph/registration.d.ts +121 -0
- package/src/graph/registration.js +233 -0
- package/src/graph/registration.js.map +1 -0
- package/src/graph/rustfmt-config.d.ts +42 -0
- package/src/graph/rustfmt-config.js +173 -0
- package/src/graph/rustfmt-config.js.map +1 -0
- package/src/graph/script-input.d.ts +46 -0
- package/src/graph/script-input.js +65 -0
- package/src/graph/script-input.js.map +1 -0
- package/src/graph/settings.d.ts +178 -0
- package/src/graph/settings.js +479 -0
- package/src/graph/settings.js.map +1 -0
- package/src/graph/target-defaults-causes.d.ts +33 -0
- package/src/graph/target-defaults-causes.js +202 -0
- package/src/graph/target-defaults-causes.js.map +1 -0
- package/src/graph/target-defaults-layers.d.ts +186 -0
- package/src/graph/target-defaults-layers.js +420 -0
- package/src/graph/target-defaults-layers.js.map +1 -0
- package/src/graph/target-defaults-meaning.d.ts +95 -0
- package/src/graph/target-defaults-meaning.js +292 -0
- package/src/graph/target-defaults-meaning.js.map +1 -0
- package/src/graph/target-defaults-report.d.ts +77 -0
- package/src/graph/target-defaults-report.js +242 -0
- package/src/graph/target-defaults-report.js.map +1 -0
- package/src/graph/target-defaults.d.ts +79 -0
- package/src/graph/target-defaults.js +425 -0
- package/src/graph/target-defaults.js.map +1 -0
- package/src/graph/target-fields.d.ts +16 -0
- package/src/graph/target-fields.js +134 -0
- package/src/graph/target-fields.js.map +1 -0
- package/src/graph/target-tables.d.ts +45 -0
- package/src/graph/target-tables.js +299 -0
- package/src/graph/target-tables.js.map +1 -0
- package/src/graph/targets.d.ts +371 -0
- package/src/graph/targets.js +408 -0
- package/src/graph/targets.js.map +1 -0
- package/src/graph/unification.d.ts +141 -0
- package/src/graph/unification.js +459 -0
- package/src/graph/unification.js.map +1 -0
- package/src/graph/unignored-directories.d.ts +25 -0
- package/src/graph/unignored-directories.js +89 -0
- package/src/graph/unignored-directories.js.map +1 -0
- package/src/graph/visibility.d.ts +17 -0
- package/src/graph/visibility.js +67 -0
- package/src/graph/visibility.js.map +1 -0
- package/src/graph/warnings.d.ts +38 -0
- package/src/graph/warnings.js +77 -0
- package/src/graph/warnings.js.map +1 -0
- package/src/graph/wasm.d.ts +56 -0
- package/src/graph/wasm.js +77 -0
- package/src/graph/wasm.js.map +1 -0
- package/src/index.d.ts +68 -0
- package/src/index.js +109 -0
- package/src/index.js.map +1 -0
- package/src/release/manifests.d.ts +95 -0
- package/src/release/manifests.js +164 -0
- package/src/release/manifests.js.map +1 -0
- package/src/release/places.d.ts +127 -0
- package/src/release/places.js +368 -0
- package/src/release/places.js.map +1 -0
- package/src/release/publish-cargo.d.ts +177 -0
- package/src/release/publish-cargo.js +351 -0
- package/src/release/publish-cargo.js.map +1 -0
- package/src/release/publish-crates.d.ts +124 -0
- package/src/release/publish-crates.js +242 -0
- package/src/release/publish-crates.js.map +1 -0
- package/src/release/publish-environments.d.ts +50 -0
- package/src/release/publish-environments.js +284 -0
- package/src/release/publish-environments.js.map +1 -0
- package/src/release/publish-messages.d.ts +66 -0
- package/src/release/publish-messages.js +273 -0
- package/src/release/publish-messages.js.map +1 -0
- package/src/release/publish-registry.d.ts +27 -0
- package/src/release/publish-registry.js +135 -0
- package/src/release/publish-registry.js.map +1 -0
- package/src/release/publish-settings.d.ts +26 -0
- package/src/release/publish-settings.js +56 -0
- package/src/release/publish-settings.js.map +1 -0
- package/src/release/publish.d.ts +59 -0
- package/src/release/publish.js +620 -0
- package/src/release/publish.js.map +1 -0
- package/src/release/repository.d.ts +73 -0
- package/src/release/repository.js +219 -0
- package/src/release/repository.js.map +1 -0
- package/src/release/requirements.d.ts +34 -0
- package/src/release/requirements.js +30 -0
- package/src/release/requirements.js.map +1 -0
- package/src/release/toml-edit.d.ts +67 -0
- package/src/release/toml-edit.js +453 -0
- package/src/release/toml-edit.js.map +1 -0
- package/src/release/version-actions.d.ts +133 -0
- package/src/release/version-actions.js +474 -0
- package/src/release/version-actions.js.map +1 -0
- package/src/release/version-checks.d.ts +21 -0
- package/src/release/version-checks.js +151 -0
- package/src/release/version-checks.js.map +1 -0
- package/src/release/version-lockfiles.d.ts +61 -0
- package/src/release/version-lockfiles.js +222 -0
- package/src/release/version-lockfiles.js.map +1 -0
- package/src/tools/napi-cli.d.ts +70 -0
- package/src/tools/napi-cli.js +63 -0
- package/src/tools/napi-cli.js.map +1 -0
- package/src/tools/optional-tools.d.ts +121 -0
- package/src/tools/optional-tools.js +303 -0
- package/src/tools/optional-tools.js.map +1 -0
- package/src/tools/print-napi-cli.d.ts +1 -0
- package/src/tools/print-napi-cli.js +24 -0
- package/src/tools/print-napi-cli.js.map +1 -0
package/docs/ci.mara.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Continuous integration
|
|
2
|
+
|
|
3
|
+
> **Status:** the coverage baseline target, `coverage-baseline`, works for a
|
|
4
|
+
> workspace with `affectedTests`.
|
|
5
|
+
|
|
6
|
+
v1 targets a single machine: all Rust tasks of a pipeline run on one runner.
|
|
7
|
+
JS tasks can be distributed as before.
|
|
8
|
+
|
|
9
|
+
## Cache two things in two places
|
|
10
|
+
|
|
11
|
+
| What | Cached by | Key |
|
|
12
|
+
| -------------------------------- | ------------------------------------- | ---------------------------------------------- |
|
|
13
|
+
| Task results and final artifacts | Nx, locally or through a remote cache | The task's inputs ([Caching](caching.mara.md)) |
|
|
14
|
+
| Cargo's build directory | Your CI system's cache | Lockfile and toolchain |
|
|
15
|
+
|
|
16
|
+
Nx never stores the build directory. Without a warm build directory every
|
|
17
|
+
pipeline compiles all dependencies from scratch, and the `workspace-build`
|
|
18
|
+
feature-unification strategy in particular depends on it
|
|
19
|
+
([Batching and features](execution.mara.md)).
|
|
20
|
+
|
|
21
|
+
A pull request pipeline then needs one step:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
nx affected -t lint test build
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Every job that runs `nx` needs cargo, also a job that only builds JS projects,
|
|
28
|
+
because Nx asks Cargo for the crates when it builds the project graph
|
|
29
|
+
([Setup](setup.mara.md)).
|
|
30
|
+
|
|
31
|
+
Set `NX_RUST_LOCKED=true` in pipelines. Every cargo command that a task runs
|
|
32
|
+
then passes `--locked` and fails if `Cargo.lock` is out of date, instead of
|
|
33
|
+
updating it as plain cargo would. The exceptions are `update`, because changing
|
|
34
|
+
the lockfile is its job, and `fmt` and `fmt-check`, because `cargo fmt` rejects
|
|
35
|
+
`--locked`.
|
|
36
|
+
|
|
37
|
+
A task that Nx restores from the cache runs no cargo at all, and locked mode is
|
|
38
|
+
not part of its key. The `lockfile` task of each workspace is not cached,
|
|
39
|
+
though, and passes `--locked`: every run in which it runs fails on an outdated
|
|
40
|
+
`Cargo.lock`, even when every crate task is restored. A job that runs only
|
|
41
|
+
`fmt` or `fmt-check`, excludes task dependencies or runs no Rust task does not
|
|
42
|
+
check the lockfile. To check it there as well, run a command of its own in
|
|
43
|
+
each workspace, outside Nx:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
(cd rust && cargo metadata --format-version 1 --locked > /dev/null)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It fails on an outdated `Cargo.lock` without changing it and compiles nothing.
|
|
50
|
+
It resolves the workspace's dependencies, so like a build it needs the
|
|
51
|
+
registry or a filled Cargo home.
|
|
52
|
+
|
|
53
|
+
To fail a pipeline on compiler and clippy warnings without changing what
|
|
54
|
+
developers get, set `CARGO_BUILD_WARNINGS=deny` in it; Cargo honours it from
|
|
55
|
+
1.97 on. The variable is part of the cache key, so a result that passed
|
|
56
|
+
elsewhere with warnings allowed is not reused
|
|
57
|
+
([Targets](targets.mara.md#warnings)).
|
|
58
|
+
|
|
59
|
+
## The coverage baseline
|
|
60
|
+
|
|
61
|
+
This section applies only with `affectedTests` on ([Testing](testing.mara.md)).
|
|
62
|
+
Selecting affected tests needs per-test coverage data from a commit of the main
|
|
63
|
+
branch, and the plugin's record of the context it was collected in. The
|
|
64
|
+
workspace project's `coverage-baseline` target makes both:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
nx run rust:coverage-baseline
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
It runs `cargo affected collect -- --workspace --no-fail-fast` in the workspace
|
|
71
|
+
root, with the cargo options you give the target, and writes
|
|
72
|
+
`target/affected/coverage.db` and, beside it, `target/affected/nx-rust-context.json`.
|
|
73
|
+
cargo-affected refuses a working tree with uncommitted changes, so collect on a
|
|
74
|
+
clean checkout. The main pipeline maintains the baseline:
|
|
75
|
+
|
|
76
|
+
1. Restore the database and the record from the previous main run.
|
|
77
|
+
2. Run the full `test`. Nx's cache limits it to the crates that changed.
|
|
78
|
+
3. Run `coverage-baseline`, which re-collects only affected and new tests.
|
|
79
|
+
4. Save the database and the record to the CI cache, keyed by commit.
|
|
80
|
+
|
|
81
|
+
The main pipeline does not set `NX_RUST_TEST_MODE`, so in CI its tests run in
|
|
82
|
+
mode `full`.
|
|
83
|
+
|
|
84
|
+
A pull request pipeline sets `NX_RUST_TEST_MODE=affected` and restores the
|
|
85
|
+
database and record for its base commit. Those of an earlier main commit also
|
|
86
|
+
work; the diff is then wider and more tests are selected. A pipeline that
|
|
87
|
+
forgets the variable runs the full suite, which is slower but never wrong.
|
|
88
|
+
|
|
89
|
+
Before it collects, the target compares the record of the last collection
|
|
90
|
+
with the context it collects in now, and asks `cargo affected status` what the
|
|
91
|
+
database holds. It re-collects with `collect --diff` only where the record is
|
|
92
|
+
there and equal and the data is usable. It collects everything into an empty
|
|
93
|
+
database where there is no record (the first run, or a collection that failed
|
|
94
|
+
or was stopped), where the context changed (other options, another value of a
|
|
95
|
+
variable or runtime input that the tests hash, a new toolchain), where the
|
|
96
|
+
data is not usable (a lost database, or a changed lockfile, manifest,
|
|
97
|
+
compiler, `RUSTFLAGS` or build target), or where the oldest collection is
|
|
98
|
+
more commits behind `HEAD` than `fullCollectThreshold`, 100 unless you set it.
|
|
99
|
+
So a main pipeline whose context changes between runs pays one full
|
|
100
|
+
collection, and `--diff` never keeps coverage of another context under the new
|
|
101
|
+
record. Its output says which collection it runs and why.
|
|
102
|
+
|
|
103
|
+
The record holds the cargo options of the collection, the target triple, a
|
|
104
|
+
hash of each environment input of the workspace's `test` tasks and of the
|
|
105
|
+
output of their runtime inputs. A test run whose own differ, or a baseline
|
|
106
|
+
without a record, runs the full suite. So give `coverage-baseline` the same
|
|
107
|
+
`features`, `allFeatures`, `noDefaultFeatures` and `profile` as your test runs,
|
|
108
|
+
in `[workspace.metadata.nx.project.targets.coverage-baseline.options]` or on
|
|
109
|
+
the command line, and run it with the same environment. The collection does
|
|
110
|
+
not load the dotenv files that Nx loads only for `test` tasks: a variable
|
|
111
|
+
that the tests hash and that only `.env.test` sets makes every affected run
|
|
112
|
+
take the full suite, until you set the same value for the collection step as
|
|
113
|
+
well, for example in `.env` or in the step's environment. The target removes
|
|
114
|
+
the record before it collects and writes it only once cargo-affected has
|
|
115
|
+
succeeded, so a collection whose test fails, or that is stopped, leaves no
|
|
116
|
+
record, and pull requests run their full suites until the next collection
|
|
117
|
+
succeeds. Save and restore the two files together, never one without the
|
|
118
|
+
other.
|
|
119
|
+
|
|
120
|
+
A worked example for GitHub Actions, for a workspace in `rust/` whose
|
|
121
|
+
workspace project is `rust`:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
# .github/workflows/main.yml, on push to main
|
|
125
|
+
- uses: actions/cache/restore@v4
|
|
126
|
+
with:
|
|
127
|
+
path: |
|
|
128
|
+
rust/target/affected/coverage.db
|
|
129
|
+
rust/target/affected/nx-rust-context.json
|
|
130
|
+
key: coverage-${{ github.sha }}
|
|
131
|
+
restore-keys: coverage-
|
|
132
|
+
- run: pnpm nx run-many -t test
|
|
133
|
+
- run: pnpm nx run rust:coverage-baseline
|
|
134
|
+
env:
|
|
135
|
+
CARGO_BUILD_JOBS: "4"
|
|
136
|
+
NEXTEST_TEST_THREADS: "4"
|
|
137
|
+
- uses: actions/cache/save@v4
|
|
138
|
+
with:
|
|
139
|
+
path: |
|
|
140
|
+
rust/target/affected/coverage.db
|
|
141
|
+
rust/target/affected/nx-rust-context.json
|
|
142
|
+
key: coverage-${{ github.sha }}
|
|
143
|
+
|
|
144
|
+
# .github/workflows/pr.yml, on pull_request
|
|
145
|
+
- uses: actions/cache/restore@v4
|
|
146
|
+
with:
|
|
147
|
+
path: |
|
|
148
|
+
rust/target/affected/coverage.db
|
|
149
|
+
rust/target/affected/nx-rust-context.json
|
|
150
|
+
key: coverage-${{ github.event.pull_request.base.sha }}
|
|
151
|
+
restore-keys: coverage-
|
|
152
|
+
- run: pnpm nx affected -t test
|
|
153
|
+
env:
|
|
154
|
+
NX_RUST_TEST_MODE: affected
|
|
155
|
+
NEXTEST_TEST_THREADS: "4"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Collection's memory grows with its parallelism, so the example caps it at 4
|
|
159
|
+
build jobs and 4 test threads. `NEXTEST_TEST_THREADS` is part of the record,
|
|
160
|
+
like every `NEXTEST_` variable, so the pull request pipeline sets the same
|
|
161
|
+
value; a pipeline that sets another runs the full suite and names the
|
|
162
|
+
variable. `CARGO_BUILD_JOBS` changes nothing that is compiled and is not
|
|
163
|
+
recorded. Restore only the database and the record, not
|
|
164
|
+
`target/affected/build`, where cargo-affected keeps its instrumented build;
|
|
165
|
+
the restore keys fall back to the newest saved baseline where the exact
|
|
166
|
+
commit has none, which only widens the diff. The database to save holds the
|
|
167
|
+
coverage of every test: 53 MB for ripgrep's 1,220 tests, 400 MB for tokio's
|
|
168
|
+
2,184 with all features, and 8.75 GB for rust-analyzer's 8,314, which
|
|
169
|
+
`actions/cache` compresses with zstd, to 2.6 MB and 404 MB for ripgrep and
|
|
170
|
+
rust-analyzer.
|
|
171
|
+
|
|
172
|
+
Collecting costs time, memory and cache space on every main commit. Measured
|
|
173
|
+
with 4 build jobs and 4 test threads:
|
|
174
|
+
|
|
175
|
+
| Per main commit | ripgrep, 1,220 tests | rust-analyzer, 8,314 tests |
|
|
176
|
+
| -------------------------------------- | -------------------- | -------------------------- |
|
|
177
|
+
| Plain test run of the commit | 3.2–3.7 s | 31–44 s |
|
|
178
|
+
| `collect --diff` after it | 1.1–2.5 s | 52–824 s |
|
|
179
|
+
| Full `collect` into an empty database | 12.5–13.1 s | 645–656 s |
|
|
180
|
+
| Database to save, `zstd -3` compressed | 53 MB, 2.6 MB | 8.75 GB, 404 MB |
|
|
181
|
+
| Peak memory of collection, cache incl. | 1.8 GiB | 6.8 GiB |
|
|
182
|
+
|
|
183
|
+
Collection runs every test it re-collects under instrumentation, and its cost
|
|
184
|
+
grows with the number of tests and the code they reach. On rust-analyzer, whose
|
|
185
|
+
many fast tests run in 21 s, it cost far more on main than any selection could
|
|
186
|
+
save on a pull request. Slow tests make a workspace a candidate for
|
|
187
|
+
`affectedTests`, not a sure gain: where the slow tests are integration tests
|
|
188
|
+
that start a binary or read shared files, the widening of
|
|
189
|
+
[Testing](testing.mara.md) can select the whole suite for common changes and
|
|
190
|
+
leave only the overhead. Not measured here: what pull requests save after that
|
|
191
|
+
widening, the upkeep of the baseline over many commits, and the time to move
|
|
192
|
+
the database between CI runs.
|
|
193
|
+
|
|
194
|
+
Before you switch it on, measure a few representative changes in your own
|
|
195
|
+
repository, each committed on top of a collected commit of main:
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
cargo affected collect -- --workspace --no-fail-fast # once, on main
|
|
199
|
+
# commit a representative change, then time each of these:
|
|
200
|
+
cargo affected collect --diff -- --workspace --no-fail-fast # cost on main
|
|
201
|
+
NX_RUST_TEST_MODE=full nx affected -t test --skip-nx-cache # without selection
|
|
202
|
+
NX_RUST_TEST_MODE=affected nx affected -t test --skip-nx-cache # with selection
|
|
203
|
+
ls -l target/affected/coverage.db # what CI saves
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Add the cargo arguments of your test runs, such as `--all-features`, after
|
|
207
|
+
`--workspace`. cargo-affected builds the instrumented tests in
|
|
208
|
+
`target/affected/build`, so a pipeline that caches `target` caches them as
|
|
209
|
+
well.
|
|
210
|
+
|
|
211
|
+
The target's options, all off by default but the threshold:
|
|
212
|
+
|
|
213
|
+
| Option | Use |
|
|
214
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
215
|
+
| `fullCollectThreshold` | How many commits the oldest collection may lie behind `HEAD` before a full collection replaces `--diff`; 100 |
|
|
216
|
+
| `fullCollect` | Always collect everything into an empty database: a nightly run for tests that depend on state outside the repository, a scheduled recollection, or `collect` as the full run on main where benchmarks justify it |
|
|
217
|
+
| `diffOnly` | Never start a full collection on its own: where only a full one would do, as after a dependency update, collect nothing and keep the baseline, and leave the full collection to a scheduled or batched run with `--fullCollect` |
|
|
218
|
+
| `separateBuildDir` | Build the instrumented tests in `target/affected/build` also where Cargo's configuration sets `build.build-dir`, so that they stay out of a build directory that CI caches |
|
|
219
|
+
|
|
220
|
+
A run of `test` and a collection may overlap, in one `nx` command or in two:
|
|
221
|
+
a test task that reads the baseline while a collection changes it runs its
|
|
222
|
+
full suite, and two collections of one checkout do not run at once, because
|
|
223
|
+
the second fails and says that the first one runs. A collection that was
|
|
224
|
+
killed leaves `target/affected/nx-rust-collect.lock`, which the next one takes
|
|
225
|
+
over; should one be killed during that takeover, it also leaves
|
|
226
|
+
`nx-rust-collect.lock.takeover`. That marker fails a collection only where the
|
|
227
|
+
collection also finds a lock whose process no longer runs, because the
|
|
228
|
+
takeover it would need is refused; the message names both files, which you
|
|
229
|
+
remove once no collection runs. Where there is no lock, the collection runs as
|
|
230
|
+
usual and the marker stays until someone removes it.
|
|
231
|
+
|
|
232
|
+
## Later: distributing Rust tasks
|
|
233
|
+
|
|
234
|
+
v1 does not spread Rust tasks across Nx agents. The only thing v1 does for it
|
|
235
|
+
is keep "build" and "run" apart inside the test executor
|
|
236
|
+
([[DES-TEST-PHASES]]). A distributed mode might look like this:
|
|
237
|
+
|
|
238
|
+
- One workspace-level task builds everything, writes a nextest archive of the
|
|
239
|
+
test binaries and computes the test selection. Both files are Nx outputs, so
|
|
240
|
+
the remote cache delivers them to agents.
|
|
241
|
+
- Per-crate test tasks run from the archive with a package filter. They do not
|
|
242
|
+
invoke cargo, so there is no build lock and no need for batching.
|
|
243
|
+
- Only the build machine compiles. Its build directory stays warm through the
|
|
244
|
+
CI cache, and `check` and `lint` are pinned to it.
|
|
245
|
+
- Only the build machine needs the coverage database; the selection travels as
|
|
246
|
+
a report file.
|
|
247
|
+
- Agents need nextest and the same source checkout, pinned by
|
|
248
|
+
`rust-toolchain.toml`.
|
|
249
|
+
|
|
250
|
+
The costs: the archive can be large and is uploaded again on every change, any
|
|
251
|
+
source change rebuilds it, and tests that read files by path may need changes
|
|
252
|
+
to run from an archive. This is a sketch, not a specification.
|
|
253
|
+
|
|
254
|
+
## Requirements
|
|
255
|
+
|
|
256
|
+
:::mara requirement REQ-BASELINE
|
|
257
|
+
:mid: 01M78FHG7FMF300FJ3R9NCWRAZ
|
|
258
|
+
:title: Maintain the coverage baseline on the main branch
|
|
259
|
+
:status: accepted
|
|
260
|
+
:satisfies: NEED-FAST-TESTS
|
|
261
|
+
|
|
262
|
+
For a workspace with `affectedTests` enabled, a workspace-level task brings the [[TERM-BASELINE]] up to date for the current commit. It re-collects only what changed when usable data from an earlier commit exists, and collects everything when no usable data exists or the earlier data is further behind than a configured threshold.
|
|
263
|
+
:::
|
|
264
|
+
|
|
265
|
+
## Design
|
|
266
|
+
|
|
267
|
+
:::mara design DES-BASELINE
|
|
268
|
+
:mid: 01M78FHG7F1EWYSCPVF4MY7YGF
|
|
269
|
+
:title: Baseline on main
|
|
270
|
+
:status: accepted
|
|
271
|
+
:satisfies: REQ-BASELINE
|
|
272
|
+
:mitigates: RISK-BASELINE-DRIFT
|
|
273
|
+
|
|
274
|
+
The main pipeline runs four steps per workspace:
|
|
275
|
+
|
|
276
|
+
1. Restore the coverage database and its context record from the previous main run.
|
|
277
|
+
2. Run the full `test`; Nx's cache limits it to crates that changed. The pipeline sets no test mode, so in CI the mode is `full` ([[DES-TEST-MODE]]).
|
|
278
|
+
3. Run the collection target, which runs `cargo affected collect --diff` and so re-collects only affected and new tests.
|
|
279
|
+
4. Save the database and the record to the CI cache, keyed by commit.
|
|
280
|
+
|
|
281
|
+
Pull request pipelines set `NX_RUST_TEST_MODE=affected` and restore the database and record for their base commit. An earlier main commit's database also works, with a wider diff.
|
|
282
|
+
|
|
283
|
+
A full `collect` replaces `--diff` when the context record of the last collection is missing, cannot be read, is of another version or differs from the context of this collection (**Choosing the collection**, below), when the report shows no usable data (first run, lost database, or a changed lockfile, manifest, compiler, `RUSTFLAGS` or build target), or when the anchors are more commits behind than a set threshold. The threshold is tuned per repository ([[RISK-BASELINE-DRIFT]]).
|
|
284
|
+
|
|
285
|
+
A full `collect` starts without the previous database: the target removes `target/affected/coverage.db`, its SQLite files `coverage.db-wal` and `coverage.db-shm`, and the context record before it (**Order of writing**, below). Over an existing database cargo-affected first deletes the rows of the current fingerprint and keeps those of up to ten earlier ones, so that on rust-analyzer a full `collect` over the previous database took 957 s against 652 s into an empty one, and the rows of a fingerprint that a changed lockfile left behind would stay in every database saved after it ([[EVD-COVERAGE-COLLECT-COST]]). The removal touches only cargo-affected's own files, never Cargo's directories. The control plane decided this on 16 November 2026 from [[RISK-COVERAGE-COST]]; `cargo affected clean`, the option not taken, deletes the rows by SQL as slowly. To undo it, the target stops removing the files.
|
|
286
|
+
|
|
287
|
+
A `collect --diff` that re-collected half of rust-analyzer's tests, after a change to a core crate, took longer than a full `collect` into an empty database, 749–824 s against 645–656 s. The target still runs `--diff` there: telling beforehand would need `cargo affected status`, which reads the database for about as long as `--diff` does before it runs a test, so that the gain would be small.
|
|
288
|
+
|
|
289
|
+
Collection is a target of the [[TERM-WORKSPACE-PROJECT]]. Restoring and saving the database are steps of the CI system, not of the plugin. Off by default and available as switches: a nightly full run for tests that depend on external state, scheduled or batched recollection after dependency updates, `collect` as the full run on main, and a separate build directory for coverage builds (**The target**, below).
|
|
290
|
+
|
|
291
|
+
**Directories of coverage builds.** By default collection sets no Cargo directory of its own ([[DES-BUILD-DIRS]]), as plain `cargo affected collect` sets none. cargo-affected builds into the artifact directory `target/affected/build` and points the profiles of build scripts there, so that without `build.build-dir` its instrumented build has a build directory of its own. With a `build.build-dir` that both share, the two builds kept their files side by side, and building normally, collecting, and building normally again compiled nothing the second time, on ripgrep and rust-analyzer with Cargo 1.100.0 ([[EVD-COVERAGE-COLLECT-COST]]). The separate build directory is therefore not needed to keep the builds from evicting each other; the switch keeps the instrumented build, about as large as the normal one, out of a build directory that CI caches. The control plane decided on 16 November 2026, from [[REQ-CARGO-UNCHANGED]] and these measurements, against a separate build directory by default; to undo it, the switch becomes the default. Cargo 1.91, the oldest supported version, was not measured: ripgrep at the measured commit needs rustc 1.96. Should an older Cargo make the two builds evict each other in one build directory, the cost is rebuilding, never a wrong result, since Cargo rebuilds what its fingerprints no longer match, and the switch for a separate build directory is the remedy.
|
|
292
|
+
|
|
293
|
+
Collection runs `cargo affected collect -- --workspace --no-fail-fast` with the cargo arguments of the test runs, such as `--all-features`, which cargo-affected's fingerprint does not hold; without `--no-fail-fast` it stopped at the first failing test and stored part of the suite. It gets git's `diff.relative` as step 1 of [[DES-TEST-RUN]] does. The database the pipeline restores and saves is `target/affected/coverage.db` in the workspace root, whatever `CARGO_TARGET_DIR` or `build.target-dir` say ([[EVD-CARGO-AFFECTED-REPORT]]).
|
|
294
|
+
|
|
295
|
+
Beside the database, the collection target writes `target/affected/nx-rust-context.json` in the workspace root, the record of the context it collected in ([[ADR-AFFECTED-BASELINE-CONTEXT]]): the cargo options of the collection that change what is compiled or run, namely `--features`, `--all-features`, `--no-default-features`, the profile and `--target`; the target triple that cargo built for; and for every environment input of the workspace's `test` tasks ([[DES-INPUTS]]), those the plugin infers, every variable of the prefixes its list names and those that `envInputs` declares, the SHA-256 of the value or a mark that it was unset, so that no value is written. The pipeline saves and restores the file with the database, and a baseline without it runs the full suite (step 1 of [[DES-TEST-RUN]]). The record is a JSON object of version 2 with the fields `cargo`, `triple`, `env` and `runtime`, which the plugin writes and reads with the same functions (`baseline-context.ts`); the triple is named as step 1 names the group's, the variables are the environment inputs of the `test` tasks as Nx expands them, the prefixed ones included, without `NX_CLOUD_ENCRYPTION_KEY` and `NX_RUST_RUN_ID`, which change nothing that is compiled or run, and `runtime` holds, for every runtime input of the `test` tasks but the test mode command, by its command, the SHA-256 of what it prints when it runs through `sh -c` in the repository root with the collection's environment, as Nx runs a runtime input ([[EVD-NX-24-INPUT-SEMANTICS]]). A record of version 1, without runtime inputs, counts as missing. The control plane decided this form on 16 November 2026 in nxr-tabkjx, which reads the record first; the maintainer added the runtime inputs on 17 November 2026 ([[ADR-AFFECTED-BASELINE-CONTEXT]]).
|
|
296
|
+
|
|
297
|
+
**Order of writing.** Every collection, full or `--diff`, first removes the context record, after the target has read it and run the `status` that choose the collection, and before cargo-affected's `collect`, and a full one removes the database files with it; the target writes the new record only after cargo-affected has ended successfully. cargo-affected 0.4.1 writes the coverage it collected and only afterwards returns a failure status, and a `--diff` that fails halfway has changed the database as well, so that a record left in place could vouch for coverage from another context: a checkout that holds baseline and record A, then collects with other features or another value of an environment input, would keep A's record beside B's coverage, and a later affected run in context A could leave out a test of a branch that only A takes. A collection that fails or is interrupted therefore leaves no record, and the next affected run takes the full suite, as [[ADR-AFFECTED-BASELINE-CONTEXT]] says for a missing record. The control plane decided this on 16 November 2026 from [[GOAL-TRUSTED-CACHE]] and [[REQ-SELECTION-SAFETY]]; to undo it, the target writes the record before collecting, which the case above shows to be unsafe.
|
|
298
|
+
|
|
299
|
+
A full `collect` from scratch took 15.7 s on ripgrep and 80 s on tokio at `-j 4` with 4 test threads, and peaked at 1.5 and 4.75 GiB ([[EVD-CARGO-AFFECTED-COST]]). On rust-analyzer it took 645–656 s and peaked at 6.8 GiB, page cache included, and `collect --diff` took 1.1–2.5 s on ripgrep and 52–824 s on rust-analyzer, against a plain test run of 3.2–3.7 s and 31–44 s for the same commits ([[EVD-COVERAGE-COLLECT-COST]], [[RISK-COVERAGE-COST]]).
|
|
300
|
+
|
|
301
|
+
**The target.** The collection target is `coverage-baseline`, on the workspace project of a workspace with `affectedTests` and of no other; `targetNames` renames it, with the check for two targets of one name ([[DES-PLUGIN-OPTIONS]]). It runs on the lockfile executor, `@convesoft/nx-rust:lockfile`, which has no batch implementation, so that a collection never joins a batch, and whose empty `targetDefaults` entry that `init` adds covers it, as it covers `hakari-check` ([[DES-WORKSPACE-TARGETS]]). It is not cached, has no `dependsOn`, and no target depends on it. It takes the options `features`, `allFeatures`, `noDefaultFeatures` and `profile`, which it passes as `test` with the nextest runner passes them, `--cargo-profile` for the profile, with the configuration for all features; adds `--locked` in locked mode and the flags of the `cargo` strategy ([[DES-INVOCATION]], [[DES-UNIFICATION]]); and takes four options of its own: `fullCollectThreshold`, an integer of commits that the inferred target sets to 100; `fullCollect`, which always collects everything into an empty database, without asking `status`, for the nightly full run, a scheduled recollection and `collect` as the full run on main; `diffOnly`, which never starts a full collection on its own and, where only one would do, collects nothing, succeeds with a warning and leaves the database and the record as they are, which still belong together, for recollection after dependency updates that a scheduled run with `fullCollect` batches; and `separateBuildDir`, which sets `CARGO_BUILD_BUILD_DIR` to `target/affected/build` in the workspace root, cargo-affected's own target directory, for the collect command alone, so that the instrumented build keeps its intermediate files there as it does without `build.build-dir`. A task whose tool is missing, cargo-affected, cargo-nextest, or `llvm-cov` and `llvm-profdata`, which cargo-affected looks for in the toolchain's sysroot, through `xcrun` on macOS and on `PATH`, fails before it changes anything, with the message of [[DES-DIAGNOSTICS]] ([[DES-GENERATORS]]). The control plane decided on 17 November 2026 in nxr-d0t9vm, from [[REQ-BASELINE]], [[REQ-CARGO-UNCHANGED]] and the switches above, that the cargo options are the target's own and not read from the crates' `test` targets, whose options can differ from crate to crate: a collection in other options than a test run's runs the full suite and names the option, which is safe; the guide says to give both the same options. To undo it, the target takes its defaults from the `test` targets of the workspace.
|
|
302
|
+
|
|
303
|
+
**Choosing the collection.** `collect --diff` re-collects the tests that a change affects and keeps every other test's rows, which the new record then vouches for, so the target first reads the record that is there before the collection, before anything removes it, and compares it with the context of this collection, with `contextDifferences` of `baseline-context.ts`, which the test runs use, and in both directions: a variable or runtime input that the old record holds and this collection's context lacks counts as a difference too. Only a record that can be read, is of the current version and equals this context in every field (cargo options, triple, environment inputs, runtime inputs) lets `--diff` run. A missing record (the first run, or a collection that failed or was stopped), an unreadable one, one of another version and one that differs each give a full collection into an empty database, without `status`, and the task's output names the case and, for a difference, what differs; with `diffOnly`, the same cases collect nothing and leave the database and the record as they are. A review found with the real cargo-affected that a collection with another value of a declared environment input chose `--diff`, re-collected nothing, wrote the record of the new value beside the coverage of the old, and let an affected run in the new context leave out a test that failed in the full run. The maintainer decided the rule on 17 November 2026 in the review of nxr-d0t9vm, from [[ADR-AFFECTED-BASELINE-CONTEXT]], [[REQ-SELECTION-SAFETY]] and [[GOAL-TRUSTED-CACHE]]; there is no safe undo. Where the record allows `--diff`, the target runs `cargo affected status --report-json <file> -- <the collection's arguments without --no-fail-fast>` in the workspace root with git's `diff.relative`, and runs `collect --diff` where cargo-affected exits with 0 and writes a report of `schema_version` 1 whose `cache.status` is `hit-exact` or `hit-with-divergence`, which names a collection whose relation to `HEAD` is `equal` or `reachable`, and in which no reachable collection's `commits_ahead` exceeds `fullCollectThreshold`. In every other case it runs a full `collect`, a failed `status` and a report it cannot read included, since a full collection is always correct and starts again from a database that cannot be read. `status` lists the tests, which builds them as the test run before it has ([[EVD-CARGO-AFFECTED-COST]]). Where `status` is stopped by a signal, the task fails without collecting. The task says which collection it runs and why. The control plane decided this rule and the threshold's default of 100 commits on 17 November 2026 in nxr-d0t9vm, from [[REQ-BASELINE]] and [[RISK-BASELINE-DRIFT]], which is not measured: the default bounds how far `--diff` drifts and costs a full collection about every 100 commits of main; to undo it, change the default, which only changes when time is spent.
|
|
304
|
+
|
|
305
|
+
**The record's content.** The target computes the record before it changes anything: from the inputs that Nx's `HashPlanInspector` lists for the `test` target of every crate of the workspace, under the name that `targetNames` gives it, the union of their environment inputs and of their runtime inputs, evaluated as `baseline-context.ts` evaluates a group's in the collection task's environment, which is that of the `nx` command with the dotenv files that Nx loads for the collection task, not those it loads for a `test` task; its own cargo options; and the triple that cargo builds for there, as step 1 of [[DES-TEST-RUN]] names it, with no `--target`, since `test` runs on the host. A group compares only its own variables and runtime inputs with the record, so the union of the workspace is a superset of what any group needs. The variables that the target sets for cargo-affected alone, git's configuration and `CARGO_BUILD_BUILD_DIR`, change nothing that is compiled or run and are recorded only where a `test` task has them among its inputs, with the value of the task's environment. A runtime input that fails stops the task before anything changes. The control plane decided this on 17 November 2026 in nxr-d0t9vm, from [[ADR-AFFECTED-BASELINE-CONTEXT]]; to undo it, the collection would have to rebuild each `test` task's environment, as a batch does ([[DES-BATCH]]).
|
|
306
|
+
|
|
307
|
+
**Collection and the test runs.** A collection changes the commits that the mode command reads when Nx hashes a `test` task ([[DES-TEST-MODE]]), and a test run of the same `nx` command or of another may overlap with it, since neither target depends on the other. Three rules keep every `test` task from selecting against a baseline that a collection is changing. The guard of [[DES-TEST-MODE]] holds as it is: while cargo-affected writes, the database has a `-wal` file, or after the removal of a full collection no file, and the mode command and the executor then read `full`; the executor's own read and its check of the report's collections give the full suite where a collection changed the commits between hashing and the run, and the record of subsets keeps a later hash of the same command from saying `full` for a subset. A collection of the same commit in another context, such as other features, changes neither the commits nor the report's collections, only the record; the test executor therefore reads the record again after `status` and runs the full suite where it is gone or differs from the one it compared ([[DES-TEST-RUN]]). Two collections of one checkout could leave the record of one beside the coverage of the other, so a collection takes a lock first, the file `target/affected/nx-rust-collect.lock` in the workspace root with its process ID: a second collection fails with a message that names the first and changes nothing. Every file of the lock appears whole and only where it did not exist: the contender writes it under a name of its own and hard-links it to the lock's name, which fails where that exists. A lock whose process no longer runs, as after a collection that was killed, is taken over only under the takeover marker `target/affected/nx-rust-collect.lock.takeover`, created the same way: holding it, the contender reads the lock again, removes it only where it still names the dead process, and creates its own as above. Two contenders therefore never both hold the lock: only the marker's holder removes a lock, one contender at a time holds the marker, a contender that read the stale lock before another took it over finds the other's process under the marker and is refused, and one that creates the lock between the removal and the taker's creation makes the taker's creation fail. A contender that finds a stale lock and the marker there, because a takeover runs or one was killed halfway, cannot tell which and fails without touching the database or the record, naming both files and saying to remove them once no collection runs. A marker beside no lock, as one that a taker killed between removing the stale lock and creating its own leaves, stops nothing: the next contender creates the lock as usual, and the marker stays until someone removes it. That plain creation is safe, because a taker that is still alive in that window then fails to create the lock, which the newcomer holds, and is refused, so that there is still exactly one holder; the maintainer decided on 19 November 2026 in the re-check of nxr-d0t9vm that the plain path does not look at the marker, which is safe and spares a removal by hand. A review found that the first form of the takeover, a removal without the marker, let a contender remove a lock that another had just taken over, so that both held it; the maintainer decided on 17 November 2026 that a takeover is atomic or does not happen. The control plane decided this on 17 November 2026 in nxr-d0t9vm, from [[GOAL-TRUSTED-CACHE]], [[REQ-SELECTION-SAFETY]] and [[RISK-SUBSET-AS-FULL]]. Not taken: making the collection depend on the workspace's `test` tasks, which orders one `nx` command but not two, and would keep `fullCollect` from serving as the full run on main. To undo the second read or the lock, drop it, which reopens the case it closes.
|
|
308
|
+
:::
|