@smoothbricks/nx-plugin 0.6.3-0 → 0.7.1
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 +159 -121
- package/dist/.build-inputs.json +25 -20
- package/dist/bin/smoo-nx-go-test-build.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-build.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-build.js +79 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts +3 -0
- package/dist/bin/smoo-nx-go-test-run.d.ts.map +1 -0
- package/dist/bin/smoo-nx-go-test-run.js +129 -0
- package/dist/bounded-test-policy.d.ts +1 -1
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +9 -8
- package/dist/cargo-workspace.d.ts +10 -20
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +12 -22
- package/dist/cross-check-policy.d.ts +2 -2
- package/dist/cross-check-policy.js +2 -2
- package/dist/deploy-policy.d.ts +6 -0
- package/dist/deploy-policy.d.ts.map +1 -1
- package/dist/deploy-policy.js +11 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +49 -37
- package/dist/executors/bounded-exec/mbx-pool.d.ts +39 -10
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +78 -24
- package/dist/executors/bounded-exec/progress.js +5 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts +40 -2
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +55 -4
- package/dist/executors/bounded-exec/runtime-pin.js +1 -1
- package/dist/executors/bounded-exec/verdict.d.ts +6 -0
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +6 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts +10 -0
- package/dist/executors/wrangler-deploy/deploy-hash.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/deploy-hash.js +14 -0
- package/dist/executors/wrangler-deploy/executor.d.ts +24 -0
- package/dist/executors/wrangler-deploy/executor.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/executor.js +43 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts +27 -0
- package/dist/executors/wrangler-deploy/hasher.d.ts.map +1 -0
- package/dist/executors/wrangler-deploy/hasher.js +90 -0
- package/dist/executors/wrangler-deploy/schema.d.ts +5 -0
- package/dist/executors/wrangler-deploy/schema.d.ts.map +1 -0
- package/dist/go-tests.d.ts +30 -0
- package/dist/go-tests.d.ts.map +1 -0
- package/dist/go-tests.js +43 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +271 -230
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +5 -0
- package/dist/process-group.js +2 -2
- package/dist/runtime-input-policy.d.ts +3 -3
- package/dist/runtime-input-policy.js +3 -3
- package/dist/test-timings.d.ts +23 -4
- package/dist/test-timings.d.ts.map +1 -1
- package/dist/test-timings.js +72 -12
- package/dist/version-actions.cjs +10 -11
- package/dist/version-actions.d.cts.map +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +17 -22
- package/dist/workspace-manifest.js +3 -3
- package/executors.json +6 -5
- package/managed/raw/patches/nx@23.2.1.patch +118 -24
- package/managed/raw/patches/ttsc@0.34.1.patch +64 -0
- package/managed/raw/tooling/direnv/developer-links.ts +121 -51
- package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
- package/managed/raw/tooling/direnv/setup-environment.ts +14 -4
- package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
- package/package.json +58 -8
- package/runtime/nx-publish/.build-inputs.json +11 -0
- package/runtime-input.sh +50 -23
- package/src/bin/smoo-nx-go-test-build.ts +83 -0
- package/src/bin/smoo-nx-go-test-run.ts +140 -0
- package/src/bounded-test-policy.ts +9 -8
- package/src/cargo-workspace.ts +12 -24
- package/src/cross-check-policy.ts +2 -2
- package/src/deploy-policy.ts +11 -0
- package/src/executors/bounded-exec/executor.ts +61 -42
- package/src/executors/bounded-exec/mbx-pool.ts +97 -33
- package/src/executors/bounded-exec/progress.ts +5 -5
- package/src/executors/bounded-exec/runner-sizing.ts +73 -7
- package/src/executors/bounded-exec/runtime-pin.ts +1 -1
- package/src/executors/bounded-exec/verdict.ts +7 -0
- package/src/executors/wrangler-deploy/deploy-hash.ts +15 -0
- package/src/executors/wrangler-deploy/executor.ts +63 -0
- package/src/executors/wrangler-deploy/hasher.ts +111 -0
- package/src/executors/wrangler-deploy/schema.json +16 -0
- package/src/executors/wrangler-deploy/schema.ts +4 -0
- package/src/go-tests.ts +67 -0
- package/src/index.ts +294 -253
- package/src/managed-files/files.ts +5 -0
- package/src/process-group.ts +2 -2
- package/src/runtime-input-policy.ts +3 -3
- package/src/test-timings.ts +72 -14
- package/src/version-actions.cts +10 -11
- package/src/workspace-config-policy.ts +20 -29
- package/src/workspace-manifest.ts +3 -3
- package/test-timings.json +131 -130
- package/dist/executors/clean-outputs/executor.d.ts +0 -26
- package/dist/executors/clean-outputs/executor.d.ts.map +0 -1
- package/dist/executors/clean-outputs/executor.js +0 -83
- package/dist/executors/clean-outputs/schema.d.ts +0 -4
- package/dist/executors/clean-outputs/schema.d.ts.map +0 -1
- package/src/executors/clean-outputs/executor.ts +0 -131
- package/src/executors/clean-outputs/schema.json +0 -15
- package/src/executors/clean-outputs/schema.ts +0 -3
- /package/dist/executors/{clean-outputs → wrangler-deploy}/schema.js +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type SpawnSyncReturns, spawnSync } from 'node:child_process';
|
|
3
|
+
import { lstatSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { join, relative, resolve } from 'node:path';
|
|
5
|
+
import { GO_TESTS_MANIFEST, type GoTestBinary, type GoTestsManifest } from '../go-tests.js';
|
|
6
|
+
|
|
7
|
+
// Builds a Go module's test binaries ahead of their run, so the build can be a cached target of its own: run in the
|
|
8
|
+
// module, it builds one `go test -c` binary for each package with test files among <package pattern>..., as `go list`
|
|
9
|
+
// resolves them, and writes <out-dir>/go-tests.json naming each binary's package and directory for
|
|
10
|
+
// smoo-nx-go-test-run. <out-dir> is replaced whole, so no binary of a package that lost its tests lingers; a directory
|
|
11
|
+
// that holds no such manifest is never replaced. Exit 2 on a usage error or such a directory; go's own status when go
|
|
12
|
+
// fails, its diagnostics already on stderr.
|
|
13
|
+
const usage = 'usage: smoo-nx-go-test-build <out-dir> <package pattern>...\n';
|
|
14
|
+
const words = process.argv.slice(2);
|
|
15
|
+
const [outWord, ...patterns] = words;
|
|
16
|
+
if (outWord === undefined || patterns.length === 0 || words.some((word) => word.startsWith('-'))) {
|
|
17
|
+
process.stderr.write(usage);
|
|
18
|
+
process.exit(2);
|
|
19
|
+
}
|
|
20
|
+
const out = resolve(outWord);
|
|
21
|
+
// One record per package with test files: its import path and directory, each NUL-terminated; go list ends the
|
|
22
|
+
// output of every package that printed one with a newline. No path holds a NUL, so the records split exactly.
|
|
23
|
+
const LISTED = '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{"\\x00"}}{{.Dir}}{{"\\x00"}}{{end}}';
|
|
24
|
+
|
|
25
|
+
function refuse(reason: string): never {
|
|
26
|
+
process.stderr.write(`smoo-nx-go-test-build: ${reason}\n`);
|
|
27
|
+
process.exit(2);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function exists(path: string): boolean {
|
|
31
|
+
try {
|
|
32
|
+
lstatSync(path);
|
|
33
|
+
return true;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return false;
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** `go args`; when it fails, this build ends with go's status after `cleanup`. */
|
|
41
|
+
function go(args: readonly string[], capture: boolean, cleanup: () => void): SpawnSyncReturns<string> {
|
|
42
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: go list resolves and go test -c compiles for as long as the module takes; the target that runs this build bounds it, or the operator's interrupt ends it
|
|
43
|
+
const ran = spawnSync('go', args, { stdio: ['ignore', capture ? 'pipe' : 'inherit', 'inherit'], encoding: 'utf8' });
|
|
44
|
+
if (ran.error !== undefined || ran.status !== 0) {
|
|
45
|
+
cleanup();
|
|
46
|
+
const ended = ran.error?.message ?? (ran.signal === null ? `exit ${ran.status}` : `killed by ${ran.signal}`);
|
|
47
|
+
process.stderr.write(`smoo-nx-go-test-build: go ${args.join(' ')} failed: ${ended}\n`);
|
|
48
|
+
process.exit(ran.status === null || ran.status === 0 ? 2 : ran.status);
|
|
49
|
+
}
|
|
50
|
+
return ran;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (exists(out) && !exists(join(out, GO_TESTS_MANIFEST))) {
|
|
54
|
+
refuse(`${out} exists and holds no ${GO_TESTS_MANIFEST}; only a directory this tool built is replaced`);
|
|
55
|
+
}
|
|
56
|
+
const packages = go(['list', '-f', LISTED, ...patterns], true, () => {})
|
|
57
|
+
.stdout.split('\0\n')
|
|
58
|
+
.filter((record) => record !== '')
|
|
59
|
+
.map((record) => {
|
|
60
|
+
const [importPath, dir, ...rest] = record.split('\0');
|
|
61
|
+
if (importPath === undefined || dir === undefined || rest.length > 0) {
|
|
62
|
+
refuse(`go list printed a record that is no import path and directory: ${JSON.stringify(record)}`);
|
|
63
|
+
}
|
|
64
|
+
return { importPath, dir };
|
|
65
|
+
})
|
|
66
|
+
.sort((a, b) => (a.importPath < b.importPath ? -1 : a.importPath > b.importPath ? 1 : 0));
|
|
67
|
+
|
|
68
|
+
const staging = `${out}.building-${process.pid}`;
|
|
69
|
+
const dropStaging = () => rmSync(staging, { recursive: true, force: true });
|
|
70
|
+
dropStaging();
|
|
71
|
+
mkdirSync(staging, { recursive: true });
|
|
72
|
+
const tests: GoTestBinary[] = [];
|
|
73
|
+
for (const { importPath, dir } of packages) {
|
|
74
|
+
// Injective, so no two packages share a binary, and readable enough to name the package.
|
|
75
|
+
const binary = `${encodeURIComponent(importPath)}.test`;
|
|
76
|
+
go(['test', '-c', '-o', join(staging, binary), importPath], false, dropStaging);
|
|
77
|
+
tests.push({ binary, dir: relative(out, dir) || '.', importPath });
|
|
78
|
+
}
|
|
79
|
+
const manifest: GoTestsManifest = { version: 1, tests };
|
|
80
|
+
writeFileSync(join(staging, GO_TESTS_MANIFEST), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
81
|
+
rmSync(out, { recursive: true, force: true });
|
|
82
|
+
renameSync(staging, out);
|
|
83
|
+
process.stdout.write(`smoo-nx-go-test-build: ${tests.length} test binaries in ${out}\n`);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
3
|
+
import { statSync } from 'node:fs';
|
|
4
|
+
import { availableParallelism } from 'node:os';
|
|
5
|
+
import type { Readable, Writable } from 'node:stream';
|
|
6
|
+
import { type GoTestBinary, readGoTestsManifest } from '../go-tests.js';
|
|
7
|
+
|
|
8
|
+
// Runs the test binaries smoo-nx-go-test-build listed in <go-tests.json> as `go test -json` runs a package's binary:
|
|
9
|
+
// in its package directory, under `go tool test2json -t -p <import path>`, with the flags go test gives it, up to -p
|
|
10
|
+
// binaries at once (default GOMAXPROCS, else one per core, as go test's -p). Each event line reaches stdout whole, so
|
|
11
|
+
// bounded-exec reads results, verdict and progress from it as from go test (GO_TEST_RUNNER); `-json` is accepted and
|
|
12
|
+
// implied. A manifest listing no binary is refused unless --allow-empty says none is expected, so a package pattern
|
|
13
|
+
// that matched no tests cannot pass. Exit 1 when any binary failed, 2 on a usage error or a manifest it cannot run.
|
|
14
|
+
const usage = 'usage: smoo-nx-go-test-run [-p=N] [-json] [--allow-empty] <go-tests.json>\n';
|
|
15
|
+
// What `go test -json` passes every test binary it runs, its default -timeout included.
|
|
16
|
+
const GO_TEST_BINARY_FLAGS = ['-test.v=test2json', '-test.paniconexit0', '-test.timeout=10m0s'];
|
|
17
|
+
const COUNT = /^[1-9]\d*$/;
|
|
18
|
+
|
|
19
|
+
function refuse(reason: string): never {
|
|
20
|
+
process.stderr.write(`smoo-nx-go-test-run: ${reason}\n`);
|
|
21
|
+
process.exit(2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface RunArguments {
|
|
25
|
+
readonly packages: number | null;
|
|
26
|
+
readonly allowEmpty: boolean;
|
|
27
|
+
readonly manifest: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseArguments(words: readonly string[]): RunArguments | null {
|
|
31
|
+
let packages: number | null = null;
|
|
32
|
+
let allowEmpty = false;
|
|
33
|
+
let manifest: string | null = null;
|
|
34
|
+
for (let at = 0; at < words.length; at += 1) {
|
|
35
|
+
const word = words[at] ?? '';
|
|
36
|
+
const flag = /^-p(?:=(.*))?$/.exec(word);
|
|
37
|
+
if (flag !== null) {
|
|
38
|
+
let value = flag[1];
|
|
39
|
+
if (value === undefined) {
|
|
40
|
+
at += 1;
|
|
41
|
+
value = words[at];
|
|
42
|
+
}
|
|
43
|
+
if (value === undefined || !COUNT.test(value)) return null;
|
|
44
|
+
packages = Number(value);
|
|
45
|
+
} else if (word === '--allow-empty') {
|
|
46
|
+
allowEmpty = true;
|
|
47
|
+
} else if (word === '-json' || word === '-json=true') {
|
|
48
|
+
// Implied: test2json writes nothing else.
|
|
49
|
+
} else if (word.startsWith('-') || word === '' || manifest !== null) {
|
|
50
|
+
return null;
|
|
51
|
+
} else {
|
|
52
|
+
manifest = word;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return manifest === null ? null : { packages, allowEmpty, manifest };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Every complete line `from` writes reaches `to` whole, so concurrent binaries' events never split a line. */
|
|
59
|
+
function forwardLines(from: Readable, to: Writable): void {
|
|
60
|
+
let pending: Buffer = Buffer.alloc(0);
|
|
61
|
+
from.on('data', (chunk: Buffer) => {
|
|
62
|
+
const bytes = pending.length === 0 ? chunk : Buffer.concat([pending, chunk]);
|
|
63
|
+
const end = bytes.lastIndexOf(10);
|
|
64
|
+
if (end === -1) {
|
|
65
|
+
pending = bytes;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
to.write(bytes.subarray(0, end + 1));
|
|
69
|
+
pending = bytes.subarray(end + 1);
|
|
70
|
+
});
|
|
71
|
+
from.on('end', () => {
|
|
72
|
+
if (pending.length > 0) to.write(Buffer.concat([pending, Buffer.from('\n')]));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Null when the binary passed, else how it ended. */
|
|
77
|
+
function runBinary(test2json: string, test: GoTestBinary): Promise<string | null> {
|
|
78
|
+
// The plugin's lib target (ES2022) has no Promise.withResolvers.
|
|
79
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: a test binary runs as long as its tests do; the bounded-exec run around this bin owns their progress bound and ends a hung one with its process group
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
const child = spawn(test2json, ['-t', '-p', test.importPath, test.binary, ...GO_TEST_BINARY_FLAGS], {
|
|
82
|
+
cwd: test.dir,
|
|
83
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
84
|
+
});
|
|
85
|
+
forwardLines(child.stdout, process.stdout);
|
|
86
|
+
forwardLines(child.stderr, process.stderr);
|
|
87
|
+
child.on('error', (error) => resolve(`could not start: ${error.message}`));
|
|
88
|
+
child.on('close', (code, signal) =>
|
|
89
|
+
resolve(code === 0 ? null : signal === null ? `exit ${code}` : `killed by ${signal}`),
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const parsed = parseArguments(process.argv.slice(2));
|
|
95
|
+
if (parsed === null) {
|
|
96
|
+
process.stderr.write(usage);
|
|
97
|
+
process.exit(2);
|
|
98
|
+
}
|
|
99
|
+
const read = readGoTestsManifest(parsed.manifest);
|
|
100
|
+
if (!read.ok) refuse(read.reason);
|
|
101
|
+
const tests = read.tests;
|
|
102
|
+
if (tests.length === 0) {
|
|
103
|
+
if (parsed.allowEmpty) process.exit(0);
|
|
104
|
+
refuse(
|
|
105
|
+
`${parsed.manifest} lists no test binaries, as when no package pattern matched a test; --allow-empty expects that`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
for (const test of tests) {
|
|
109
|
+
if (statSync(test.binary, { throwIfNoEntry: false })?.isFile() !== true) {
|
|
110
|
+
refuse(`${parsed.manifest} lists ${test.binary} for ${test.importPath}, which is no file; build it again`);
|
|
111
|
+
}
|
|
112
|
+
if (statSync(test.dir, { throwIfNoEntry: false })?.isDirectory() !== true) {
|
|
113
|
+
refuse(`${parsed.manifest} runs ${test.importPath} in ${test.dir}, which is no directory`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// eslint-disable-next-line deadline/no-unbounded-wait -- WHY unbounded: go builds test2json into its cache on its first use, for as long as that compile takes; the bounded-exec run around this bin ends a hung one
|
|
117
|
+
const tool = spawnSync('go', ['tool', '-n', 'test2json'], { stdio: ['ignore', 'pipe', 'inherit'], encoding: 'utf8' });
|
|
118
|
+
if (tool.error !== undefined || tool.status !== 0) {
|
|
119
|
+
refuse(`go tool -n test2json named no test2json: ${tool.error?.message ?? `exit ${tool.status ?? tool.signal}`}`);
|
|
120
|
+
}
|
|
121
|
+
const test2json = tool.stdout.trim();
|
|
122
|
+
const inherited = process.env.GOMAXPROCS;
|
|
123
|
+
const packages =
|
|
124
|
+
parsed.packages ?? (inherited !== undefined && COUNT.test(inherited) ? Number(inherited) : availableParallelism());
|
|
125
|
+
const failures: string[] = [];
|
|
126
|
+
const queue = tests.values();
|
|
127
|
+
const worker = async (): Promise<void> => {
|
|
128
|
+
for (const test of queue) {
|
|
129
|
+
const failure = await runBinary(test2json, test);
|
|
130
|
+
if (failure !== null) failures.push(`${test.importPath} (${failure})`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
await Promise.all(Array.from({ length: Math.min(packages, tests.length) }, worker));
|
|
134
|
+
if (failures.length > 0) {
|
|
135
|
+
failures.sort();
|
|
136
|
+
process.stderr.write(
|
|
137
|
+
`smoo-nx-go-test-run: ${failures.length} of ${tests.length} test binaries failed: ${failures.join(', ')}\n`,
|
|
138
|
+
);
|
|
139
|
+
process.exitCode = 1;
|
|
140
|
+
}
|
|
@@ -2,7 +2,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { expandWildcardTargetConfiguration } from 'nx/src/tasks-runner/utils.js';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
CARGO_TEST_BUILD_TARGET,
|
|
6
6
|
CARGO_TEST_TARGET,
|
|
7
7
|
listCargoWorkspacePackages,
|
|
8
8
|
packageNameFromCargoTestTarget,
|
|
@@ -162,7 +162,7 @@ export function checkWorkspaceBoundedTestTargetPolicy(
|
|
|
162
162
|
* package-local `nx.targets['cargo-test'].dependsOn` that omits the inferred
|
|
163
163
|
* runner leg leaves a target that still "reaches" its dependencies while no
|
|
164
164
|
* test binary is ever run. Reachability alone cannot see this, because
|
|
165
|
-
* `cargo-test-
|
|
165
|
+
* `cargo-test-build` only compiles. (Inference itself no longer skips a
|
|
166
166
|
* declared cargo key, so the executor and options survive the declaration —
|
|
167
167
|
* see `index.ts`.)
|
|
168
168
|
*
|
|
@@ -221,9 +221,9 @@ export function checkWorkspaceCargoTestReachabilityPolicy(
|
|
|
221
221
|
/**
|
|
222
222
|
* True when `target`, or something in its dependency closure, invokes cargo in a
|
|
223
223
|
* mode that executes tests. Compile-only steps are deliberately excluded:
|
|
224
|
-
* `cargo-test-
|
|
225
|
-
* `cargo
|
|
226
|
-
*
|
|
224
|
+
* `cargo-test-build` is `cargo nextest list --list-type binaries-only`, a cross
|
|
225
|
+
* lane's archive is `cargo nextest archive` and a `--no-run` build is
|
|
226
|
+
* `cargo test --no-run`. Each proves the binaries build and nothing about them
|
|
227
227
|
* only these is the silent green this check exists to catch.
|
|
228
228
|
*/
|
|
229
229
|
function resolvedTargetRunsTests(project: ResolvedProjectTargets, target: string): boolean {
|
|
@@ -239,7 +239,8 @@ function resolvedTargetRunsTests(project: ResolvedProjectTargets, target: string
|
|
|
239
239
|
command !== undefined &&
|
|
240
240
|
/\btest\b|\bnextest\b/.test(command) &&
|
|
241
241
|
!command.includes('--no-run') &&
|
|
242
|
-
!command.includes('nextest archive')
|
|
242
|
+
!command.includes('nextest archive') &&
|
|
243
|
+
!command.includes('nextest list');
|
|
243
244
|
const reached =
|
|
244
245
|
runs ||
|
|
245
246
|
(project.targetDependencies?.get(targetName) ?? []).some((dependency) =>
|
|
@@ -252,7 +253,7 @@ function resolvedTargetRunsTests(project: ResolvedProjectTargets, target: string
|
|
|
252
253
|
}
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
|
-
* Per-crate nextest targets that `cargo-test` actually reaches. `cargo-test-
|
|
256
|
+
* Per-crate nextest targets that `cargo-test` actually reaches. `cargo-test-build`
|
|
256
257
|
* is excluded: it is not a runner. Members come from the same Cargo.toml walk
|
|
257
258
|
* inference uses; the child list is the graph, not a hand-written crate list.
|
|
258
259
|
*/
|
|
@@ -453,7 +454,7 @@ function bunTestHasNoDeadline(command: string): boolean {
|
|
|
453
454
|
|
|
454
455
|
function isTestLegTargetName(name: string): boolean {
|
|
455
456
|
return (
|
|
456
|
-
name !==
|
|
457
|
+
name !== CARGO_TEST_BUILD_TARGET &&
|
|
457
458
|
cargoCrossTestTripleFromArchiveTarget(name) === null &&
|
|
458
459
|
isTestRunnerTargetName(name)
|
|
459
460
|
);
|
package/src/cargo-workspace.ts
CHANGED
|
@@ -267,7 +267,7 @@ async function deriveCargoPackageTestInputs(
|
|
|
267
267
|
// hashes a `{projectRoot}` glob against only the files its project OWNS, and
|
|
268
268
|
// a nested Nx project owns the crates under it. A repository-root cargo
|
|
269
269
|
// workspace whose members live in `packages/*` would then hash none of its
|
|
270
|
-
// members' sources, and its
|
|
270
|
+
// members' sources, and its test build would cache-hit against edited crates
|
|
271
271
|
// while every per-crate runner reran on the stale binaries.
|
|
272
272
|
const inputRoot = posix.join('{workspaceRoot}', relative(workspaceRoot, absoluteProjectRoot).split(sep).join('/'));
|
|
273
273
|
const loadManifest = (path: string): Promise<TomlTable> => {
|
|
@@ -578,24 +578,12 @@ function readTestShards(cratePackage: Record<string, unknown>, crateTomlPath: st
|
|
|
578
578
|
export const CARGO_TEST_TARGET = 'cargo-test';
|
|
579
579
|
|
|
580
580
|
/**
|
|
581
|
-
* The one workspace-wide
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
581
|
+
* The one workspace-wide test build every per-crate runner executes from, in
|
|
582
|
+
* place. Named here beside the other cargo target names so the policy that
|
|
583
|
+
* checks a workspace's test graph and the inference that builds it read the
|
|
584
|
+
* same string.
|
|
585
585
|
*/
|
|
586
|
-
export const
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* Where that archive lands, relative to the cargo workspace root — the cwd both
|
|
590
|
-
* the archive command and every runner already use. `cargo nextest archive`
|
|
591
|
-
* does NOT create this parent directory and fails the whole build when it is
|
|
592
|
-
* missing ("error writing to archive ... No such file or directory"), so the
|
|
593
|
-
* target mkdir's it first.
|
|
594
|
-
* The archive is an Nx-restored output, so it lives on the source volume, never
|
|
595
|
-
* beneath Cargo's symlinked target directory (16_build_volumes.md).
|
|
596
|
-
*/
|
|
597
|
-
export const CARGO_TEST_ARCHIVE_FILE = '.cache/nextest/archive.tar.zst';
|
|
598
|
-
|
|
586
|
+
export const CARGO_TEST_BUILD_TARGET = 'cargo-test-build';
|
|
599
587
|
/**
|
|
600
588
|
* One foreign target triple this cargo workspace also archives its tests for.
|
|
601
589
|
*/
|
|
@@ -717,14 +705,14 @@ export function cargoTestGroupTargetName(group: string): string {
|
|
|
717
705
|
* crate collapse back to that crate, so a split crate counts as covered once.
|
|
718
706
|
*
|
|
719
707
|
* The workspace-wide `cargo-test-*` targets are not crates: reading them as one
|
|
720
|
-
* would invent
|
|
708
|
+
* would invent a member named "build", and a serial group's runner
|
|
721
709
|
* would invent one named after its group. Each reports every crate's coverage
|
|
722
710
|
* against a set that can never match.
|
|
723
711
|
*/
|
|
724
712
|
export function packageNameFromCargoTestTarget(targetName: string): string | null {
|
|
725
713
|
if (
|
|
726
714
|
!targetName.startsWith('cargo-test-') ||
|
|
727
|
-
targetName ===
|
|
715
|
+
targetName === CARGO_TEST_BUILD_TARGET ||
|
|
728
716
|
targetName.startsWith(CARGO_TEST_GROUP_PREFIX)
|
|
729
717
|
) {
|
|
730
718
|
return null;
|
|
@@ -1063,9 +1051,9 @@ export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/
|
|
|
1063
1051
|
* The plugin's own nextest settings, as a config layer BENEATH the repository's.
|
|
1064
1052
|
*
|
|
1065
1053
|
* `--config-file` replaces `<workspace>/.config/nextest.toml` outright, which
|
|
1066
|
-
* made every plugin default unoverridable and
|
|
1067
|
-
*
|
|
1068
|
-
* cdylib or fixture
|
|
1054
|
+
* made every plugin default unoverridable and left a repository no way to
|
|
1055
|
+
* declare a setting of its own, such as the `archive.include` a cross lane needs
|
|
1056
|
+
* for a cdylib or fixture. `--tool-config-file` is nextest's mechanism
|
|
1069
1057
|
* for exactly this: "lower than --config-file in priority but above the default
|
|
1070
1058
|
* config shipped with nextest". Measured: with only this layer a 1s
|
|
1071
1059
|
* slow-timeout terminates a 3s test; adding `.config/nextest.toml` with 10s
|
|
@@ -1073,7 +1061,7 @@ export const PLUGIN_NEXTEST_CONFIG_PATH = 'node_modules/@smoothbricks/nx-plugin/
|
|
|
1073
1061
|
*
|
|
1074
1062
|
* The path must be absolute, and an absolute path written into the command text
|
|
1075
1063
|
* would differ per checkout and split one Nx cache entry per machine. `$PWD`
|
|
1076
|
-
* resolves at exec time — both the
|
|
1064
|
+
* resolves at exec time — both the test build (`nx:run-commands`) and the runners
|
|
1077
1065
|
* (`bounded-exec`, which spawns with `shell: true`) go through a shell — so the
|
|
1078
1066
|
* command text stays identical everywhere. Quoted, because a workspace path may
|
|
1079
1067
|
* contain spaces.
|
|
@@ -242,8 +242,8 @@ export function cargoCrossTestTargetName(triple: string): string {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
* One archive file per triple,
|
|
246
|
-
*
|
|
245
|
+
* One archive file per triple, relative to the cargo workspace root: the only
|
|
246
|
+
* test archives, since a same-platform run executes `cargo-test-build`'s binaries in place. Distinct
|
|
247
247
|
* paths are what let both exist: each is a declared Nx output, so a single path
|
|
248
248
|
* for two triples would let a restored cache serve one machine's binaries under
|
|
249
249
|
* the other's name.
|
package/src/deploy-policy.ts
CHANGED
|
@@ -38,3 +38,14 @@ export function stageDeploysProject(tags: string[] | undefined, stage: Deploymen
|
|
|
38
38
|
if (tags.includes(STAGING_DEPLOY_TAG)) return stage === 'staging';
|
|
39
39
|
return tags.includes(STAGE_DEPLOY_TAG);
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The tag a deploy uploads its version under, from the artifact hash it deploys: `nx-` and that hash when it is
|
|
44
|
+
* decimal (Nx's own), or the first 32 digits of a hexadecimal hash of at least 32. `smoo wrangler deploy-stage` tags
|
|
45
|
+
* with it, and the wrangler-deploy hasher compares the stage's live tag with it. Null for any other hash.
|
|
46
|
+
*/
|
|
47
|
+
export function deployVersionTag(artifactHash: string): string | null {
|
|
48
|
+
if (/^(?:0|[1-9][0-9]*)$/.test(artifactHash)) return `nx-${artifactHash}`;
|
|
49
|
+
const normalized = artifactHash.toLowerCase();
|
|
50
|
+
return /^[0-9a-f]{32,}$/.test(normalized) ? `nx-${normalized.slice(0, 32)}` : null;
|
|
51
|
+
}
|
|
@@ -38,7 +38,15 @@ import type { HangDiagnostics } from './hang-diagnostics.js';
|
|
|
38
38
|
import { captureHangDiagnostics, HANG_CAPTURE_MS } from './hang-diagnostics.js';
|
|
39
39
|
import type { CpuWaitRow } from './lease-wait.js';
|
|
40
40
|
import type { LockWait } from './lock-wait.js';
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
MBX_GRANT_FD,
|
|
43
|
+
mbxIdleGated,
|
|
44
|
+
mbxLeaf,
|
|
45
|
+
mbxPool,
|
|
46
|
+
nxTaskCores,
|
|
47
|
+
runsPrebuiltNextest,
|
|
48
|
+
withMbxLeaf,
|
|
49
|
+
} from './mbx-pool.js';
|
|
42
50
|
import { MBX_QUEUE_POLL_MS, type MbxQueuedRequest, snapshotMbxQueue } from './mbx-queue.js';
|
|
43
51
|
import { createNoSpaceWatch } from './no-space.js';
|
|
44
52
|
import {
|
|
@@ -64,7 +72,7 @@ import {
|
|
|
64
72
|
ramTempPaths,
|
|
65
73
|
} from './ram-temp.js';
|
|
66
74
|
import { createRunnerLifecycle, withFixtureLifecycle, withRunnerLifecycle } from './runner-lifecycle.js';
|
|
67
|
-
import { CPU_TOKENS_ENV, runnerDemand, sizeRunner } from './runner-sizing.js';
|
|
75
|
+
import { CPU_TOKENS_ENV, runnerDemand, sizeRunner, sizeRunnerToGrant } from './runner-sizing.js';
|
|
68
76
|
import { checkRuntimePin, describeRuntimePinRefusal } from './runtime-pin.js';
|
|
69
77
|
import type { BoundedExecOptions } from './schema.js';
|
|
70
78
|
import { createTestResultWriter, type TestResultWriter } from './test-result-writer.js';
|
|
@@ -529,7 +537,12 @@ export async function runBoundedExec(
|
|
|
529
537
|
// (`run-cpu-pool.ts`), so a task takes its tokens from a parent's pool; a command that inherits none runs exactly as
|
|
530
538
|
// asked and nothing is said.
|
|
531
539
|
const cores = availableParallelism();
|
|
532
|
-
|
|
540
|
+
// A prebuilt nextest leaf under mbx asks for its task's share of the host (`nxTaskCores`), not every core: it knows
|
|
541
|
+
// no count of its tests. A declared or named count still wins.
|
|
542
|
+
const mbx = mbxPool(process.env);
|
|
543
|
+
const leafCores =
|
|
544
|
+
mbx !== null && runsPrebuiltNextest(requested) ? nxTaskCores(cores, { ...process.env, ...options.env }) : cores;
|
|
545
|
+
const demand = runnerDemand(requested, options.parallelism, leafCores, process.env, options.env);
|
|
533
546
|
const asked = Date.now();
|
|
534
547
|
// A pool that answered and refused is a live budget, and running beside it would count the run twice: the run fails
|
|
535
548
|
// instead. A pool whose endpoint is gone (its holder exited) lends nothing, and the run goes on as asked.
|
|
@@ -550,17 +563,18 @@ export async function runBoundedExec(
|
|
|
550
563
|
const waitedMs = Date.now() - asked;
|
|
551
564
|
let cpu: BoundedExecRecord['cpu'];
|
|
552
565
|
let sized: { command: string; env: Record<string, string> } = { command: requested, env: {} };
|
|
553
|
-
// With mbx the leaf's admission is mbx's one pool, not a parent's tokens
|
|
554
|
-
//
|
|
555
|
-
// job"). No grant and no sub-pool beside it.
|
|
556
|
-
const
|
|
557
|
-
const leaf = mbx === null ? null : mbxLeaf(mbx, demand.kind, demand.want);
|
|
566
|
+
// With mbx the leaf's admission is mbx's one pool, not a parent's tokens. A leaf mbx does not admit itself asks for
|
|
567
|
+
// its runner's count, a maximum, and its runner runs on the cores it is granted, which only the command learns
|
|
568
|
+
// (specs/cowshed/05_gateway.md, "Parallelism inside a job"). No grant and no sub-pool beside it.
|
|
569
|
+
const leaf = mbx === null ? null : mbxLeaf(mbx, demand, requested);
|
|
558
570
|
if (grant !== null) {
|
|
559
571
|
sized = sizeRunner(demand, requested, grant.tokens);
|
|
560
572
|
cpu = { tokens: grant.tokens, want: demand.want, waitedMs };
|
|
561
573
|
appendStderr(
|
|
562
574
|
`cowshed: cpu-pool wait done elapsed=${waitedMs}ms status=ok tokens=${grant.tokens}/${demand.want} runner=${demand.kind}\n`,
|
|
563
575
|
);
|
|
576
|
+
} else if (leaf?.kind === 'reserve') {
|
|
577
|
+
sized = { command: sizeRunnerToGrant(leaf.demand, requested), env: {} };
|
|
564
578
|
} else if (leaf !== null) {
|
|
565
579
|
sized = sizeRunner(demand, requested, demand.want);
|
|
566
580
|
}
|
|
@@ -585,7 +599,14 @@ export async function runBoundedExec(
|
|
|
585
599
|
let mbxAdmitted = false;
|
|
586
600
|
let admissionWait = NO_ADMISSION_WAIT;
|
|
587
601
|
let lastQueueRequests: readonly MbxQueuedRequest[] = [];
|
|
588
|
-
|
|
602
|
+
/**
|
|
603
|
+
* Why the last admission snapshot failed, while the one after it has not succeeded; null otherwise. A snapshot only
|
|
604
|
+
* decides whether waiting on mbx admission is credited against the idle bound, so a failed one withholds that credit
|
|
605
|
+
* and ends nothing: the bounds decide, and an idle expiry names it.
|
|
606
|
+
*/
|
|
607
|
+
let unconfirmedAdmission: string | null = null;
|
|
608
|
+
/** When the last successful snapshot completed (`Date.now()`): credit runs to it and no further. */
|
|
609
|
+
let confirmedAdmissionAt: number | null = null;
|
|
589
610
|
const queueWait = (): AdmissionQueueWait | null =>
|
|
590
611
|
mbxAdmitted || lastQueueRequests.length === 0
|
|
591
612
|
? null
|
|
@@ -711,7 +732,7 @@ export async function runBoundedExec(
|
|
|
711
732
|
// With a supervisor, `cowshed subtree-root` asks it for a handle on itself, writes the answer to the handle
|
|
712
733
|
// descriptor, and execs `/bin/sh -c command` in the same process: the command's pid, group and life are unchanged.
|
|
713
734
|
const unadmitted = hooked?.command ?? (fixture === null ? command : `${fixture.command} && ${command}`);
|
|
714
|
-
const shellCommand =
|
|
735
|
+
const shellCommand = withMbxLeaf(unadmitted, leaf);
|
|
715
736
|
// Only leaves known to be scheduled can exclude zero-hold time. Others keep lifecycle hang protection.
|
|
716
737
|
const queued = mbxIdleGated(leaf, sized.command, { ...process.env, ...env });
|
|
717
738
|
// fd 4 is unused without a subtree admission, so the grant takes fd 5 either way.
|
|
@@ -851,7 +872,7 @@ export async function runBoundedExec(
|
|
|
851
872
|
let checkingIdle = false;
|
|
852
873
|
const armBoundTimer = (): void => {
|
|
853
874
|
clearTimeout(boundTimer);
|
|
854
|
-
if (state.settled || state.expiry !== null
|
|
875
|
+
if (state.settled || state.expiry !== null) return;
|
|
855
876
|
const next = earliestBound(checkingIdle ? { ...bounds, idle: null } : bounds);
|
|
856
877
|
if (next !== null) {
|
|
857
878
|
boundTimer = setTimeout(
|
|
@@ -863,7 +884,7 @@ export async function runBoundedExec(
|
|
|
863
884
|
}
|
|
864
885
|
};
|
|
865
886
|
const confirmExpiry = async (kind: BoundKind, at: number): Promise<void> => {
|
|
866
|
-
if (state.settled || state.expiry !== null
|
|
887
|
+
if (state.settled || state.expiry !== null) return;
|
|
867
888
|
const scheduled = earliestBound(checkingIdle ? { ...bounds, idle: null } : bounds);
|
|
868
889
|
if (scheduled?.kind !== kind || scheduled.at !== at) return;
|
|
869
890
|
if (kind === 'idle' && leaf !== null) {
|
|
@@ -878,13 +899,13 @@ export async function runBoundedExec(
|
|
|
878
899
|
checkingIdle = false;
|
|
879
900
|
}
|
|
880
901
|
}
|
|
881
|
-
if (state.settled || state.expiry !== null
|
|
902
|
+
if (state.settled || state.expiry !== null) return;
|
|
882
903
|
const next = earliestBound(bounds);
|
|
883
904
|
if (next !== null && next.at <= Date.now()) expire(expiredAs(next.kind));
|
|
884
905
|
else armBoundTimer();
|
|
885
906
|
};
|
|
886
907
|
const stepTo = (event: BoundEvent): void => {
|
|
887
|
-
if (state.settled || state.expiry !== null
|
|
908
|
+
if (state.settled || state.expiry !== null) return;
|
|
888
909
|
const idleBefore = bounds.idle;
|
|
889
910
|
bounds = stepBounds(
|
|
890
911
|
bounds,
|
|
@@ -906,16 +927,18 @@ export async function runBoundedExec(
|
|
|
906
927
|
let lastQueueDiagnostic = '';
|
|
907
928
|
let lastQueueDiagnosticAt: number | null = null;
|
|
908
929
|
let lastSnapshotDiagnostics = '';
|
|
909
|
-
const
|
|
910
|
-
if (state.settled || state.expiry !== null || queueAbort.signal.aborted
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
930
|
+
const unconfirmAdmission = (detail: string): void => {
|
|
931
|
+
if (state.settled || state.expiry !== null || queueAbort.signal.aborted) return;
|
|
932
|
+
if (unconfirmedAdmission !== detail) {
|
|
933
|
+
tell(
|
|
934
|
+
`bounded-exec: mbx admission snapshot failed: ${detail}; admission is unconfirmed, so this wait earns no idle credit until a snapshot succeeds\n`,
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
unconfirmedAdmission = detail;
|
|
938
|
+
lastQueueRequests = [];
|
|
939
|
+
admissionWait = stepAdmissionWait(admissionWait, { kind: 'snapshot', at: performance.now(), waiting: false });
|
|
940
|
+
// The wait since the last confirmed snapshot is unconfirmed: the idle bound resumes from that snapshot.
|
|
941
|
+
stepTo({ kind: 'admission-queue', at: confirmedAdmissionAt ?? Date.now(), waiting: false, testing: isTesting() });
|
|
919
942
|
};
|
|
920
943
|
const refreshQueue = async (fresh: boolean): Promise<void> => {
|
|
921
944
|
if (fresh && queueSnapshot !== null) await queueSnapshot;
|
|
@@ -930,7 +953,7 @@ export async function runBoundedExec(
|
|
|
930
953
|
);
|
|
931
954
|
if (state.settled || state.expiry !== null || queueAbort.signal.aborted) return;
|
|
932
955
|
if (!snapshot.ok) {
|
|
933
|
-
|
|
956
|
+
unconfirmAdmission(snapshot.detail);
|
|
934
957
|
return;
|
|
935
958
|
}
|
|
936
959
|
const diagnostics = snapshot.diagnostics?.join('; ') ?? '';
|
|
@@ -940,6 +963,8 @@ export async function runBoundedExec(
|
|
|
940
963
|
const observedAt = Date.now();
|
|
941
964
|
const observedWaitAt = performance.now();
|
|
942
965
|
admissionWait = stepAdmissionWait(admissionWait, { kind: 'snapshot', at: observedWaitAt, waiting });
|
|
966
|
+
unconfirmedAdmission = null;
|
|
967
|
+
confirmedAdmissionAt = observedAt;
|
|
943
968
|
if (waiting) {
|
|
944
969
|
lastQueueRequests = snapshot.requests;
|
|
945
970
|
const positions = JSON.stringify(snapshot.requests);
|
|
@@ -959,7 +984,7 @@ export async function runBoundedExec(
|
|
|
959
984
|
stepTo({ kind: 'admission-queue', at: observedAt, waiting, testing: isTesting() });
|
|
960
985
|
})()
|
|
961
986
|
.catch((error: unknown) => {
|
|
962
|
-
|
|
987
|
+
unconfirmAdmission(error instanceof Error ? error.message : String(error));
|
|
963
988
|
})
|
|
964
989
|
.finally(() => {
|
|
965
990
|
queueSnapshot = null;
|
|
@@ -1056,7 +1081,7 @@ export async function runBoundedExec(
|
|
|
1056
1081
|
cancelCapture();
|
|
1057
1082
|
clearTimeout(boundTimer);
|
|
1058
1083
|
// Preserve explicit live membership before cancellation removes the queued process. A failed bounded observation
|
|
1059
|
-
//
|
|
1084
|
+
// leaves the admission unconfirmed, never a manufactured queue or admission.
|
|
1060
1085
|
signalCleanup = (leaf === null ? Promise.resolve() : refreshQueue(false))
|
|
1061
1086
|
.finally(() => {
|
|
1062
1087
|
stopQueueObservation();
|
|
@@ -1069,10 +1094,7 @@ export async function runBoundedExec(
|
|
|
1069
1094
|
signalToExitCode(signal),
|
|
1070
1095
|
state.expiry,
|
|
1071
1096
|
Date.now() - startedAt,
|
|
1072
|
-
state.poolCloseError !== null ||
|
|
1073
|
-
lifecycleFailure !== null ||
|
|
1074
|
-
state.retireError !== null ||
|
|
1075
|
-
queueFailure !== null,
|
|
1097
|
+
state.poolCloseError !== null || lifecycleFailure !== null || state.retireError !== null,
|
|
1076
1098
|
state.noSpace === null ? null : await state.noSpace,
|
|
1077
1099
|
state.lockWaits,
|
|
1078
1100
|
),
|
|
@@ -1130,7 +1152,11 @@ export async function runBoundedExec(
|
|
|
1130
1152
|
bound.tests.length > 0
|
|
1131
1153
|
? `still running: ${bound.tests.join(', ')}`
|
|
1132
1154
|
: 'the runner named no test still running'
|
|
1133
|
-
} (cwd=${cwd}): ${command}\n
|
|
1155
|
+
} (cwd=${cwd}): ${command}\n${
|
|
1156
|
+
unconfirmedAdmission === null
|
|
1157
|
+
? ''
|
|
1158
|
+
: `The last mbx admission snapshot failed (${unconfirmedAdmission}), so the wait it could not confirm earned no idle credit\n`
|
|
1159
|
+
}`
|
|
1134
1160
|
: bound.kind === 'fixture'
|
|
1135
1161
|
? `\nFixture command timed out after ${elapsedMs}ms (fixtureTimeoutMs=${bound.limitMs}, cwd=${cwd}): ${fixture?.command ?? command}\n`
|
|
1136
1162
|
: `\nCommand timed out after ${elapsedMs}ms (timeoutMs=${bound.limitMs}, cwd=${cwd}): ${command}\n`,
|
|
@@ -1252,7 +1278,7 @@ export async function runBoundedExec(
|
|
|
1252
1278
|
said = true;
|
|
1253
1279
|
tell(
|
|
1254
1280
|
leaf.kind === 'reserve'
|
|
1255
|
-
? `cowshed: mbx reserve granted elapsed=${Date.now() - startedAt}ms
|
|
1281
|
+
? `cowshed: mbx reserve granted elapsed=${Date.now() - startedAt}ms asked=${leaf.demand.want} priority=${leaf.priority}\n`
|
|
1256
1282
|
: `cowshed: mbx cargo granted elapsed=${Date.now() - startedAt}ms\n`,
|
|
1257
1283
|
);
|
|
1258
1284
|
}
|
|
@@ -1331,18 +1357,11 @@ export async function runBoundedExec(
|
|
|
1331
1357
|
appendStderr(`${describeRamTempError(full)}\n`);
|
|
1332
1358
|
}
|
|
1333
1359
|
}
|
|
1334
|
-
await releaseLease(
|
|
1335
|
-
code !== 0 ||
|
|
1336
|
-
state.expiry !== null ||
|
|
1337
|
-
state.poolCloseError !== null ||
|
|
1338
|
-
lifecycleFailure !== null ||
|
|
1339
|
-
queueFailure !== null,
|
|
1340
|
-
);
|
|
1360
|
+
await releaseLease(code !== 0 || state.expiry !== null || state.poolCloseError !== null || lifecycleFailure !== null);
|
|
1341
1361
|
|
|
1342
1362
|
// Broken resource ownership, a lost native lifecycle, or leftovers that could not be retired fail even if a shell
|
|
1343
1363
|
// branch later exited 0: its verdict is an ordinary operational failure, never a successful or silently unbounded run.
|
|
1344
|
-
const operationalFailure =
|
|
1345
|
-
state.poolCloseError !== null || lifecycleFailure !== null || state.retireError !== null || queueFailure !== null;
|
|
1364
|
+
const operationalFailure = state.poolCloseError !== null || lifecycleFailure !== null || state.retireError !== null;
|
|
1346
1365
|
await recordRun(code, state.expiry, Date.now() - startedAt, operationalFailure, seen, state.lockWaits);
|
|
1347
1366
|
return {
|
|
1348
1367
|
success: !operationalFailure && resultFailure === null && state.expiry === null && code === 0,
|