@smoothbricks/nx-plugin 0.7.2 → 0.7.4
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 +118 -118
- package/dist/.build-inputs.json +18 -18
- package/dist/cargo-toolchain-paths.d.ts +1 -1
- package/dist/cargo-toolchain-paths.js +1 -1
- package/dist/cargo-toolchain-policy.d.ts +2 -2
- package/dist/cargo-toolchain-policy.js +2 -2
- package/dist/cross-check-policy.d.ts +25 -30
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +27 -31
- package/dist/ensure-built-witness.js +727 -450
- package/dist/ensure-built.js +2 -2
- package/dist/executors/bounded-exec/bounds.d.ts +6 -3
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +9 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +24 -19
- package/dist/executors/bounded-exec/mbx-pool.d.ts +13 -16
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +24 -28
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts +2 -0
- package/dist/executors/bounded-exec/runner-lifecycle.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-lifecycle.js +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts +6 -1
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +7 -2
- package/dist/executors/bounded-exec/schema.d.ts +12 -3
- package/dist/executors/bounded-exec/schema.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +36 -2
- package/dist/index.js +9 -7
- package/dist/managed-files/files.d.ts +4 -4
- package/dist/managed-files/files.js +4 -4
- package/dist/owned-installation.d.ts.map +1 -1
- package/dist/owned-installation.js +4 -2
- package/dist/producer-receipts.js +476 -402
- package/dist/task-graph-policy.js +1 -1
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +15 -0
- package/dist/workspace-config-policy.d.ts +1 -1
- package/dist/workspace-config-policy.js +1 -1
- package/dist/workspace-manifest.d.ts +5 -0
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/managed/raw/patches/{nx@23.2.1.patch → nx@24.0.3.patch} +1397 -2174
- package/managed/raw/tooling/direnv/devenv.smoo.nix +30 -31
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +4 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +21 -21
- package/managed/templates/github/actions/setup-devenv/action.yml +20 -5
- package/package.json +4 -3
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +24 -11
- package/runtime/nx-publish/nx_publish.js +2 -1
- package/runtime-input.sh +1 -1
- package/src/cargo-toolchain-paths.ts +1 -1
- package/src/cargo-toolchain-policy.ts +2 -2
- package/src/cross-check-policy.ts +29 -32
- package/src/ensure-built.ts +2 -2
- package/src/executors/bounded-exec/bounds.ts +13 -4
- package/src/executors/bounded-exec/executor.ts +27 -29
- package/src/executors/bounded-exec/mbx-pool.ts +36 -30
- package/src/executors/bounded-exec/runner-lifecycle.ts +13 -6
- package/src/executors/bounded-exec/runner-sizing.ts +8 -2
- package/src/executors/bounded-exec/schema.json +5 -1
- package/src/executors/bounded-exec/schema.ts +12 -3
- package/src/executors/cargo-zigbuild/executor.ts +42 -2
- package/src/index.ts +9 -5
- package/src/managed-files/files.ts +4 -4
- package/src/owned-installation.ts +4 -2
- package/src/task-graph-policy.ts +1 -1
- package/src/testing.ts +13 -0
- package/src/workspace-config-policy.ts +1 -1
- package/src/workspace-manifest.ts +5 -0
- package/test-timings.json +2 -0
|
@@ -95,13 +95,11 @@
|
|
|
95
95
|
ln -s ${pkgs.python3Packages.pyflakes}/bin/pyflakes "$out/bin/pyflakes"
|
|
96
96
|
'';
|
|
97
97
|
|
|
98
|
-
#
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
# base shell already carries.
|
|
98
|
+
# The Linux rust-std set every Linux Rust artifact ships for except
|
|
99
|
+
# x86_64-unknown-linux-gnu, which the base shell already carries; see
|
|
100
|
+
# `profiles.linux-cross` below for where it applies and why. zig and
|
|
101
|
+
# cargo-zigbuild are in the base shell (see `packages`).
|
|
103
102
|
linuxToolchain = {
|
|
104
|
-
packages = [pkgs.cargo-zigbuild];
|
|
105
103
|
languages.rust.targets = [
|
|
106
104
|
"aarch64-unknown-linux-gnu"
|
|
107
105
|
"x86_64-unknown-linux-musl"
|
|
@@ -190,7 +188,7 @@ in {
|
|
|
190
188
|
# its own process. Measured on a 56-project consumer's shed (2026-10-22,
|
|
191
189
|
# three restarts each): the same project graph and the same hash for all
|
|
192
190
|
# 443 tasks of `nx run-many -t lint`; the daemon tree went from 8
|
|
193
|
-
# processes, about 1.75 GB RSS, to 1 process, about 0.65 GB. Nx
|
|
191
|
+
# processes, about 1.75 GB RSS, to 1 process, about 0.65 GB. Nx 24.0.3
|
|
194
192
|
# reads only "false" as off (project-graph/plugins/isolation/enabled.js).
|
|
195
193
|
NX_ISOLATE_PLUGINS = "false";
|
|
196
194
|
SMOO_TYPECHECK_TSC = "${typecheckTsc}/bin/tsc";
|
|
@@ -256,8 +254,8 @@ in {
|
|
|
256
254
|
# type-check the arm CI compiles. rust-std alone reaches every crate whose
|
|
257
255
|
# dependency graph is pure Rust; a dependency that compiles C for the target
|
|
258
256
|
# — ring, openssl-sys, libgit2-sys, libz-sys — additionally needs a C
|
|
259
|
-
# compiler for the target,
|
|
260
|
-
#
|
|
257
|
+
# compiler for the target: zig, driven by cargo-zigbuild, both in every
|
|
258
|
+
# shell (see `packages` below).
|
|
261
259
|
#
|
|
262
260
|
# The reverse direction is not available at any price: type-checking an Apple
|
|
263
261
|
# target from Linux needs an Apple SDK for those same C-building
|
|
@@ -270,35 +268,32 @@ in {
|
|
|
270
268
|
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux linuxToolchain.languages.rust.targets;
|
|
271
269
|
};
|
|
272
270
|
|
|
273
|
-
# The Linux Rust toolchain
|
|
271
|
+
# The Linux Rust toolchain is cargo-zigbuild driving zig, plus the Linux
|
|
274
272
|
# rust-std set. It builds every published Linux Rust artifact — static musl
|
|
275
|
-
# CLIs, glibc 2.17 N-API addons — and `
|
|
273
|
+
# CLIs, glibc 2.17 N-API addons — and the `cargo-lint-cross` clippy, with the
|
|
276
274
|
# same command on every host. zig carries glibc symbol-version stubs for every
|
|
277
275
|
# glibc and the musl sources inside its own store path, so nothing on the
|
|
278
276
|
# build machine reaches the artifact: no loader path, no RUNPATH, no build
|
|
279
277
|
# host's glibc floor. cargo-zigbuild supplies the `zig cc` shims and per-triple
|
|
280
278
|
# compiler variables itself, so this module sets no environment.
|
|
281
279
|
#
|
|
282
|
-
#
|
|
283
|
-
#
|
|
284
|
-
# `
|
|
285
|
-
#
|
|
286
|
-
#
|
|
287
|
-
#
|
|
288
|
-
#
|
|
289
|
-
#
|
|
290
|
-
# 2.2.3 has first-class profiles, so this is one gated
|
|
291
|
-
# file rather than a second config directory that would
|
|
292
|
-
# everything here.
|
|
280
|
+
# Every host's base shell carries zig, cargo-zigbuild and the
|
|
281
|
+
# x86_64-unknown-linux-gnu rust-std, which is all the cross clippy needs, so
|
|
282
|
+
# `cargo-lint-cross` runs in any checkout's shell and in the land gate's one Nx
|
|
283
|
+
# graph beside every other gate task. A Linux host also carries the remaining
|
|
284
|
+
# Linux rust-std set in the base shell, because its ordinary `build` includes
|
|
285
|
+
# its own platform's artifacts. A macOS host opts into that set through the
|
|
286
|
+
# `linux-cross` profile, activated by `devenv -P linux-cross`: the three
|
|
287
|
+
# rust-std targets are about 0.5 GiB and only a Linux artifact built on Darwin
|
|
288
|
+
# needs them. devenv 2.2.3 has first-class profiles, so this is one gated
|
|
289
|
+
# module in the shared file rather than a second config directory that would
|
|
290
|
+
# re-import and re-pin everything here.
|
|
293
291
|
#
|
|
294
|
-
#
|
|
295
|
-
#
|
|
296
|
-
#
|
|
297
|
-
#
|
|
298
|
-
#
|
|
299
|
-
# With the flag on the target instead, running it outside this profile fails
|
|
300
|
-
# loudly on the missing cargo-zigbuild, and a host lint can never be mistaken
|
|
301
|
-
# for a cross one.
|
|
292
|
+
# Neither shell sets CARGO_BUILD_TARGET: the triple belongs to the Nx target
|
|
293
|
+
# that asks for it (`cargo-lint-cross` passes `--target` explicitly), not to
|
|
294
|
+
# the ambient environment. An ambient triple would make the check silently
|
|
295
|
+
# host-local wherever it was missing, reporting green having compiled macOS,
|
|
296
|
+
# and a host lint can never be mistaken for a cross one.
|
|
302
297
|
profiles.linux-cross.module = {
|
|
303
298
|
config = lib.mkIf (!pkgs.stdenv.hostPlatform.isLinux) linuxToolchain;
|
|
304
299
|
};
|
|
@@ -424,8 +419,12 @@ in {
|
|
|
424
419
|
# on profiles below). The closure is about 380 MiB, fetched once per Nix
|
|
425
420
|
# store, not per checkout.
|
|
426
421
|
pkgs.zig
|
|
422
|
+
# Drives zig as the C compiler and linker of every Linux triple, for the
|
|
423
|
+
# Linux artifacts and for the `cargo-lint-cross` clippy, which therefore
|
|
424
|
+
# runs in every shell and in the land gate's Nx graph.
|
|
425
|
+
pkgs.cargo-zigbuild
|
|
427
426
|
]
|
|
428
|
-
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux
|
|
427
|
+
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [pkgs.chromium];
|
|
429
428
|
|
|
430
429
|
# devenv wraps the Python interpreter to find native libraries in
|
|
431
430
|
# `languages.python.libraries`, whose default is this checkout's
|
|
@@ -251,6 +251,10 @@ persist_devenv_environment() {
|
|
|
251
251
|
# The runner step owns these.
|
|
252
252
|
PWD | OLDPWD | SHLVL | SHELL | HOME | USER | LOGNAME | HOSTNAME | TERM | TMPDIR | TMP | TEMP | _ | PS1) continue ;;
|
|
253
253
|
GITHUB_* | RUNNER_* | ACTIONS_* | CI) continue ;;
|
|
254
|
+
# The shell Python's package path, not bookkeeping: nixpkgs' sitecustomize (which
|
|
255
|
+
# PYTHONPATH names) reads it to put the withPackages site-packages on sys.path, so a
|
|
256
|
+
# later step's python3 imports the packages the shell provides.
|
|
257
|
+
NIX_PYTHONPATH) ;;
|
|
254
258
|
# Shell-session bookkeeping, meaningful only inside the shell itself.
|
|
255
259
|
DIRENV_* | DEVENV_* | NIX_* | BASH* | XDG_* | IN_NIX_SHELL | SMOO_ENV_CAPTURE_OUT) continue ;;
|
|
256
260
|
esac
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
# 2. The macOS-only Linux cross-compile gate. It asks Nx for cargo-lint-cross,
|
|
12
12
|
# whose hit means a real `cargo-zigbuild clippy --target x86_64-unknown-linux-gnu`
|
|
13
13
|
# already passed for exactly this tree, so the push is safe with no toolchain
|
|
14
|
-
# present.
|
|
15
|
-
#
|
|
14
|
+
# present. The probe asks the cross target to replay and never to compile: on a
|
|
15
|
+
# miss its guard refuses. Its dependencies are ordinary Nx tasks whose outputs
|
|
16
16
|
# the cross key reads, so Nx restores them from the cache or, for a tree no gate
|
|
17
17
|
# ran, builds them. A refusal names the one command that fixes it; any other
|
|
18
18
|
# failure is said as that, never as a cache miss.
|
|
@@ -27,18 +27,17 @@
|
|
|
27
27
|
# SDK. Under the checkout's environment the keys are the gate's, and a dependency
|
|
28
28
|
# that does miss builds the way the gate builds it.
|
|
29
29
|
#
|
|
30
|
-
# Why the cross target never compiles here.
|
|
31
|
-
# cargo-zigbuild
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
30
|
+
# Why the cross target never compiles here. Every checkout shell carries zig,
|
|
31
|
+
# cargo-zigbuild and the Linux rust-std the cross clippy needs, so a miss would
|
|
32
|
+
# compile, and a push the user expected to take a second would spend minutes
|
|
33
|
+
# in clippy. Pushing is not the place to discover that the tree has not been
|
|
34
|
+
# compiled for Linux: the land gate, whose Nx graph holds cargo-lint-cross, or
|
|
35
|
+
# `bun run check:linux`, is.
|
|
36
36
|
#
|
|
37
|
-
#
|
|
38
|
-
# which is what turns a miss into a refusal here.
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
# runs, in the toolchain the user entered for it.
|
|
37
|
+
# SMOO_CROSS_LINT_REPLAY_ONLY=1 makes the target's own guard refuse before it
|
|
38
|
+
# starts cargo-zigbuild, which is what turns a miss into a refusal here. Nx
|
|
39
|
+
# hashes no environment a target does not declare, so the variable leaves the
|
|
40
|
+
# probe's key the gate's, and a hit replays as before.
|
|
42
41
|
#
|
|
43
42
|
# The denylist gate needs only tooling/direnv/repo-path's PATH; the cross gate
|
|
44
43
|
# needs direnv on the caller's PATH, and the checkout's own devenv through it,
|
|
@@ -89,23 +88,24 @@ cross_gate() {
|
|
|
89
88
|
return 1
|
|
90
89
|
fi
|
|
91
90
|
|
|
92
|
-
# The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL
|
|
93
|
-
# is the one line that means the key
|
|
94
|
-
# so the hook reads the output for it
|
|
91
|
+
# The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL,
|
|
92
|
+
# under CARGO_CROSS_LINT_REPLAY_ONLY_ENV) is the one line that means the key
|
|
93
|
+
# missed. Nx exits 1 for every task failure, so the hook reads the output for it
|
|
94
|
+
# rather than guessing from the status.
|
|
95
95
|
output=$(mktemp "${TMPDIR:-/tmp}/pre-push-cross.XXXXXX") || return 1
|
|
96
96
|
trap 'rm -f "$output"' EXIT
|
|
97
97
|
set -o pipefail
|
|
98
|
-
direnv exec "$PWD" nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
|
|
98
|
+
SMOO_CROSS_LINT_REPLAY_ONLY=1 direnv exec "$PWD" nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
|
|
99
99
|
status=$?
|
|
100
100
|
[ "$status" -eq 0 ] && return 0
|
|
101
101
|
|
|
102
|
-
if grep -qF 'cargo-lint-cross
|
|
102
|
+
if grep -qF 'cargo-lint-cross is not cached for this tree; run: bun run check:linux' "$output"; then
|
|
103
103
|
cat >&2 <<'EOF'
|
|
104
104
|
|
|
105
105
|
pre-push: the Linux cross-compile check is NOT cached for this tree, so this
|
|
106
|
-
push would ship code that has never been compiled for Linux. The "
|
|
107
|
-
|
|
108
|
-
broken toolchain.
|
|
106
|
+
push would ship code that has never been compiled for Linux. The "not cached"
|
|
107
|
+
line above is the cross target refusing to compile here, as the probe asked,
|
|
108
|
+
not a broken toolchain.
|
|
109
109
|
|
|
110
110
|
Run: bun run check:linux
|
|
111
111
|
Wait for it to pass, then push again.
|
|
@@ -121,13 +121,24 @@ runs:
|
|
|
121
121
|
# job by design (act/runner/run_context.go: MustRandName), so a restored
|
|
122
122
|
# cache could never match. The workspace is therefore bind-mounted at a
|
|
123
123
|
# stable path (a symlink would not do: Nix canonicalises) and devenv is
|
|
124
|
-
# evaluated from there
|
|
125
|
-
#
|
|
124
|
+
# evaluated from there. DEVENV_WORKDIR names the path the devenv steps use.
|
|
125
|
+
# Later steps start in the checkout, but the shell environment they inherit
|
|
126
|
+
# names the stable path (PATH, NX_WORKSPACE_ROOT_PATH), so Nx and every task
|
|
127
|
+
# it runs see the workspace there.
|
|
126
128
|
# The mount target is the instance's own /work, not the shared bind: only
|
|
127
129
|
# the path's spelling must be stable, and a bind onto the idmapped cache
|
|
128
130
|
# dataset failed inside the job (move_mount: ENOENT) where a container-fs
|
|
129
|
-
# target does not.
|
|
130
|
-
#
|
|
131
|
+
# target does not. An instance that already ran a job of this scope still
|
|
132
|
+
# holds that job's bind at the stable path, onto a checkout the runner has
|
|
133
|
+
# since deleted, and a bind over it fails with ENOENT too. Binds stack there
|
|
134
|
+
# when an earlier job's checkout outlived it. On Linux the step detaches
|
|
135
|
+
# each first, lazily: a process an earlier job left behind may still hold
|
|
136
|
+
# it. A detach that fails leaves the bind to the kernel's answer below.
|
|
137
|
+
# If the mount is still refused the job goes on from the checkout: devenv
|
|
138
|
+
# evaluates again, and every task sees the checkout's path instead of the
|
|
139
|
+
# stable one. That can change verdicts, not just cost: Biome's scanner skips
|
|
140
|
+
# every path with a .cache component, and act's default checkout lies under
|
|
141
|
+
# ~/.cache/act, so lint loaded no nested .gitignore and checked build output.
|
|
131
142
|
- name: 📂 Locate devenv state on the shared bind
|
|
132
143
|
if: steps.runner-kind.outputs.host == 'true'
|
|
133
144
|
shell: bash
|
|
@@ -145,12 +156,16 @@ runs:
|
|
|
145
156
|
ln -s "$root/.devenv" tooling/direnv/.devenv
|
|
146
157
|
ln -s "$root/.direnv" tooling/direnv/.direnv
|
|
147
158
|
stable="/work/$DEVENV_STATE_REPO/${lane:-default}/$DEVENV_STATE_JOB/$scope"
|
|
159
|
+
while [ "$RUNNER_OS" = Linux ] && mountpoint -q "$stable"; do
|
|
160
|
+
echo "detaching an earlier job's bind at $stable"
|
|
161
|
+
sudo umount --lazy "$stable" || break
|
|
162
|
+
done
|
|
148
163
|
if mkdir -p "$stable" && sudo mount --bind "$GITHUB_WORKSPACE" "$stable"; then
|
|
149
164
|
echo "DEVENV_WORKDIR=$stable" >> "$GITHUB_ENV"
|
|
150
165
|
echo "devenv state: $root (workspace bind-mounted at $stable)"
|
|
151
166
|
else
|
|
152
167
|
echo "DEVENV_WORKDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
|
|
153
|
-
echo "::warning::stable devenv path unavailable (bind mount refused);
|
|
168
|
+
echo "::warning::stable devenv path unavailable (bind mount refused); devenv and every task run from the checkout at $GITHUB_WORKSPACE"
|
|
154
169
|
echo "devenv state: $root (workspace at $GITHUB_WORKSPACE)"
|
|
155
170
|
fi
|
|
156
171
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -283,6 +283,7 @@
|
|
|
283
283
|
"default",
|
|
284
284
|
"^dependencyDefault",
|
|
285
285
|
"bunToolchain",
|
|
286
|
+
"{workspaceRoot}/packages/nx-23.2.1/package.json",
|
|
286
287
|
{
|
|
287
288
|
"runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh node --version"
|
|
288
289
|
},
|
|
@@ -648,10 +649,10 @@
|
|
|
648
649
|
"directory": "packages/nx-plugin"
|
|
649
650
|
},
|
|
650
651
|
"dependencies": {
|
|
651
|
-
"@nx/js": "
|
|
652
|
+
"@nx/js": "24.0.3",
|
|
652
653
|
"@smoothbricks/build-inputs": "0.0.2",
|
|
653
654
|
"@smoothbricks/cargo-retain": "0.0.2",
|
|
654
|
-
"@smoothbricks/cowshed": "0.4.
|
|
655
|
+
"@smoothbricks/cowshed": "0.4.5",
|
|
655
656
|
"@smoothbricks/nextest-extract": "0.0.2",
|
|
656
657
|
"jsonc-parser": "^3.3.1",
|
|
657
658
|
"minimatch": "10.2.5",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 1,
|
|
3
3
|
"files": {
|
|
4
|
-
"packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js": "
|
|
5
|
-
"packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js": "
|
|
4
|
+
"packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js": "e8c05f18787e395d1509daf75bdb521b1a7018dff60daa1c8afe93ca8f585d64",
|
|
5
|
+
"packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js": "431e05ae1e1a1249a23bf2600101d6e88ca01bc0fc95bd389128e126edca33b9"
|
|
6
6
|
},
|
|
7
7
|
"producer": {
|
|
8
8
|
"project": "nx-plugin",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// One version-sensitive boundary for the checkout's own Nx cache (05_gateway.md, "Publication").
|
|
2
|
-
// DbCache and its native cache field are INTERNAL Nx
|
|
2
|
+
// DbCache and its native cache field are INTERNAL Nx APIs, not a public stable adapter: each Nx version
|
|
3
|
+
// it was read against is declared in openNxCache with the layout it relies on, and any other is refused.
|
|
3
4
|
// biome-ignore lint/correctness/noUnusedVariables: invoked by the bodies cache_adapter::script prefixes (cache_adapter.rs), not from this file.
|
|
4
5
|
function openNxCache(root) {
|
|
5
6
|
const path = require('node:path');
|
|
@@ -7,27 +8,40 @@ function openNxCache(root) {
|
|
|
7
8
|
if (!root || !path.isAbsolute(root)) {
|
|
8
9
|
throw new Error(`Nx cache adapter requires an absolute checkout root, got ${JSON.stringify(root)}`);
|
|
9
10
|
}
|
|
11
|
+
// What each qualified Nx version fixes for this adapter, read in nrwl/nx at that tag: the checkout's
|
|
12
|
+
// task-database and cache directories (`utils/cache-directory.ts`). In both, the task database is
|
|
13
|
+
// `<machine>-v<DB_VERSION>.db` there (v3 in 23.2.1, v6 in 24.0.3: `native/db/mod.rs`, `initialize.rs`),
|
|
14
|
+
// reached only through Nx's own `NxCache.get`; an entry is `<cache>/<hash>/` with its terminal output in
|
|
15
|
+
// `<cache>/terminalOutputs/<hash>` (`native/cache/cache.rs`); `CachedResult` is `{ code, terminalOutput,
|
|
16
|
+
// outputsPath, size }`; and `HttpRemoteCache.store` archives the entry alike (`native/cache/http_remote_cache.rs`,
|
|
17
|
+
// the same source). 23.2.1's `get` answers a row whose entry directory is gone; 24.0.3's does not.
|
|
18
|
+
const layouts = new Map([
|
|
19
|
+
['23.2.1', { workspaceData: '.nx/workspace-data', cache: '.nx/cache' }],
|
|
20
|
+
['24.0.3', { workspaceData: '.nx/workspace-data', cache: '.nx/cache' }],
|
|
21
|
+
]);
|
|
10
22
|
const requireNx = createRequire(path.join(root, 'package.json'));
|
|
11
23
|
const version = requireNx('nx/package.json').version;
|
|
12
|
-
|
|
24
|
+
const layout = layouts.get(version);
|
|
25
|
+
if (!layout) {
|
|
13
26
|
throw new Error(
|
|
14
|
-
`Nx cache adapter supports exactly Nx
|
|
27
|
+
`Nx cache adapter supports exactly Nx ${[...layouts.keys()].join(' or ')}, not ${version}; requalify the adapter against it`,
|
|
15
28
|
);
|
|
16
29
|
}
|
|
30
|
+
const workspaceData = path.join(root, layout.workspaceData);
|
|
31
|
+
const cacheDir = path.join(root, layout.cache);
|
|
17
32
|
// Nx fixes these paths at module load. Every root is handled in its own existing job process.
|
|
18
33
|
process.env.NX_WORKSPACE_ROOT_PATH = root;
|
|
19
|
-
process.env.NX_WORKSPACE_DATA_DIRECTORY =
|
|
20
|
-
process.env.NX_CACHE_DIRECTORY =
|
|
34
|
+
process.env.NX_WORKSPACE_DATA_DIRECTORY = workspaceData;
|
|
35
|
+
process.env.NX_CACHE_DIRECTORY = cacheDir;
|
|
21
36
|
if (requireNx('nx/src/native').IS_WASM) {
|
|
22
37
|
throw new Error('The Nx cache adapter requires the pinned native database cache, not WASM');
|
|
23
38
|
}
|
|
24
39
|
// Nx resolves its workspace-data directory itself; prove it is this checkout's before any database is opened.
|
|
25
40
|
const { sharedDataDirectory } = requireNx('nx/src/utils/cache-directory');
|
|
26
|
-
const workspaceData = path.join(root, '.nx', 'workspace-data');
|
|
27
41
|
const actualWorkspaceData = sharedDataDirectory(root, 'workspace-data');
|
|
28
42
|
if (path.resolve(actualWorkspaceData) !== path.resolve(workspaceData)) {
|
|
29
43
|
throw new Error(
|
|
30
|
-
`Nx
|
|
44
|
+
`Nx ${version} workspace-data directory changed: expected ${workspaceData}, actual ${actualWorkspaceData}`,
|
|
31
45
|
);
|
|
32
46
|
}
|
|
33
47
|
const { DbCache } = requireNx('nx/src/tasks-runner/cache');
|
|
@@ -35,11 +49,10 @@ function openNxCache(root) {
|
|
|
35
49
|
const cache = new DbCache({ nxCloudRemoteCache: null, skipRemoteCache: true });
|
|
36
50
|
const native = cache.cache;
|
|
37
51
|
if (!native || typeof native.get !== 'function' || typeof native.cacheDirectory !== 'string') {
|
|
38
|
-
throw new Error(
|
|
52
|
+
throw new Error(`Nx ${version} DbCache native cache surface changed; requalify the adapter`);
|
|
39
53
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
throw new Error(`Nx 23.2.1 cache directory changed: expected ${expectedCacheDir}, actual ${native.cacheDirectory}`);
|
|
54
|
+
if (path.resolve(native.cacheDirectory) !== path.resolve(cacheDir)) {
|
|
55
|
+
throw new Error(`Nx ${version} cache directory changed: expected ${cacheDir}, actual ${native.cacheDirectory}`);
|
|
43
56
|
}
|
|
44
57
|
return { requireNx, cache, cacheDir: native.cacheDirectory, getLocal: (hash) => native.get(hash) };
|
|
45
58
|
}
|
|
@@ -32,7 +32,8 @@ async function publish() {
|
|
|
32
32
|
let skipped = 0;
|
|
33
33
|
for (const hash of hashes) {
|
|
34
34
|
const result = getLocal(hash);
|
|
35
|
-
// A task Nx does not cache, or one that failed, has no complete entry to share
|
|
35
|
+
// A task Nx does not cache, or one that failed, has no complete entry to share; nor has a row
|
|
36
|
+
// whose entry directory is gone, which Nx 23.2.1's lookup still answers.
|
|
36
37
|
if (result?.code !== 0 || !fs.statSync(result.outputsPath, { throwIfNoEntry: false })?.isDirectory()) {
|
|
37
38
|
skipped += 1;
|
|
38
39
|
continue;
|
package/runtime-input.sh
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# The input's value is the command's stdout. A command that fails stops Nx with
|
|
7
7
|
# an error; its failure never becomes a key.
|
|
8
8
|
#
|
|
9
|
-
# WHY the 0xFF byte. Nx
|
|
9
|
+
# WHY the 0xFF byte. Nx 24.0.3 (`packages/nx/src/native/tasks/hashers/
|
|
10
10
|
# hash_runtime.rs`) runs a runtime input under `sh -c`, hashes its trimmed
|
|
11
11
|
# stdout followed by its trimmed stderr, and never looks at the exit status. A
|
|
12
12
|
# failed input is therefore a valid key: its error text, the same string for
|
|
@@ -20,7 +20,7 @@ import { delimiter, join } from 'node:path';
|
|
|
20
20
|
*
|
|
21
21
|
* rustc and cargo are not here on purpose. Cargo keys units on the output of `rustc -vV`, never on rustc's path, and the
|
|
22
22
|
* version recipe beside this one hashes it. On a non-Linux host the default shell and its linux-cross profile carry
|
|
23
|
-
* different rust-std targets, so a rustc path would split
|
|
23
|
+
* different rust-std targets, so a rustc path would split one target's key between the two shells.
|
|
24
24
|
*
|
|
25
25
|
* Only a path in the Nix store counts. A store object is named by the hash of everything it was built from, so one
|
|
26
26
|
* shell gives one object on every machine of a platform. A path elsewhere belongs to the machine and takes no part.
|
|
@@ -22,8 +22,8 @@ import { runtimeInput, shellWord } from './runtime-input.js';
|
|
|
22
22
|
* differs between a bare shell and a devenv profile for the SAME sources: in
|
|
23
23
|
* the `linux-cross` profile `CARGO_INSTALL_ROOT` moves under
|
|
24
24
|
* `profiles/linux-cross/`, and every variable the profile's tools set appears,
|
|
25
|
-
* so
|
|
26
|
-
*
|
|
25
|
+
* so an entry written inside the profile could never be hit from a bare shell (the
|
|
26
|
+
* pre-push probe ran bare while `check:linux` ran in the profile). Measured on one repository-root archive
|
|
27
27
|
* target with the dump still in place: bare 18197306115812424011, in-profile
|
|
28
28
|
* 12567954759860890767.
|
|
29
29
|
*
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* compiles is invisible to every check a macOS host can run: a full local lint
|
|
6
6
|
* passes and CI still goes red on unused imports, unresolved names and dead code
|
|
7
7
|
* inside the `not(target_os = "macos")` branch. Closing that needs three pieces
|
|
8
|
-
* to agree
|
|
9
|
-
*
|
|
10
|
-
* the triple, and a root script that runs
|
|
11
|
-
* live here together because the plugin infers the target while the CLI
|
|
8
|
+
* to agree: a shell carrying the Linux toolchain (zig, cargo-zigbuild and the
|
|
9
|
+
* x86_64-unknown-linux-gnu rust-std, every managed devenv shell's), an Nx target
|
|
10
|
+
* per Cargo workspace that asks for the triple, and a root script that runs it.
|
|
11
|
+
* They live here together because the plugin infers the target while the CLI
|
|
12
12
|
* installs the script and reports a project missing it; kept apart, the three
|
|
13
13
|
* spellings drift and the gate silently stops gating.
|
|
14
14
|
*/
|
|
@@ -19,14 +19,6 @@
|
|
|
19
19
|
*/
|
|
20
20
|
export const CARGO_LINUX_TRIPLE = 'x86_64-unknown-linux-gnu';
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* The devenv profile carrying the Linux toolchain — zig, cargo-zigbuild and the
|
|
24
|
-
* Linux rust-std set — defined in the managed `tooling/direnv/devenv.smoo.nix`.
|
|
25
|
-
* Opt-in on macOS because zig alone is a 380 MiB closure that nothing but a
|
|
26
|
-
* Linux artifact or this check uses.
|
|
27
|
-
*/
|
|
28
|
-
export const DEVENV_CROSS_PROFILE = 'linux-cross';
|
|
29
|
-
|
|
30
22
|
/**
|
|
31
23
|
* Nx target name. No colons, per the repo's target-naming rule.
|
|
32
24
|
*
|
|
@@ -41,15 +33,24 @@ export const DEVENV_CROSS_PROFILE = 'linux-cross';
|
|
|
41
33
|
export const CARGO_CROSS_LINT_TARGET = 'cargo-lint-cross';
|
|
42
34
|
|
|
43
35
|
/**
|
|
44
|
-
* What the cross lint prints when it
|
|
45
|
-
*
|
|
46
|
-
* key missed. The
|
|
47
|
-
*
|
|
36
|
+
* What the cross lint prints when it is asked to replay and not compile: on a
|
|
37
|
+
* Darwin cache miss under the managed pre-push probe this line, and only this
|
|
38
|
+
* line, means the key missed. The hook reads its output for exactly this text to
|
|
39
|
+
* tell a miss from any other Nx failure.
|
|
48
40
|
*/
|
|
49
|
-
export const CARGO_CROSS_LINT_REFUSAL =
|
|
50
|
-
|
|
41
|
+
export const CARGO_CROSS_LINT_REFUSAL = 'cargo-lint-cross is not cached for this tree; run: bun run check:linux';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Set to `1` by the managed pre-push probe, which asks Nx for the cross target's
|
|
45
|
+
* cached verdict and must never start the clippy itself. Nx hashes no
|
|
46
|
+
* environment a target does not declare, so the probe's key is the gate's.
|
|
47
|
+
*/
|
|
48
|
+
export const CARGO_CROSS_LINT_REPLAY_ONLY_ENV = 'SMOO_CROSS_LINT_REPLAY_ONLY';
|
|
49
|
+
|
|
50
|
+
const CARGO_CROSS_LINT_MISSING_TOOL =
|
|
51
|
+
"cargo-lint-cross needs cargo-zigbuild, which every managed devenv shell carries; run it in the checkout's shell: bun run check:linux";
|
|
51
52
|
|
|
52
|
-
const CARGO_CROSS_LINT_GUARD = `command -v cargo-zigbuild >/dev/null || { echo
|
|
53
|
+
const CARGO_CROSS_LINT_GUARD = `[ "\${${CARGO_CROSS_LINT_REPLAY_ONLY_ENV}:-}" != 1 ] || { echo '${CARGO_CROSS_LINT_REFUSAL}' >&2; exit 2; }; command -v cargo-zigbuild >/dev/null || { echo "${CARGO_CROSS_LINT_MISSING_TOOL}" >&2; exit 2; }`;
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* The prefix `cargoFrozen` writes. Exported so target inference can recognize
|
|
@@ -147,9 +148,9 @@ export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
|
|
|
147
148
|
* cross test target; it could only recompile these crates to produce a harness it
|
|
148
149
|
* must then refuse to launch.
|
|
149
150
|
*
|
|
150
|
-
* `--target` is explicit rather than inherited from
|
|
151
|
-
*
|
|
152
|
-
*
|
|
151
|
+
* `--target` is explicit rather than inherited from an ambient CARGO_BUILD_TARGET,
|
|
152
|
+
* so the triple belongs to this target and a host lint can never pass for a cross
|
|
153
|
+
* one.
|
|
153
154
|
*
|
|
154
155
|
* cargo-zigbuild rather than plain cargo because ring compiles C for the target
|
|
155
156
|
* from its build script, and build scripts run even under clippy: zig is the
|
|
@@ -192,19 +193,15 @@ export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
|
|
|
192
193
|
|
|
193
194
|
/**
|
|
194
195
|
* The developer entry point: one command on macOS that reports what CI's Linux
|
|
195
|
-
* job would.
|
|
196
|
-
*
|
|
196
|
+
* job would. A plain Nx run, because every managed devenv shell carries the
|
|
197
|
+
* cross toolchain; the land gate's Nx graph holds the same target.
|
|
197
198
|
*
|
|
198
199
|
* Deliberately NOT `--quiet`. The pre-push gate is a probe: it consults the Nx
|
|
199
|
-
* cache and refuses a push that has no hit, never
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* adds about 0.9 GiB (zig plus three rust-std targets) and the clippy behind it
|
|
203
|
-
* is unbounded, so a silent terminal is indistinguishable from a hang.
|
|
204
|
-
* Suppressing that output only paid while a hook ran this for you and nobody
|
|
205
|
-
* read it.
|
|
200
|
+
* cache and refuses a push that has no hit, never starting a compile of its own.
|
|
201
|
+
* The clippy behind this script is unbounded, so a silent terminal is
|
|
202
|
+
* indistinguishable from a hang.
|
|
206
203
|
*/
|
|
207
|
-
export const CROSS_CHECK_SCRIPT_COMMAND = `
|
|
204
|
+
export const CROSS_CHECK_SCRIPT_COMMAND = `nx run-many -t ${CARGO_CROSS_LINT_TARGET}`;
|
|
208
205
|
|
|
209
206
|
/**
|
|
210
207
|
* A cross-built test archive and the target that EXECUTES it, per foreign
|
package/src/ensure-built.ts
CHANGED
|
@@ -921,7 +921,7 @@ export function providerInputProof(
|
|
|
921
921
|
taskGraph: TaskGraph,
|
|
922
922
|
requireNx: WorkspaceNxRequire,
|
|
923
923
|
): ProviderInputProof {
|
|
924
|
-
const { WorkspaceContext, HashPlanInspector, HashPlanner
|
|
924
|
+
const { WorkspaceContext, HashPlanInspector, HashPlanner } = requireNx('nx/src/native');
|
|
925
925
|
const { transformProjectGraphForRust } = requireNx('nx/src/native/transform-objects');
|
|
926
926
|
const { createProjectRootMappings } = requireNx('nx/src/project-graph/utils/find-project-for-path');
|
|
927
927
|
const { workspaceDataDirectoryForWorkspace } = requireNx('nx/src/utils/cache-directory');
|
|
@@ -937,7 +937,7 @@ export function providerInputProof(
|
|
|
937
937
|
runtimeSource: { kind: 'opaque', detail: 'Nx supplied no native file-input proof' },
|
|
938
938
|
};
|
|
939
939
|
}
|
|
940
|
-
const planner = new HashPlanner(nxJson,
|
|
940
|
+
const planner = new HashPlanner(nxJson, transformProjectGraphForRust(projectGraph));
|
|
941
941
|
const inspector = new HashPlanInspector(
|
|
942
942
|
externalReferences.allWorkspaceFiles,
|
|
943
943
|
externalReferences.projectFiles,
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* a pure function of the run's events and the times they happened at, so a table can test it with no clock and no
|
|
4
4
|
* process (verdict.ts says why the bounds are separate).
|
|
5
5
|
*
|
|
6
|
-
* - A scheduled leaf arms nothing until its first grant
|
|
6
|
+
* - A scheduled leaf arms nothing until its first grant, but for a fixture that runs before its reservation, whose
|
|
7
|
+
* ceiling starts at spawn. Later zero-hold intervals pause only the idle budget.
|
|
7
8
|
* - Any explicitly queued task process pauses idle, including alongside held grants; ceilings keep running.
|
|
8
9
|
* - The fixture ceiling ends with its segment. The idle clock also stops outside the testing lifecycle.
|
|
9
10
|
* - Finished tests reset the idle budget whether their release byte arrived before or after their output.
|
|
@@ -18,7 +19,7 @@ export interface BoundLimits {
|
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* When each armed bound expires, in the clock's milliseconds; `null` when it is not armed. `queued`: the run waits for
|
|
21
|
-
* its pool's grant, so none is armed yet.
|
|
22
|
+
* its pool's grant, so none is armed yet but a fixture ceiling started at spawn (`fixtureFirst`).
|
|
22
23
|
*/
|
|
23
24
|
export interface Bounds {
|
|
24
25
|
readonly idle: number | null;
|
|
@@ -35,7 +36,8 @@ export type BoundKind = 'idle' | 'fixture' | 'total';
|
|
|
35
36
|
export type BoundEvent =
|
|
36
37
|
/**
|
|
37
38
|
* The command started; `testing` is the lifecycle's answer then, `fixture` whether a supervised fixture leads it,
|
|
38
|
-
* `queued` whether mbx schedules this leaf, as known before spawn
|
|
39
|
+
* `queued` whether mbx schedules this leaf, as known before spawn, and `fixtureFirst` whether that fixture runs
|
|
40
|
+
* before the leaf's reservation (it counts the leaf's units), so its ceiling starts now, not at the grant.
|
|
39
41
|
*/
|
|
40
42
|
| {
|
|
41
43
|
readonly kind: 'spawn';
|
|
@@ -43,6 +45,7 @@ export type BoundEvent =
|
|
|
43
45
|
readonly testing: boolean;
|
|
44
46
|
readonly fixture: boolean;
|
|
45
47
|
readonly queued: boolean;
|
|
48
|
+
readonly fixtureFirst: boolean;
|
|
46
49
|
}
|
|
47
50
|
/** Each admission begins a hold; the first one starts the queued leaf's ceilings. */
|
|
48
51
|
| { readonly kind: 'granted'; readonly at: number; readonly testing: boolean; readonly fixture: boolean }
|
|
@@ -91,7 +94,13 @@ export function stepBounds(bounds: Bounds, limits: BoundLimits, event: BoundEven
|
|
|
91
94
|
switch (event.kind) {
|
|
92
95
|
case 'spawn':
|
|
93
96
|
return event.queued
|
|
94
|
-
? {
|
|
97
|
+
? {
|
|
98
|
+
...UNARMED,
|
|
99
|
+
queued: true,
|
|
100
|
+
holds: 0,
|
|
101
|
+
idleRemaining: limits.idleMs ?? null,
|
|
102
|
+
fixture: event.fixtureFirst && limits.fixtureMs !== undefined ? event.at + limits.fixtureMs : null,
|
|
103
|
+
}
|
|
95
104
|
: armed(limits, event.at, event.testing, event.fixture);
|
|
96
105
|
case 'granted': {
|
|
97
106
|
if (bounds.holds === null) return bounds;
|