@smoothbricks/nx-plugin 0.4.30 → 0.5.0
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 +36 -21
- package/dist/cargo-toolchain-policy.d.ts +6 -6
- package/dist/cargo-toolchain-policy.js +6 -6
- package/dist/cross-check-policy.d.ts +31 -14
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +43 -15
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +22 -5
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +189 -18
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +3 -2
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/run-cpu-pool.js +63 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts +60 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -0
- package/dist/executors/cargo-zigbuild/executor.js +266 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts +15 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts.map +1 -0
- package/dist/index.d.ts +3 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -92
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -2
- package/executors.json +4 -4
- package/managed/raw/patches/nx@23.2.1.patch +177 -9
- package/managed/raw/tooling/direnv/devenv.smoo.nix +46 -46
- package/managed/raw/tooling/direnv/setup-environment.ts +13 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +41 -23
- package/package.json +1 -1
- package/src/cargo-closure-key.test.ts +3 -2
- package/src/cargo-toolchain-policy.ts +6 -6
- package/src/cross-check-policy.test.ts +90 -11
- package/src/cross-check-policy.ts +47 -17
- package/src/executors/bounded-exec/cpu-tokens.test.ts +205 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +229 -22
- package/src/executors/bounded-exec/executor.ts +3 -2
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +76 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +75 -0
- package/src/executors/cargo-zigbuild/executor.test.ts +129 -0
- package/src/executors/cargo-zigbuild/executor.ts +176 -0
- package/src/executors/cargo-zigbuild/schema.json +35 -0
- package/src/executors/cargo-zigbuild/schema.ts +14 -0
- package/src/index.test.ts +41 -63
- package/src/index.ts +73 -101
- package/src/nx-daemon-validity.test.ts +65 -0
- package/src/testing.ts +3 -2
- package/test-timings.json +2 -1
- package/dist/executors/napi-cross-toolchain/executor.d.ts +0 -42
- package/dist/executors/napi-cross-toolchain/executor.d.ts.map +0 -1
- package/dist/executors/napi-cross-toolchain/executor.js +0 -126
- package/dist/executors/napi-cross-toolchain/schema.d.ts +0 -4
- package/dist/executors/napi-cross-toolchain/schema.d.ts.map +0 -1
- package/src/executors/napi-cross-toolchain/executor.test.ts +0 -112
- package/src/executors/napi-cross-toolchain/executor.ts +0 -165
- package/src/executors/napi-cross-toolchain/schema.json +0 -15
- package/src/executors/napi-cross-toolchain/schema.ts +0 -3
- /package/dist/executors/{napi-cross-toolchain → cargo-zigbuild}/schema.js +0 -0
package/README.md
CHANGED
|
@@ -757,17 +757,21 @@ Concrete targets come from concrete files:
|
|
|
757
757
|
one has finished. Explicit target declarations are not platform-conditional: dependency-only target nodes and their
|
|
758
758
|
ordering edges remain off macOS even though no executable group runner is inferred. The ordinary `test` and
|
|
759
759
|
`cargo-test` aggregates must still reach neither group.
|
|
760
|
-
- Canonical `napi` package metadata provides a host `cargo-napi` target
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
760
|
+
- Canonical `napi` package metadata provides a host `cargo-napi` target (only when no configured triple is the host's
|
|
761
|
+
own platform) and named release targets for each configured triple. macOS triples run `napi build` with the host's
|
|
762
|
+
toolchain, because a macOS addon needs Apple's SDK, which zig does not carry; the napi CLI also writes the platform
|
|
763
|
+
`.d.ts`.
|
|
764
|
+
- Linux artifacts reference no build-host path. N-API addons link glibc 2.17 symbol versions and carry no RUNPATH;
|
|
765
|
+
binaries a package builds for Linux, such as a CLI, build the same way. Both are built by devenv's zig through
|
|
766
|
+
cargo-zigbuild, with the same command on every host. Each Linux triple's `napi-<arch>-linux` target runs the
|
|
767
|
+
`@smoothbricks/nx-plugin:cargo-zigbuild` executor with `--target <triple>.2.17`, and the executor copies the cdylib to
|
|
768
|
+
`dist/native/linux-<arch>-gnu/<binaryName>.linux-<arch>-gnu.node` itself: the napi CLI cannot carry the glibc suffix,
|
|
769
|
+
since it looks for the artifact under `target/<triple>.2.17/`. A package-local `cli-<arch>-linux` uses the same
|
|
770
|
+
executor with `bin` set; a static CLI targets `<arch>-unknown-linux-musl`. The executor runs `cargo-zigbuild`
|
|
771
|
+
directly, removes any compiler or linker the shell names for its triple (a Linux shell pins its host compiler for
|
|
772
|
+
`x86_64-unknown-linux-gnu`), and reads the artifact path from cargo's JSON messages. zig and cargo-zigbuild come from
|
|
773
|
+
the managed devenv module: a Linux shell carries them, a macOS shell only inside the `linux-cross` profile
|
|
774
|
+
(`tooling/devenv -P linux-cross shell -- …`).
|
|
771
775
|
- `build` is inferred only when the project has at least one concrete build target to run, such as inferred `tsc-js`, a
|
|
772
776
|
package-local target like `tsdown-js`, or `cargo-wasm` from this plugin. It depends on output-family wildcard targets:
|
|
773
777
|
`*-js`, `*-web`, `*-html`, `*-css`, `*-ios`, `*-android`, `*-native`, `*-napi`, `*-bun`, and `*-wasm`.
|
|
@@ -1435,16 +1439,27 @@ callers use the CLI facade rather than introducing another disk-command runner.
|
|
|
1435
1439
|
Without an inherited parent pool, a `bounded-exec` command takes CPU tokens from cowshed's host budget before it starts,
|
|
1436
1440
|
when the gateway answers on the same socket (`specs/cowshed/05_gateway.md`, "Host CPU budget"), so concurrent gates on
|
|
1437
1441
|
one host keep their runnable work near the core count instead of each sizing its runners to the whole machine. It asks
|
|
1438
|
-
for the runner's requested parallelism
|
|
1439
|
-
|
|
1440
|
-
`
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
`
|
|
1447
|
-
|
|
1442
|
+
for the runner's requested parallelism, read from the runner's own flag rather than the core count — nextest's
|
|
1443
|
+
`--test-threads` or one per core (one for `--no-capture`, which runs tests serially), `bun test --parallel=N` N,
|
|
1444
|
+
Stryker's `--concurrency` N or N% (default one per core less one past four cores), Vitest's `--maxWorkers` N or N%
|
|
1445
|
+
(default one per core less one), `go test -p` (default `GOMAXPROCS`), cargo-mutants' `--jobserver-tasks` (default one
|
|
1446
|
+
per core, whatever `--jobs` says), a cargo build one per core, anything else one, or the target's `parallelism` option —
|
|
1447
|
+
bounded by positive inherited `NEXTEST_TEST_THREADS`/`CARGO_BUILD_JOBS` ceilings. A configured count can lower an
|
|
1448
|
+
inherited ceiling, never raise it. The runner uses `min(bounded request, granted tokens)`: nextest's environment and
|
|
1449
|
+
named flag, Bun's parallel flag, Stryker's, Vitest's and go's worker flag (added when the command names none),
|
|
1450
|
+
cargo-mutants' jobserver tasks, `--jobs` and per-process test threads, and Cargo's jobs are sized to that limit. A
|
|
1451
|
+
runner that starts its own workers or jobserver (cargo-mutants, Stryker, Vitest, `go test`) ignores the `cargo`
|
|
1452
|
+
launcher's fifo, so it must run under `bounded-exec`; the inferred `mutation` target does. Cargo's `RUST_TEST_THREADS`
|
|
1453
|
+
retains its independent inherited/configured ceiling. `BOUNDED_EXEC_CPU_TOKENS`, the sub-ledger and telemetry still name
|
|
1454
|
+
the actual held grant. The gateway shares tokens fairly between checkouts (Nx workspace roots). `timeoutMs` and
|
|
1455
|
+
`idleTimeoutMs` start at the grant. The tokens go back when the command exits, or with the executor's socket when it is
|
|
1456
|
+
killed. The wait prints one `cowshed: cpu-tokens wait done elapsed=… tokens=<granted>/<asked>` line. On a host whose
|
|
1457
|
+
gateway socket does not exist (a CI runner, a machine without cowshed), the plugin's `preTasksExecution` serves each Nx
|
|
1458
|
+
run that inherits no pool its own `BOUNDED_EXEC_CPU_POOL` of one token per core, and `postTasksExecution` closes it: the
|
|
1459
|
+
run's targets, started side by side under `NX_PARALLEL=100%`, queue for its cores instead of each sizing its runner to
|
|
1460
|
+
the whole host (`specs/cowshed/05_gateway.md`, "A run without a gateway budgets itself"). Its scope is one run. A
|
|
1461
|
+
command no pool and no gateway answers runs exactly as configured and nothing is said; a gateway from before the budget
|
|
1462
|
+
runs it unbudgeted and stderr says so.
|
|
1448
1463
|
|
|
1449
1464
|
A granted executor serves a private `BOUNDED_EXEC_CPU_POOL` with its actual token count. A nested default executor asks
|
|
1450
1465
|
that immediate parent pool for its own demand, instead of taking from the host while the parent holds its grant; the
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
* two machines ever agree and no cargo target can share a cache entry with a
|
|
19
19
|
* peer or with CI — a remote cache for Rust was dead on arrival. And the dump
|
|
20
20
|
* differs between a bare shell and a devenv profile for the SAME sources: in
|
|
21
|
-
* the `linux-cross` profile `
|
|
22
|
-
* `
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* the `linux-cross` profile `CARGO_INSTALL_ROOT` moves under
|
|
22
|
+
* `profiles/linux-cross/`, and every variable the profile's tools set appears,
|
|
23
|
+
* so the entry `check:linux` writes inside the profile could never be hit by
|
|
24
|
+
* the pre-push probe, which runs bare. Measured on one repository-root archive
|
|
25
|
+
* target with the dump still in place: bare 18197306115812424011, in-profile
|
|
26
|
+
* 12567954759860890767.
|
|
27
27
|
*
|
|
28
28
|
* A file input has neither defect. The lock's bytes are identical bare and
|
|
29
29
|
* in-profile and on every machine holding the checkout, while the toolchain
|
|
@@ -19,12 +19,12 @@ import { runtimeInput, shellWord } from './runtime-input.js';
|
|
|
19
19
|
* two machines ever agree and no cargo target can share a cache entry with a
|
|
20
20
|
* peer or with CI — a remote cache for Rust was dead on arrival. And the dump
|
|
21
21
|
* differs between a bare shell and a devenv profile for the SAME sources: in
|
|
22
|
-
* the `linux-cross` profile `
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
22
|
+
* the `linux-cross` profile `CARGO_INSTALL_ROOT` moves under
|
|
23
|
+
* `profiles/linux-cross/`, and every variable the profile's tools set appears,
|
|
24
|
+
* so the entry `check:linux` writes inside the profile could never be hit by
|
|
25
|
+
* the pre-push probe, which runs bare. Measured on one repository-root archive
|
|
26
|
+
* target with the dump still in place: bare 18197306115812424011, in-profile
|
|
27
|
+
* 12567954759860890767.
|
|
28
28
|
*
|
|
29
29
|
* A file input has neither defect. The lock's bytes are identical bare and
|
|
30
30
|
* in-profile and on every machine holding the checkout, while the toolchain
|
|
@@ -5,11 +5,12 @@
|
|
|
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 — a devenv profile carrying the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* to agree — a devenv profile carrying the Linux toolchain (zig, cargo-zigbuild
|
|
9
|
+
* and the Linux rust-std set), an Nx target per Cargo workspace that asks for
|
|
10
|
+
* the triple, and a root script that runs the second inside the first. They
|
|
11
|
+
* live here together because the plugin infers the target while the CLI
|
|
12
|
+
* installs the script and reports a project missing it; kept apart, the three
|
|
13
|
+
* spellings drift and the gate silently stops gating.
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
16
|
* The triple CI's Linux job compiles, and the one a macOS host can cross-check.
|
|
@@ -17,9 +18,10 @@
|
|
|
17
18
|
*/
|
|
18
19
|
export declare const CARGO_LINUX_TRIPLE = "x86_64-unknown-linux-gnu";
|
|
19
20
|
/**
|
|
20
|
-
* The devenv profile carrying the
|
|
21
|
-
* `tooling/direnv/devenv.smoo.nix`.
|
|
22
|
-
*
|
|
21
|
+
* The devenv profile carrying the Linux toolchain — zig, cargo-zigbuild and the
|
|
22
|
+
* Linux rust-std set — defined in the managed `tooling/direnv/devenv.smoo.nix`.
|
|
23
|
+
* Opt-in on macOS because zig alone is a 380 MiB closure that nothing but a
|
|
24
|
+
* Linux artifact or this check uses.
|
|
23
25
|
*/
|
|
24
26
|
export declare const DEVENV_CROSS_PROFILE = "linux-cross";
|
|
25
27
|
/**
|
|
@@ -34,12 +36,21 @@ export declare const DEVENV_CROSS_PROFILE = "linux-cross";
|
|
|
34
36
|
* build-output families, so no aggregate `build` picks it up either.
|
|
35
37
|
*/
|
|
36
38
|
export declare const CARGO_CROSS_LINT_TARGET = "cargo-lint-cross";
|
|
39
|
+
/**
|
|
40
|
+
* What the cross lint prints when it refuses to compile without cargo-zigbuild
|
|
41
|
+
* on PATH: on a Darwin cache miss this line, and only this line, means the
|
|
42
|
+
* key missed. The managed pre-push hook reads its output for exactly this text
|
|
43
|
+
* to tell a miss from any other Nx failure.
|
|
44
|
+
*/
|
|
45
|
+
export declare const CARGO_CROSS_LINT_REFUSAL = "cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux";
|
|
37
46
|
/**
|
|
38
47
|
* The prefix `cargoFrozen` writes. Exported so target inference can recognize
|
|
39
48
|
* the commands whose precondition `CARGO_FETCH_TARGET` supplies without
|
|
40
49
|
* re-spelling the flag; a second copy would silently stop matching.
|
|
41
50
|
*/
|
|
42
51
|
export declare const CARGO_FROZEN_PREFIX = "cargo --frozen ";
|
|
52
|
+
/** Does this command text run frozen cargo, directly or through cargo-zigbuild? */
|
|
53
|
+
export declare function runsFrozenCargo(text: string): boolean;
|
|
43
54
|
/**
|
|
44
55
|
* `--frozen` is cargo's `--locked` + `--offline`. Cargo.lock and the registry
|
|
45
56
|
* cache are inputs: inferred cargo must not rewrite the lockfile or fetch.
|
|
@@ -109,8 +120,13 @@ export declare const CARGO_DENY_WARNINGS = "--config 'build.warnings=\"deny\"'";
|
|
|
109
120
|
* must then refuse to launch.
|
|
110
121
|
*
|
|
111
122
|
* `--target` is explicit rather than inherited from a CARGO_BUILD_TARGET exported
|
|
112
|
-
* by the profile, so running this outside the cross shell fails loudly on
|
|
113
|
-
* missing
|
|
123
|
+
* by the profile, so running this outside the cross shell fails loudly on the
|
|
124
|
+
* missing cargo-zigbuild instead of quietly linting the host and reporting green.
|
|
125
|
+
*
|
|
126
|
+
* cargo-zigbuild rather than plain cargo because ring compiles C for the target
|
|
127
|
+
* from its build script, and build scripts run even under clippy: zig is the
|
|
128
|
+
* C compiler for every Linux triple on every host, the same one the Linux
|
|
129
|
+
* artifacts build with, so the check needs no per-triple cross gcc.
|
|
114
130
|
*
|
|
115
131
|
* `cargo fmt` is absent on purpose: formatting is target-independent and already
|
|
116
132
|
* covered by `cargo-lint`, so repeating it here would only cost time.
|
|
@@ -126,7 +142,7 @@ export declare const CARGO_DENY_WARNINGS = "--config 'build.warnings=\"deny\"'";
|
|
|
126
142
|
* are distinct anyway, and its own lock keeps the cross check from queueing
|
|
127
143
|
* behind host builds.
|
|
128
144
|
*/
|
|
129
|
-
export declare const CARGO_CROSS_LINT_COMMAND:
|
|
145
|
+
export declare const CARGO_CROSS_LINT_COMMAND = "command -v cargo-zigbuild >/dev/null || { echo 'cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux' >&2; exit 2; }; cargo-zigbuild clippy --frozen --workspace --all-targets --target x86_64-unknown-linux-gnu --target-dir target/cargo-lint-cross --config 'build.warnings=\"deny\"'";
|
|
130
146
|
/**
|
|
131
147
|
* No `--target-dir`: clippy writes the workspace's own `target/`, beside every
|
|
132
148
|
* dev build. Check units carry their mode in the unit hash, so they never
|
|
@@ -150,9 +166,10 @@ export declare const CROSS_CHECK_SCRIPT_NAME = "check:linux";
|
|
|
150
166
|
* cache and refuses a push that has no hit, never entering a profile or starting
|
|
151
167
|
* a compile of its own. That makes this script the only place the gate ever
|
|
152
168
|
* runs, and a human watching it needs devenv's progress too — the cross profile
|
|
153
|
-
*
|
|
154
|
-
* terminal is indistinguishable from a hang.
|
|
155
|
-
* while a hook ran this for you and nobody
|
|
169
|
+
* adds about 0.9 GiB (zig plus three rust-std targets) and the clippy behind it
|
|
170
|
+
* is unbounded, so a silent terminal is indistinguishable from a hang.
|
|
171
|
+
* Suppressing that output only paid while a hook ran this for you and nobody
|
|
172
|
+
* read it.
|
|
156
173
|
*/
|
|
157
174
|
export declare const CROSS_CHECK_SCRIPT_COMMAND = "tooling/devenv -P linux-cross shell -- nx run-many -t cargo-lint-cross";
|
|
158
175
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cross-check-policy.d.ts","sourceRoot":"","sources":["../src/cross-check-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,mGAC6D,CAAC;AAInG;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAYrD,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,uCAAqC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,wBAAwB,uUAA0L,CAAC;AAEhO;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,QAAyE,CAAC;AAEhH,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,0BAA0B,2EAAiG,CAAC;AAEzI;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,6DAA6D;AAC7D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE;AAID,iFAAiF;AACjF,wBAAgB,qCAAqC,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvF"}
|
|
@@ -5,11 +5,12 @@
|
|
|
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 — a devenv profile carrying the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* to agree — a devenv profile carrying the Linux toolchain (zig, cargo-zigbuild
|
|
9
|
+
* and the Linux rust-std set), an Nx target per Cargo workspace that asks for
|
|
10
|
+
* the triple, and a root script that runs the second inside the first. They
|
|
11
|
+
* live here together because the plugin infers the target while the CLI
|
|
12
|
+
* installs the script and reports a project missing it; kept apart, the three
|
|
13
|
+
* spellings drift and the gate silently stops gating.
|
|
13
14
|
*/
|
|
14
15
|
/**
|
|
15
16
|
* The triple CI's Linux job compiles, and the one a macOS host can cross-check.
|
|
@@ -17,9 +18,10 @@
|
|
|
17
18
|
*/
|
|
18
19
|
export const CARGO_LINUX_TRIPLE = 'x86_64-unknown-linux-gnu';
|
|
19
20
|
/**
|
|
20
|
-
* The devenv profile carrying the
|
|
21
|
-
* `tooling/direnv/devenv.smoo.nix`.
|
|
22
|
-
*
|
|
21
|
+
* The devenv profile carrying the Linux toolchain — zig, cargo-zigbuild and the
|
|
22
|
+
* Linux rust-std set — defined in the managed `tooling/direnv/devenv.smoo.nix`.
|
|
23
|
+
* Opt-in on macOS because zig alone is a 380 MiB closure that nothing but a
|
|
24
|
+
* Linux artifact or this check uses.
|
|
23
25
|
*/
|
|
24
26
|
export const DEVENV_CROSS_PROFILE = 'linux-cross';
|
|
25
27
|
/**
|
|
@@ -34,13 +36,33 @@ export const DEVENV_CROSS_PROFILE = 'linux-cross';
|
|
|
34
36
|
* build-output families, so no aggregate `build` picks it up either.
|
|
35
37
|
*/
|
|
36
38
|
export const CARGO_CROSS_LINT_TARGET = 'cargo-lint-cross';
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* What the cross lint prints when it refuses to compile without cargo-zigbuild
|
|
41
|
+
* on PATH: on a Darwin cache miss this line, and only this line, means the
|
|
42
|
+
* key missed. The managed pre-push hook reads its output for exactly this text
|
|
43
|
+
* to tell a miss from any other Nx failure.
|
|
44
|
+
*/
|
|
45
|
+
export const CARGO_CROSS_LINT_REFUSAL = 'cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux';
|
|
46
|
+
const CARGO_CROSS_LINT_GUARD = `command -v cargo-zigbuild >/dev/null || { echo '${CARGO_CROSS_LINT_REFUSAL}' >&2; exit 2; }`;
|
|
38
47
|
/**
|
|
39
48
|
* The prefix `cargoFrozen` writes. Exported so target inference can recognize
|
|
40
49
|
* the commands whose precondition `CARGO_FETCH_TARGET` supplies without
|
|
41
50
|
* re-spelling the flag; a second copy would silently stop matching.
|
|
42
51
|
*/
|
|
43
52
|
export const CARGO_FROZEN_PREFIX = 'cargo --frozen ';
|
|
53
|
+
/**
|
|
54
|
+
* cargo-zigbuild's spelling of frozen clippy. The flag sits on the subcommand
|
|
55
|
+
* because cargo does not forward a global `--frozen` to an external one:
|
|
56
|
+
* `cargo --frozen zigbuild` resolves and writes Cargo.lock as if unflagged
|
|
57
|
+
* (measured). And `cargo-zigbuild` is run directly rather than as
|
|
58
|
+
* `cargo zigbuild`, so its inner `cargo` is the one on PATH rather than the
|
|
59
|
+
* real binary cargo would hand it through `CARGO`.
|
|
60
|
+
*/
|
|
61
|
+
const CARGO_ZIGBUILD_CLIPPY_FROZEN_PREFIX = 'cargo-zigbuild clippy --frozen ';
|
|
62
|
+
/** Does this command text run frozen cargo, directly or through cargo-zigbuild? */
|
|
63
|
+
export function runsFrozenCargo(text) {
|
|
64
|
+
return text.includes(CARGO_FROZEN_PREFIX) || text.includes(CARGO_ZIGBUILD_CLIPPY_FROZEN_PREFIX);
|
|
65
|
+
}
|
|
44
66
|
/**
|
|
45
67
|
* `--frozen` is cargo's `--locked` + `--offline`. Cargo.lock and the registry
|
|
46
68
|
* cache are inputs: inferred cargo must not rewrite the lockfile or fetch.
|
|
@@ -112,8 +134,13 @@ export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
|
|
|
112
134
|
* must then refuse to launch.
|
|
113
135
|
*
|
|
114
136
|
* `--target` is explicit rather than inherited from a CARGO_BUILD_TARGET exported
|
|
115
|
-
* by the profile, so running this outside the cross shell fails loudly on
|
|
116
|
-
* missing
|
|
137
|
+
* by the profile, so running this outside the cross shell fails loudly on the
|
|
138
|
+
* missing cargo-zigbuild instead of quietly linting the host and reporting green.
|
|
139
|
+
*
|
|
140
|
+
* cargo-zigbuild rather than plain cargo because ring compiles C for the target
|
|
141
|
+
* from its build script, and build scripts run even under clippy: zig is the
|
|
142
|
+
* C compiler for every Linux triple on every host, the same one the Linux
|
|
143
|
+
* artifacts build with, so the check needs no per-triple cross gcc.
|
|
117
144
|
*
|
|
118
145
|
* `cargo fmt` is absent on purpose: formatting is target-independent and already
|
|
119
146
|
* covered by `cargo-lint`, so repeating it here would only cost time.
|
|
@@ -129,7 +156,7 @@ export const CARGO_DENY_WARNINGS = `--config 'build.warnings="deny"'`;
|
|
|
129
156
|
* are distinct anyway, and its own lock keeps the cross check from queueing
|
|
130
157
|
* behind host builds.
|
|
131
158
|
*/
|
|
132
|
-
export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${
|
|
159
|
+
export const CARGO_CROSS_LINT_COMMAND = `${CARGO_CROSS_LINT_GUARD}; ${CARGO_ZIGBUILD_CLIPPY_FROZEN_PREFIX}--workspace --all-targets --target ${CARGO_LINUX_TRIPLE} --target-dir target/cargo-lint-cross ${CARGO_DENY_WARNINGS}`;
|
|
133
160
|
/**
|
|
134
161
|
* No `--target-dir`: clippy writes the workspace's own `target/`, beside every
|
|
135
162
|
* dev build. Check units carry their mode in the unit hash, so they never
|
|
@@ -153,9 +180,10 @@ export const CROSS_CHECK_SCRIPT_NAME = 'check:linux';
|
|
|
153
180
|
* cache and refuses a push that has no hit, never entering a profile or starting
|
|
154
181
|
* a compile of its own. That makes this script the only place the gate ever
|
|
155
182
|
* runs, and a human watching it needs devenv's progress too — the cross profile
|
|
156
|
-
*
|
|
157
|
-
* terminal is indistinguishable from a hang.
|
|
158
|
-
* while a hook ran this for you and nobody
|
|
183
|
+
* adds about 0.9 GiB (zig plus three rust-std targets) and the clippy behind it
|
|
184
|
+
* is unbounded, so a silent terminal is indistinguishable from a hang.
|
|
185
|
+
* Suppressing that output only paid while a hook ran this for you and nobody
|
|
186
|
+
* read it.
|
|
159
187
|
*/
|
|
160
188
|
export const CROSS_CHECK_SCRIPT_COMMAND = `tooling/devenv -P ${DEVENV_CROSS_PROFILE} shell -- nx run-many -t ${CARGO_CROSS_LINT_TARGET}`;
|
|
161
189
|
/**
|
|
@@ -16,26 +16,42 @@ export type RunnerKind =
|
|
|
16
16
|
'nextest'
|
|
17
17
|
/** `bun test --parallel`: its worker processes. */
|
|
18
18
|
| 'bun-parallel'
|
|
19
|
+
/** A runner whose worker count is one flag of its own (`WORKER_FLAGS`). */
|
|
20
|
+
| WorkerFlagKind
|
|
21
|
+
/** `cargo mutants`: its own jobserver's tasks, `--jobserver-tasks`, shared by the `--jobs` cargo processes it starts. */
|
|
22
|
+
| 'cargo-mutants'
|
|
19
23
|
/** A cargo build (`cargo build`/`test`/`clippy`/…, `nextest archive`, `napi build`): its jobs. */
|
|
20
24
|
| 'cargo'
|
|
21
25
|
/** Anything else, one `bun test` process included: one process unless it declares more. */
|
|
22
26
|
| 'process';
|
|
23
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* What a runner asks the budget for. Cargo also carries its independent test-thread ceiling; cargo-mutants carries
|
|
29
|
+
* how many cargo processes it runs at once, which share its grant.
|
|
30
|
+
*/
|
|
24
31
|
export type Demand = {
|
|
25
32
|
kind: 'cargo';
|
|
26
33
|
want: number;
|
|
27
34
|
testThreads: number | null;
|
|
28
35
|
} | {
|
|
29
|
-
kind:
|
|
36
|
+
kind: 'cargo-mutants';
|
|
37
|
+
want: number;
|
|
38
|
+
jobs: number;
|
|
39
|
+
} | {
|
|
40
|
+
kind: Exclude<RunnerKind, 'cargo' | 'cargo-mutants'>;
|
|
30
41
|
want: number;
|
|
31
42
|
};
|
|
32
43
|
/** Every budgeted command learns its grant here, so a script that starts a runner can size it. */
|
|
33
44
|
export declare const CPU_TOKENS_ENV = "BOUNDED_EXEC_CPU_TOKENS";
|
|
45
|
+
type WorkerFlagKind = 'stryker' | 'vitest' | 'go-test';
|
|
34
46
|
/**
|
|
35
47
|
* What `command` asks for: its kind by invocation, and `declared` (the target's `parallelism`)
|
|
36
|
-
* when it says, else the count the command names (`--test-threads=N`, `--parallel=N
|
|
37
|
-
* runner's own default — one thread per core for
|
|
38
|
-
*
|
|
48
|
+
* when it says, else the count the command names (`--test-threads=N`, `--parallel=N`, a worker
|
|
49
|
+
* flag's N or N%, `--jobserver-tasks=N`), else the runner's own default — one thread per core for
|
|
50
|
+
* nextest, a bare `--parallel` and cargo; a worker-flag runner's own (`WORKER_FLAGS`); one per core
|
|
51
|
+
* for cargo-mutants, whose own jobserver defaults to one task per core whatever `--jobs` says; one
|
|
52
|
+
* process for anything else. A nextest run with `--no-capture` runs one test at a time whatever
|
|
53
|
+
* thread count it names, so it asks for one. Positive inherited runner counts are ceilings;
|
|
54
|
+
* configured counts may only lower them.
|
|
39
55
|
*/
|
|
40
56
|
export declare function runnerDemand(command: string, declared: number | undefined, cores: number, inherited: Readonly<NodeJS.ProcessEnv>, configured?: Readonly<NodeJS.ProcessEnv>): Demand;
|
|
41
57
|
/**
|
|
@@ -79,4 +95,5 @@ export interface CpuBudget {
|
|
|
79
95
|
* workspace root: the gateway shares tokens fairly between checkouts.
|
|
80
96
|
*/
|
|
81
97
|
export declare function gatewayCpuBudget(socket?: string): CpuBudget;
|
|
98
|
+
export {};
|
|
82
99
|
//# sourceMappingURL=cpu-tokens.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpu-tokens.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/cpu-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnF;;;;;;;;;;GAUG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd
|
|
1
|
+
{"version":3,"file":"cpu-tokens.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/cpu-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnF;;;;;;;;;;GAUG;AAEH,kGAAkG;AAClG,MAAM,MAAM,UAAU;AACpB,mFAAmF;AACjF,SAAS;AACX,mDAAmD;GACjD,cAAc;AAChB,2EAA2E;GACzE,cAAc;AAChB,yHAAyH;GACvH,eAAe;AACjB,kGAAkG;GAChG,OAAO;AACT,2FAA2F;GACzF,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,kGAAkG;AAClG,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAkBxD,KAAK,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AA+CvD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EACtC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GACvC,MAAM,CAyBR;AAkHD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAkDlD;AASD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAM7E;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,GAC/F;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,uFAAuF;AACvF,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,MAAuB,GAAG,SAAS,CAuB3E"}
|