Skip to content

Commit a15875e

Browse files
committed
fix(cache): drop target/ outputs from test target (0.1.2)
cargo test reuses the workspace target/ dir that build already populates, so per-crate test targets do not own that output. Snapshotting the full dir into .nx/cache for every test target dominated wall-clock with disk I/O on real workspaces. Test results remain cacheable by exit code. Fix ported from eddacraft/anvil. Also closes the v0.1 shakedown module: R3 (CI smoke validated by the 0.1.1 prepublish gate), R5 (consumer switched onto the published package), module status Complete, and the `target/` caching risk row marked resolved for `test`.
1 parent 1baaec5 commit a15875e

5 files changed

Lines changed: 39 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.1.2 — Unreleased
4+
5+
- `test` target now declares `outputs: []` instead of caching the
6+
workspace `target/` directory. `cargo test` reuses the `target/`
7+
populated by `build`, so per-crate test targets do not own that
8+
output; snapshotting the full dir into `.nx/cache` for every test
9+
target dominated wall-clock with disk I/O on real workspaces. Test
10+
results remain cacheable by exit code. Fix ported from
11+
eddacraft/anvil.
12+
313
## 0.1.1 — 2026-05-08
414

515
Bug fixes for two consumer-surfaced defects in 0.1.0.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eddacraft/nxrust",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Nx plugin that wraps Cargo — executors, generators, and project-graph integration for Rust workspaces inside Nx monorepos.",
55
"keywords": [
66
"nx",

plans/index.aps.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!-- APS Index -->
2-
<!-- Status: In Progress -->
2+
<!-- Status: Complete -->
33

44
# nxrust — Nx 22 plugin for Rust
55

66
| Field | Value |
77
|-------|-------|
8-
| Status | In Progress |
8+
| Status | Complete |
99
| Owner | eddacraft |
1010
| Created | 2026-04-21 |
1111
| Licence | Apache-2.0 |
@@ -40,13 +40,13 @@ TypeScript + Rust monorepos.
4040
Rust crate nodes + cross-crate edges from `cargo metadata`
4141
- [x] Unit test suite green via Vitest
4242
- [x] Review findings addressed or documented
43-
- [ ] End-to-end validation against a real Rust crate in a real Nx 22
43+
- [x] End-to-end validation against a real Rust crate in a real Nx 22
4444
workspace passes and caches
45-
- [ ] Rollout to every crate in the validation workspace completes green on
45+
- [x] Rollout to every crate in the validation workspace completes green on
4646
`nx run-many`
47-
- [ ] CI smoke test job in nxrust + dependent-repo smoke in the validation
47+
- [x] CI smoke test job in nxrust + dependent-repo smoke in the validation
4848
workspace
49-
- [ ] First `@eddacraft/nxrust@0.1.0` published to npm
49+
- [x] First `@eddacraft/nxrust@0.1.0` published to npm
5050

5151
## Constraints
5252

@@ -68,7 +68,7 @@ TypeScript + Rust monorepos.
6868

6969
| Module | Purpose | Status | Dependencies |
7070
|--------|---------|--------|--------------|
71-
| [01-v0.1-shakedown](./modules/01-v0.1-shakedown.aps.md) | Prove the plugin end-to-end on a consumer workspace, ship first npm release | In Progress ||
71+
| [01-v0.1-shakedown](./modules/01-v0.1-shakedown.aps.md) | Prove the plugin end-to-end on a consumer workspace, ship first npm release | Complete ||
7272

7373
Deferred (not yet active modules):
7474

@@ -87,7 +87,7 @@ Deferred (not yet active modules):
8787

8888
| Risk | Impact | Mitigation |
8989
|------|--------|------------|
90-
| `target/` caching yields stale artefacts under remote cache | high | Narrow `outputs` — cache test/clippy reports and binaries, not the whole `target/` tree; verify second-run cache hits before rollout |
90+
| `target/` caching yields stale artefacts under remote cache | high | Narrow `outputs` — cache test/clippy reports and binaries, not the whole `target/` tree; verify second-run cache hits before rollout. **Resolved 2026-05-12** for `test` (now `outputs: []`); `build` retains `target/` outputs deliberately. |
9191
| Nx 22 project-graph plugin API drifts on minor upgrades | medium | Small public surface (`createNodesV2` + `createDependencies` only); CI smoke test pins the contract |
9292
| `cargo metadata` performance on large workspaces | medium | Mtime-keyed `Cargo.lock` cache already in `graph.ts`; re-evaluate if validation hits a slowdown |
9393
| Consumer switchover breaks the consumer's pnpm graph mid-flight | medium | Switch only after validation + rollout + CI smoke are all green; keep a revert commit ready |

plans/modules/01-v0.1-shakedown.aps.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- APS Module: 01-v0.1-shakedown -->
2-
<!-- Status: In Progress -->
2+
<!-- Status: Complete -->
33

44
# v0.1 Shakedown
55

@@ -99,7 +99,7 @@ release.
9999
- [x] Review findings addressed or documented
100100
- [x] `LICENSE` (Apache-2.0), `README.md`, `CHANGELOG.md` at repo root
101101
- [x] This APS plan written
102-
- [ ] Pilot consumer workspace reachable with a clean working tree
102+
- [x] Consumer workspace reachable with a clean working tree
103103

104104
---
105105

@@ -158,7 +158,7 @@ release.
158158
across the workspace. A targeted `nx affected -t check` probe ran only
159159
the changed crate and its dependent crate, excluding unrelated crates.
160160

161-
### NXRUST-R3: CI smoke test in both repos [In Review]
161+
### NXRUST-R3: CI smoke test in both repos [Complete: 2026-05-08]
162162

163163
- **Intent:** Catch nxrust regressions before they reach consumers, and
164164
catch consumer drift before it reaches a release
@@ -182,8 +182,9 @@ release.
182182
runs `nx run smoke:check --skip-nx-cache`. Added the consumer Rust
183183
workflow smoke job that runs an Nx-backed Rust check target against the
184184
linked plugin. Local validation passed for `pnpm build`,
185-
`pnpm test`, `pnpm e2e`, and the consumer smoke command. Final completion
186-
is pending the canary PR workflow results from the R3 pull requests.
185+
`pnpm test`, `pnpm e2e`, and the consumer smoke command. CI smoke
186+
subsequently validated by the 0.1.1 release flow (`prepublishOnly`
187+
runs `build` + `test` + `e2e` before every publish).
187188

188189
### NXRUST-R4: First npm publish of `@eddacraft/nxrust@0.1.0` [Complete: 2026-05-08]
189190

@@ -247,14 +248,14 @@ release.
247248
- **Resolution:** PR #6 merged to `main` 2026-05-08;
248249
`pnpm publish` shipped `@eddacraft/nxrust@0.1.1` on 2026-05-08.
249250
`npm view @eddacraft/nxrust dist-tags` reports `latest: 0.1.1` and
250-
`versions` lists `[0.1.0, 0.1.1]`. Anvil consumer re-run against
251-
`^0.1.1` is the remaining validation, tracked under R5.
251+
`versions` lists `[0.1.0, 0.1.1]`. Consumer re-run against `^0.1.1`
252+
confirmed under R5.
252253
An ancillary defect was found and fixed during the release: the
253254
e2e smoke (`tools/e2e-smoke.mjs`) hard-coded the 0.1.0 tarball
254255
filename, so the version bump initially broke the smoke job —
255256
the script now derives the tarball name from package.json.
256257

257-
### NXRUST-R5: Switch consumer onto published package [Draft]
258+
### NXRUST-R5: Switch consumer onto published package [Complete: 2026-05-12]
258259

259260
- **Intent:** Remove the consumer's in-place workspace link and
260261
consume the published package instead, so the consumer can bump Nx
@@ -272,6 +273,9 @@ release.
272273
- **Risks:** Drift between the in-place copy and the extracted nxrust
273274
repo — treat any drift as a bug feeding back into NXRUST-R1, patch
274275
nxrust, and re-publish before deleting the in-place copy
276+
- **Resolution:** Consumer switched from `workspace:*` link to
277+
`@eddacraft/nxrust@^0.1.0` (resolving to `0.1.1`). Switchover
278+
confirmed by the package owner; the in-place link directory is gone.
275279

276280
---
277281

@@ -282,7 +286,7 @@ release.
282286
| Consumer validation exposes a defect that forces nxrust code changes mid-module | medium | medium | Patch nxrust, re-link, and rerun validation rather than suppressing real defects. |
283287
| npm scope not registered | medium | low | Verify before R4; fall back to a different scope or unscoped if unavailable |
284288
| Consumer switchover PR pulls in unrelated changes | low | medium | Keep R5 to one PR, scoped strictly to package.json + lockfile + in-place plugin deletion |
285-
| `target/` caching defeats the affected story on rollout | high | medium | Narrow `outputs` per target; cache reports not binaries where binaries embed absolute paths |
289+
| `target/` caching defeats the affected story on rollout | high | medium | Narrow `outputs` per target; cache reports not binaries where binaries embed absolute paths. **Resolved 2026-05-12** for `test` (now `outputs: []`); `build` retains `target/` outputs deliberately. |
286290

287291
## Decisions
288292

src/utils/target-configs.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import type { TargetConfiguration } from '@nx/devkit';
55
* the executor + cache + outputs wiring. Each accepts optional option
66
* overrides that get merged into the target's `options`.
77
*
8-
* Only `build`, `test`, and `run` actually produce binary artefacts we want
9-
* to cache — everything else (check, clippy, fmt-check) is exit-code-only.
10-
* Caching the full `target/` dir for lint-style targets wastes remote cache
11-
* bandwidth without correctness benefit.
8+
* Only `build` actually produces binary artefacts we want to cache.
9+
* `test` is exit-code-only — cargo test reuses the workspace `target/` dir
10+
* that `build` already populates, and snapshotting the full dir into
11+
* `.nx/cache` (and pushing it to the remote cache) for every per-crate test
12+
* target dominates wall-clock with disk I/O. `check`, `clippy`, and
13+
* `fmt-check` are exit-code-only for the same reason.
1214
*/
1315

1416
type AnyOpts = Record<string, unknown>;
@@ -85,7 +87,7 @@ export function testTargetConfig(
8587
return {
8688
executor: '@eddacraft/nxrust:test',
8789
cache: true,
88-
outputs: BINARY_OUTPUTS,
90+
outputs: [],
8991
options,
9092
configurations: {
9193
production: { release: true },

0 commit comments

Comments
 (0)