@smoothbricks/nx-plugin 0.6.3-0 → 0.7.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 +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 +57 -7
- 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
|
@@ -281,12 +281,13 @@ function referencedStoreEntries(
|
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
283
|
* The store links the installed tree reaches whose target in Bun's install cache is gone. Under
|
|
284
|
-
* `globalStore`
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
284
|
+
* `globalStore` a node_modules/.bun/<entry> is a link into that cache or a directory of its own (Bun keeps
|
|
285
|
+
* some packages in the project, most of them peer variants `<name>@<version>+<hash>`), and only a link can
|
|
286
|
+
* dangle: one that does names a cache entry that no longer exists, the install is out of date, as it is
|
|
287
|
+
* while a developer link dangles, and `bun install` links the entry again (measured, Bun 1.4.3 and 1.4.4).
|
|
288
|
+
* A dangling variant nothing live reaches is superseded garbage the install leaves in place (see
|
|
289
|
+
* verifyInstalledBunLinks), so it never makes the install stale: no install would change it. The closure
|
|
290
|
+
* is walked only when some store link dangles, so `members` is asked for only then.
|
|
290
291
|
*/
|
|
291
292
|
export function danglingStoreLinks(root: string, members: () => readonly string[]): string[] {
|
|
292
293
|
const store = path.join(root, 'node_modules', '.bun');
|
|
@@ -1020,9 +1020,11 @@ function bunInstaller(inputs: readonly string[]): Installer {
|
|
|
1020
1020
|
* decides, because an outer shell's UV_PROJECT_ENVIRONMENT leaks into a
|
|
1021
1021
|
* checkout that syncs nothing.
|
|
1022
1022
|
*
|
|
1023
|
-
* Every package of the workspace
|
|
1024
|
-
* which is what `bun install` does for the JavaScript
|
|
1025
|
-
* shell carries the whole workspace.
|
|
1023
|
+
* Every package of the workspace, every dependency group and every optional
|
|
1024
|
+
* extra is installed, which is what `bun install` does for the JavaScript
|
|
1025
|
+
* half: a development shell carries the whole workspace. Readers run under
|
|
1026
|
+
* UV_NO_SYNC, so a target's `uv run --extra <name>` finds the extra only
|
|
1027
|
+
* because this sync installed it. CI adds `--locked`, the counterpart of
|
|
1026
1028
|
* `--frozen-lockfile`.
|
|
1027
1029
|
*
|
|
1028
1030
|
* Like node_modules, the environment is location-independent, so a copy of
|
|
@@ -1060,7 +1062,15 @@ function uvInstaller(inputs: readonly string[], options: { locked: boolean }): I
|
|
|
1060
1062
|
);
|
|
1061
1063
|
}
|
|
1062
1064
|
const stampPath = path.join(environment, '.smoo-sync');
|
|
1063
|
-
const argv = [
|
|
1065
|
+
const argv = [
|
|
1066
|
+
'sync',
|
|
1067
|
+
'--python',
|
|
1068
|
+
python,
|
|
1069
|
+
'--all-packages',
|
|
1070
|
+
'--all-groups',
|
|
1071
|
+
'--all-extras',
|
|
1072
|
+
...(options.locked ? ['--locked'] : []),
|
|
1073
|
+
];
|
|
1064
1074
|
const create = ['venv', '--relocatable', '--python', python, environment];
|
|
1065
1075
|
const uv = Bun.which('uv');
|
|
1066
1076
|
const identity = [
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every git revision Cargo.lock pins, judged against the remote it names, which is where CI fetches it.
|
|
3
|
+
*
|
|
4
|
+
* A workspace pins an external crate by git revision and builds it from the local Cargo git database, so a pin lands
|
|
5
|
+
* with no publish and no waiting. CI meets the pin only once the tree is pushed: its runner has nothing but the remote,
|
|
6
|
+
* and cargo (`net.git-fetch-with-cli`) asks the remote for the revision. When the remote does not serve it, every build
|
|
7
|
+
* that reaches the crate fails ("upload-pack: not our ref"). So a land gate reports such a pin (`--report`, exit 0):
|
|
8
|
+
* reported, never waited on. No push or land holds for a remote; the pinned repository's own push serves the revision.
|
|
9
|
+
*
|
|
10
|
+
* "Served" is what cargo does: fetch the revision by id, and when the remote refuses that, fetch its branches and tags
|
|
11
|
+
* and look for the revision among them. A remote the fetch cannot reach, or that does not answer within the report's
|
|
12
|
+
* budget, proves nothing either way and is said as that. One remote's asks run one after another in its scratch
|
|
13
|
+
* repository, since concurrent fetches there contend for git's own locks. Like the other managed git-hook helpers it
|
|
14
|
+
* imports only the runtime.
|
|
15
|
+
*/
|
|
16
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
17
|
+
import { tmpdir } from 'node:os';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
|
|
20
|
+
/** One pinned revision of one remote, with the packages Cargo.lock builds from it. */
|
|
21
|
+
export interface Pin {
|
|
22
|
+
readonly url: string;
|
|
23
|
+
readonly rev: string;
|
|
24
|
+
readonly packages: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type PinsRead =
|
|
28
|
+
| { readonly kind: 'pins'; readonly pins: readonly Pin[] }
|
|
29
|
+
| { readonly kind: 'malformed'; readonly detail: string };
|
|
30
|
+
|
|
31
|
+
export type PinAnswer =
|
|
32
|
+
| { readonly kind: 'served' }
|
|
33
|
+
| { readonly kind: 'unserved' }
|
|
34
|
+
| { readonly kind: 'unreachable'; readonly detail: string };
|
|
35
|
+
|
|
36
|
+
/** Asks one remote for one revision, answering `unreachable` once `budgetMs` has passed. */
|
|
37
|
+
export type AskRemote = (url: string, rev: string, budgetMs: number) => Promise<PinAnswer>;
|
|
38
|
+
|
|
39
|
+
/** How long a land gate's report waits for the remotes' answers, all of them together. */
|
|
40
|
+
export const REPORT_BUDGET_MS = 60_000;
|
|
41
|
+
|
|
42
|
+
const REVISION = /^[0-9a-f]{40}$/;
|
|
43
|
+
|
|
44
|
+
function malformed(detail: string): PinsRead {
|
|
45
|
+
return { kind: 'malformed', detail };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** `Array.isArray` narrows `unknown` to `any[]`; this keeps the elements `unknown`. */
|
|
49
|
+
function isArray(value: unknown): value is readonly unknown[] {
|
|
50
|
+
return Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The git sources of a Cargo.lock, `source = "git+<url>[?<reference>]#<revision>"`, one pin per remote and revision. */
|
|
54
|
+
export function readPins(lockText: string): PinsRead {
|
|
55
|
+
let parsed: unknown;
|
|
56
|
+
try {
|
|
57
|
+
parsed = Bun.TOML.parse(lockText);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return malformed(`Cargo.lock is not TOML: ${error instanceof Error ? error.message : String(error)}`);
|
|
60
|
+
}
|
|
61
|
+
if (typeof parsed !== 'object' || parsed === null) return malformed('Cargo.lock is not a table');
|
|
62
|
+
if (!('package' in parsed)) return { kind: 'pins', pins: [] };
|
|
63
|
+
const entries = parsed.package;
|
|
64
|
+
if (!isArray(entries)) return malformed('Cargo.lock `package` is not an array of tables');
|
|
65
|
+
const pins = new Map<string, { readonly url: string; readonly rev: string; readonly packages: string[] }>();
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (typeof entry !== 'object' || entry === null || !('name' in entry) || typeof entry.name !== 'string')
|
|
68
|
+
return malformed(`a Cargo.lock package has no name: ${JSON.stringify(entry)}`);
|
|
69
|
+
if (!('source' in entry)) continue;
|
|
70
|
+
const source = entry.source;
|
|
71
|
+
if (typeof source !== 'string') return malformed(`${entry.name}'s source is not a string`);
|
|
72
|
+
if (!source.startsWith('git+')) continue;
|
|
73
|
+
const hash = source.lastIndexOf('#');
|
|
74
|
+
const rev = hash === -1 ? '' : source.slice(hash + 1);
|
|
75
|
+
if (!REVISION.test(rev)) return malformed(`${entry.name}'s git source names no full revision: ${source}`);
|
|
76
|
+
const located = source.slice('git+'.length, hash);
|
|
77
|
+
const query = located.indexOf('?');
|
|
78
|
+
const url = query === -1 ? located : located.slice(0, query);
|
|
79
|
+
const key = `${url}#${rev}`;
|
|
80
|
+
const pin = pins.get(key) ?? { url, rev, packages: [] };
|
|
81
|
+
pin.packages.push(entry.name);
|
|
82
|
+
pins.set(key, pin);
|
|
83
|
+
}
|
|
84
|
+
return { kind: 'pins', pins: [...pins.values()] };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function describePin(pin: Pin, answer: PinAnswer): string {
|
|
88
|
+
const built = `Cargo.lock builds ${pin.packages.join(', ')} from it`;
|
|
89
|
+
switch (answer.kind) {
|
|
90
|
+
case 'served':
|
|
91
|
+
return `${pin.url} serves ${pin.rev} (${built})`;
|
|
92
|
+
case 'unserved':
|
|
93
|
+
return `${pin.url} does not serve ${pin.rev} (${built})`;
|
|
94
|
+
case 'unreachable':
|
|
95
|
+
return `could not ask ${pin.url} for ${pin.rev} (${built}): ${answer.detail}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function formatSeconds(ms: number): string {
|
|
100
|
+
return `${Math.round(ms / 1000)} s`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface GitRun {
|
|
104
|
+
readonly exitCode: number;
|
|
105
|
+
readonly stdout: string;
|
|
106
|
+
readonly stderr: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The git children alive now, which a signal that ends this process ends too. */
|
|
110
|
+
const CHILDREN = new Set<{ kill(): void }>();
|
|
111
|
+
|
|
112
|
+
async function git(args: readonly string[], cwd: string, signal?: AbortSignal): Promise<GitRun> {
|
|
113
|
+
const child = Bun.spawn(['git', ...args], {
|
|
114
|
+
cwd,
|
|
115
|
+
stdin: 'ignore',
|
|
116
|
+
stdout: 'pipe',
|
|
117
|
+
stderr: 'pipe',
|
|
118
|
+
// A hook and a gate run unattended: a remote that wants credentials it has no helper for refuses instead of asking.
|
|
119
|
+
// A partial repository never goes back to its remote for an object it lacks: absence is the answer.
|
|
120
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0', GIT_NO_LAZY_FETCH: '1' },
|
|
121
|
+
...(signal === undefined ? {} : { signal }),
|
|
122
|
+
});
|
|
123
|
+
CHILDREN.add(child);
|
|
124
|
+
try {
|
|
125
|
+
const [stdout, stderr, exitCode] = await Promise.all([
|
|
126
|
+
new Response(child.stdout).text(),
|
|
127
|
+
new Response(child.stderr).text(),
|
|
128
|
+
child.exited,
|
|
129
|
+
]);
|
|
130
|
+
return { exitCode, stdout, stderr: stderr.trim() };
|
|
131
|
+
} finally {
|
|
132
|
+
CHILDREN.delete(child);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function gitOrThrow(args: readonly string[], cwd: string): Promise<void> {
|
|
137
|
+
const run = await git(args, cwd);
|
|
138
|
+
if (run.exitCode !== 0) throw new Error(`git ${args.join(' ')} exited ${run.exitCode} in ${cwd}: ${run.stderr}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Asks each remote through a scratch repository of its own under `scratchRoot`, kept for the asker's life so that a
|
|
143
|
+
* repeated ask fetches only what changed. Commits are all it fetches (`--filter=tree:0`). One remote's asks run one
|
|
144
|
+
* after another, each against the deadline it was given when it was asked, so a queued ask cannot outlive it either.
|
|
145
|
+
*/
|
|
146
|
+
export function remoteAsker(scratchRoot: string): AskRemote {
|
|
147
|
+
const repositories = new Map<string, Promise<string>>();
|
|
148
|
+
const queues = new Map<string, Promise<unknown>>();
|
|
149
|
+
const repository = (url: string): Promise<string> => {
|
|
150
|
+
const known = repositories.get(url);
|
|
151
|
+
if (known !== undefined) return known;
|
|
152
|
+
const directory = join(scratchRoot, String(repositories.size));
|
|
153
|
+
const created = (async () => {
|
|
154
|
+
await gitOrThrow(['init', '--quiet', '--bare', directory], scratchRoot);
|
|
155
|
+
await gitOrThrow(['remote', 'add', 'pin', url], directory);
|
|
156
|
+
return directory;
|
|
157
|
+
})();
|
|
158
|
+
repositories.set(url, created);
|
|
159
|
+
return created;
|
|
160
|
+
};
|
|
161
|
+
const fetch = ['fetch', '--quiet', '--no-tags', '--no-write-fetch-head', '--filter=tree:0'];
|
|
162
|
+
const askNow = async (url: string, rev: string, budgetMs: number, signal: AbortSignal): Promise<PinAnswer> => {
|
|
163
|
+
const silent: PinAnswer = { kind: 'unreachable', detail: `no answer within ${formatSeconds(budgetMs)}` };
|
|
164
|
+
if (signal.aborted) return silent;
|
|
165
|
+
const directory = await repository(url);
|
|
166
|
+
const direct = await git([...fetch, '--depth=1', 'pin', rev], directory, signal);
|
|
167
|
+
if (direct.exitCode === 0) return { kind: 'served' };
|
|
168
|
+
if (signal.aborted) return silent;
|
|
169
|
+
const listed = await git(
|
|
170
|
+
[...fetch, 'pin', '+refs/heads/*:refs/pinned/heads/*', '+refs/tags/*:refs/pinned/tags/*'],
|
|
171
|
+
directory,
|
|
172
|
+
signal,
|
|
173
|
+
);
|
|
174
|
+
if (signal.aborted) return silent;
|
|
175
|
+
if (listed.exitCode !== 0)
|
|
176
|
+
return { kind: 'unreachable', detail: listed.stderr || direct.stderr || `git fetch exited ${listed.exitCode}` };
|
|
177
|
+
const found = await git(['cat-file', '-e', `${rev}^{commit}`], directory);
|
|
178
|
+
return found.exitCode === 0 ? { kind: 'served' } : { kind: 'unserved' };
|
|
179
|
+
};
|
|
180
|
+
return (url, rev, budgetMs) => {
|
|
181
|
+
const signal = AbortSignal.timeout(Math.max(0, budgetMs));
|
|
182
|
+
const asked = (queues.get(url) ?? Promise.resolve()).then(() => askNow(url, rev, budgetMs, signal));
|
|
183
|
+
queues.set(
|
|
184
|
+
url,
|
|
185
|
+
asked.catch(() => undefined),
|
|
186
|
+
);
|
|
187
|
+
return asked;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function pinsOf(text: string, where: string): readonly Pin[] {
|
|
192
|
+
const read = readPins(text);
|
|
193
|
+
if (read.kind === 'malformed') throw new Error(`${where}: ${read.detail}`);
|
|
194
|
+
return read.pins;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const USAGE = 'usage: pinned-revisions-served.ts --report';
|
|
198
|
+
|
|
199
|
+
async function report(root: string, ask: AskRemote): Promise<number> {
|
|
200
|
+
const file = Bun.file(join(root, 'Cargo.lock'));
|
|
201
|
+
if (!(await file.exists())) return 0;
|
|
202
|
+
const pins = pinsOf(await file.text(), join(root, 'Cargo.lock'));
|
|
203
|
+
const answers = await Promise.all(
|
|
204
|
+
pins.map(async (pin) => [pin, await ask(pin.url, pin.rev, REPORT_BUDGET_MS)] as const),
|
|
205
|
+
);
|
|
206
|
+
const unserved = answers.filter(([, answer]) => answer.kind === 'unserved');
|
|
207
|
+
const unanswered = answers.filter(([, answer]) => answer.kind === 'unreachable');
|
|
208
|
+
if (unserved.length === 0 && unanswered.length === 0) {
|
|
209
|
+
const remotes = new Set(pins.map((pin) => pin.url)).size;
|
|
210
|
+
console.log(
|
|
211
|
+
`PINNED-REVISIONS: every git revision Cargo.lock pins is served (${pins.length} pin(s), ${remotes} remote(s))`,
|
|
212
|
+
);
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
const counted = [
|
|
216
|
+
...(unserved.length === 0 ? [] : [`${unserved.length} pinned revision(s) their remote does not serve`]),
|
|
217
|
+
...(unanswered.length === 0 ? [] : [`${unanswered.length} whose remote did not answer`]),
|
|
218
|
+
].join(' and ');
|
|
219
|
+
console.log(
|
|
220
|
+
`PINNED-REVISIONS note: ${counted}, reported, never waited on: the land builds them from the local Cargo git database, and CI fetches them from their remote, so push each one there (the pinned repository's own land normally does):\n` +
|
|
221
|
+
[...unserved, ...unanswered].map(([pin, answer]) => ` ${describePin(pin, answer)}`).join('\n'),
|
|
222
|
+
);
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (import.meta.main) {
|
|
227
|
+
const [mode, ...rest] = process.argv.slice(2);
|
|
228
|
+
const root = process.cwd();
|
|
229
|
+
const scratch = mkdtempSync(join(tmpdir(), 'pinned-revisions-'));
|
|
230
|
+
const removeScratch = () => rmSync(scratch, { recursive: true, force: true });
|
|
231
|
+
// A signal skips `finally`: end the fetches and remove what they fetched, then exit as the signal would have.
|
|
232
|
+
for (const [name, number] of [
|
|
233
|
+
['SIGINT', 2],
|
|
234
|
+
['SIGTERM', 15],
|
|
235
|
+
['SIGHUP', 1],
|
|
236
|
+
] as const)
|
|
237
|
+
process.on(name, () => {
|
|
238
|
+
for (const child of CHILDREN) child.kill();
|
|
239
|
+
removeScratch();
|
|
240
|
+
process.exit(128 + number);
|
|
241
|
+
});
|
|
242
|
+
try {
|
|
243
|
+
const ask = remoteAsker(scratch);
|
|
244
|
+
if (mode === '--report' && rest.length === 0) process.exitCode = await report(root, ask);
|
|
245
|
+
else {
|
|
246
|
+
console.error(USAGE);
|
|
247
|
+
process.exitCode = 2;
|
|
248
|
+
}
|
|
249
|
+
} finally {
|
|
250
|
+
removeScratch();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
@@ -42,11 +42,12 @@
|
|
|
42
42
|
#
|
|
43
43
|
# The denylist gate needs only tooling/direnv/repo-path's PATH; the cross gate
|
|
44
44
|
# needs direnv on the caller's PATH, and the checkout's own devenv through it,
|
|
45
|
-
# not a devenv the caller entered. It must never pretend a check ran that did
|
|
45
|
+
# not a devenv the caller entered. It must never pretend a check ran that did
|
|
46
|
+
# not.
|
|
46
47
|
|
|
47
48
|
cd "$(git rev-parse --show-toplevel)"
|
|
48
49
|
TOOLING="$PWD/tooling"
|
|
49
|
-
# A push to the `backup` remote is a private mirror, not publication:
|
|
50
|
+
# A push to the `backup` remote is a private mirror, not publication: the
|
|
50
51
|
# gates below guard publication only, so they do not apply.
|
|
51
52
|
if [ "${1:-}" = backup ]; then exit 0; fi
|
|
52
53
|
|
|
@@ -76,34 +77,30 @@ if [ "${#pushed[@]}" -gt 0 ]; then
|
|
|
76
77
|
}
|
|
77
78
|
fi
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"this checkout's environment, and a check run in any other environment keys on" \
|
|
91
|
-
'values the land gate never used. Put direnv on PATH, then push again.' >&2
|
|
92
|
-
exit 1
|
|
93
|
-
fi
|
|
80
|
+
cross_gate() {
|
|
81
|
+
# The refusal uses shell builtins alone: without direnv nothing proves the
|
|
82
|
+
# caller's PATH carries coreutils, and a Nix-built host's /usr/bin and /bin
|
|
83
|
+
# hold none of them.
|
|
84
|
+
if ! command -v direnv >/dev/null; then
|
|
85
|
+
printf '%s\n' \
|
|
86
|
+
'pre-push: direnv is not on PATH, so the Linux cross-compile check cannot run in' \
|
|
87
|
+
"this checkout's environment, and a check run in any other environment keys on" \
|
|
88
|
+
'values the land gate never used. Put direnv on PATH, then push again.' >&2
|
|
89
|
+
return 1
|
|
90
|
+
fi
|
|
94
91
|
|
|
95
|
-
# The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL)
|
|
96
|
-
# is the one line that means the key missed. Nx exits 1 for every task failure,
|
|
97
|
-
# so the hook reads the output for it rather than guessing from the status.
|
|
98
|
-
output=$(mktemp "${TMPDIR:-/tmp}/pre-push-cross.XXXXXX") ||
|
|
99
|
-
trap 'rm -f "$output"' EXIT
|
|
100
|
-
set -o pipefail
|
|
101
|
-
direnv exec "$PWD" nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
|
|
102
|
-
status=$?
|
|
103
|
-
[ "$status" -eq 0 ] &&
|
|
92
|
+
# The guard's refusal (nx-plugin cross-check-policy.ts CARGO_CROSS_LINT_REFUSAL)
|
|
93
|
+
# is the one line that means the key missed. Nx exits 1 for every task failure,
|
|
94
|
+
# so the hook reads the output for it rather than guessing from the status.
|
|
95
|
+
output=$(mktemp "${TMPDIR:-/tmp}/pre-push-cross.XXXXXX") || return 1
|
|
96
|
+
trap 'rm -f "$output"' EXIT
|
|
97
|
+
set -o pipefail
|
|
98
|
+
direnv exec "$PWD" nx run-many -t cargo-lint-cross --output-style=static 2>&1 | tee "$output"
|
|
99
|
+
status=$?
|
|
100
|
+
[ "$status" -eq 0 ] && return 0
|
|
104
101
|
|
|
105
|
-
if grep -qF 'cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux' "$output"; then
|
|
106
|
-
|
|
102
|
+
if grep -qF 'cargo-lint-cross needs cargo-zigbuild from the linux-cross toolchain; run: bun run check:linux' "$output"; then
|
|
103
|
+
cat >&2 <<'EOF'
|
|
107
104
|
|
|
108
105
|
pre-push: the Linux cross-compile check is NOT cached for this tree, so this
|
|
109
106
|
push would ship code that has never been compiled for Linux. The "needs
|
|
@@ -113,13 +110,18 @@ broken toolchain.
|
|
|
113
110
|
Run: bun run check:linux
|
|
114
111
|
Wait for it to pass, then push again.
|
|
115
112
|
EOF
|
|
116
|
-
else
|
|
117
|
-
|
|
113
|
+
else
|
|
114
|
+
cat >&2 <<EOF
|
|
118
115
|
|
|
119
116
|
pre-push: the Linux cross-compile check failed (exit $status) before it reached
|
|
120
117
|
a cache verdict, in Nx or in direnv entering this checkout's environment; the
|
|
121
118
|
output above names why. This is not a cache miss, and bun run check:linux will
|
|
122
119
|
not fix it.
|
|
123
120
|
EOF
|
|
124
|
-
fi
|
|
125
|
-
|
|
121
|
+
fi
|
|
122
|
+
return 1
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case "$(uname -s)" in
|
|
126
|
+
Darwin) cross_gate || exit 1 ;;
|
|
127
|
+
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -228,7 +228,9 @@
|
|
|
228
228
|
"smoo-nx-test-walks": "./dist/bin/smoo-nx-test-walks.js",
|
|
229
229
|
"smoo-nx-test-clocks": "./dist/bin/smoo-nx-test-clocks.js",
|
|
230
230
|
"smoo-nx-publish": "./dist/bin/smoo-nx-publish.js",
|
|
231
|
-
"smoo-nx-forbidden-spellings": "./dist/bin/smoo-nx-forbidden-spellings.js"
|
|
231
|
+
"smoo-nx-forbidden-spellings": "./dist/bin/smoo-nx-forbidden-spellings.js",
|
|
232
|
+
"smoo-nx-go-test-build": "./dist/bin/smoo-nx-go-test-build.js",
|
|
233
|
+
"smoo-nx-go-test-run": "./dist/bin/smoo-nx-go-test-run.js"
|
|
232
234
|
},
|
|
233
235
|
"generators": "./generators.json",
|
|
234
236
|
"executors": "./executors.json",
|
|
@@ -246,18 +248,30 @@
|
|
|
246
248
|
"copy-nx-publish-assets": {
|
|
247
249
|
"executor": "nx:run-commands",
|
|
248
250
|
"cache": true,
|
|
251
|
+
"dependsOn": [
|
|
252
|
+
{
|
|
253
|
+
"projects": [
|
|
254
|
+
"build-inputs"
|
|
255
|
+
],
|
|
256
|
+
"target": "build"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
249
259
|
"inputs": [
|
|
250
260
|
"{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js",
|
|
251
261
|
"{workspaceRoot}/packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js",
|
|
252
262
|
{
|
|
253
263
|
"externalDependencies": []
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"dependentTasksOutputFiles": "**/*.js",
|
|
267
|
+
"transitive": false
|
|
254
268
|
}
|
|
255
269
|
],
|
|
256
270
|
"outputs": [
|
|
257
271
|
"{projectRoot}/runtime/nx-publish/"
|
|
258
272
|
],
|
|
259
273
|
"options": {
|
|
260
|
-
"command": "asset_source=../cowshed/crates/cowshed-core/src/build_volume; if [ -e runtime/nx-publish ]; then rm -r runtime/nx-publish; fi && mkdir -p runtime/nx-publish && cp \"$asset_source/cache_adapter.js\" \"$asset_source/nx_publish.js\" runtime/nx-publish/",
|
|
274
|
+
"command": "asset_source=../cowshed/crates/cowshed-core/src/build_volume; if [ -e runtime/nx-publish ]; then rm -r runtime/nx-publish; fi && mkdir -p runtime/nx-publish && cp \"$asset_source/cache_adapter.js\" \"$asset_source/nx_publish.js\" runtime/nx-publish/ && node ../build-inputs/dist/ts/bin/smoo-nx-build-inputs.js --input \"$asset_source/cache_adapter.js\" --input \"$asset_source/nx_publish.js\" --output runtime/nx-publish",
|
|
261
275
|
"cwd": "{projectRoot}"
|
|
262
276
|
}
|
|
263
277
|
},
|
|
@@ -298,6 +312,41 @@
|
|
|
298
312
|
"killAfterMs": 10000
|
|
299
313
|
}
|
|
300
314
|
},
|
|
315
|
+
"test-go-bins": {
|
|
316
|
+
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
317
|
+
"cache": true,
|
|
318
|
+
"inputs": [
|
|
319
|
+
"...",
|
|
320
|
+
"default",
|
|
321
|
+
"^dependencyDefault",
|
|
322
|
+
"bunToolchain",
|
|
323
|
+
{
|
|
324
|
+
"runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh node --version"
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"runtime": "sh node_modules/@smoothbricks/nx-plugin/runtime-input.sh go version"
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"dependentTasksOutputFiles": "**/dist/bin/smoo-nx-go-test-*.js",
|
|
331
|
+
"transitive": true
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"dependentTasksOutputFiles": "**/dist/go-tests.js",
|
|
335
|
+
"transitive": true
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"dependsOn": [
|
|
339
|
+
"...",
|
|
340
|
+
"tsc-js",
|
|
341
|
+
"typecheck-tests"
|
|
342
|
+
],
|
|
343
|
+
"options": {
|
|
344
|
+
"command": "bun test --timeout=0 ./src/__tests__/go-test-bins.cases.ts",
|
|
345
|
+
"cwd": "{projectRoot}",
|
|
346
|
+
"idleTimeoutMs": 180000,
|
|
347
|
+
"killAfterMs": 10000
|
|
348
|
+
}
|
|
349
|
+
},
|
|
301
350
|
"lint": {},
|
|
302
351
|
"test": {
|
|
303
352
|
"executor": "nx:noop",
|
|
@@ -309,6 +358,7 @@
|
|
|
309
358
|
"test-host",
|
|
310
359
|
"test-pool-silence",
|
|
311
360
|
"test-nx-publish",
|
|
361
|
+
"test-go-bins",
|
|
312
362
|
"test-results-runtime"
|
|
313
363
|
]
|
|
314
364
|
},
|
|
@@ -599,10 +649,10 @@
|
|
|
599
649
|
},
|
|
600
650
|
"dependencies": {
|
|
601
651
|
"@nx/js": "23.2.1",
|
|
602
|
-
"@smoothbricks/build-inputs": "0.0.
|
|
652
|
+
"@smoothbricks/build-inputs": "0.0.2",
|
|
603
653
|
"@smoothbricks/cargo-retain": "0.0.1",
|
|
604
|
-
"@smoothbricks/cowshed": "0.4.
|
|
605
|
-
"@smoothbricks/nextest-extract": "0.0.
|
|
654
|
+
"@smoothbricks/cowshed": "0.4.3",
|
|
655
|
+
"@smoothbricks/nextest-extract": "0.0.2",
|
|
606
656
|
"jsonc-parser": "^3.3.1",
|
|
607
657
|
"minimatch": "10.2.5",
|
|
608
658
|
"nx": "latest",
|
|
@@ -614,7 +664,7 @@
|
|
|
614
664
|
"yaml": "^2.9.0"
|
|
615
665
|
},
|
|
616
666
|
"devDependencies": {
|
|
617
|
-
"@smoothbricks/lmao": "0.
|
|
667
|
+
"@smoothbricks/lmao": "0.6.0",
|
|
618
668
|
"@smoothbricks/validation": "0.1.13",
|
|
619
669
|
"fast-check": "^4.4.0"
|
|
620
670
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"files": {
|
|
4
|
+
"packages/cowshed/crates/cowshed-core/src/build_volume/cache_adapter.js": "3355da0dc7972b2fe981ca2217a1f373e60004dedeaa62c31131315bba2f4f18",
|
|
5
|
+
"packages/cowshed/crates/cowshed-core/src/build_volume/nx_publish.js": "83ccff840b9d3e53cdcc629ffc2af6e64c956a0fcbaaa6c5ce0e59fe0dce436b"
|
|
6
|
+
},
|
|
7
|
+
"producer": {
|
|
8
|
+
"project": "nx-plugin",
|
|
9
|
+
"target": "copy-nx-publish-assets"
|
|
10
|
+
}
|
|
11
|
+
}
|
package/runtime-input.sh
CHANGED
|
@@ -27,43 +27,70 @@
|
|
|
27
27
|
# are visible.
|
|
28
28
|
#
|
|
29
29
|
# A failed command's own stdout never reaches the hasher either: it is
|
|
30
|
-
# captured
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
30
|
+
# captured from the start, retained in the failure record, and the only byte
|
|
31
|
+
# this script emits on failure is the 0xFF poison above. Nothing from a
|
|
32
|
+
# failure path flows into the hash as input bytes. Successful stdout is
|
|
33
|
+
# replayed from the capture.
|
|
34
34
|
#
|
|
35
35
|
# The command's stderr is not part of the value; it surfaces only on failure.
|
|
36
36
|
# Diagnostics name temp paths, process ids and the boundary the input ran in
|
|
37
37
|
# (an Nx daemon inside a sandbox runs inputs with the sandbox's view of the
|
|
38
38
|
# client's environment), none of which is the input.
|
|
39
|
+
# A successful input costs the command alone: both of its streams are captured
|
|
40
|
+
# by command substitution, a forked subshell rather than a program run, so the
|
|
41
|
+
# success path executes nothing but the command. Under Nx a runtime input runs
|
|
42
|
+
# on every hash of every task that names it, and each program the wrapper ran
|
|
43
|
+
# cost more than the input it wrapped. The command's stdout goes to the outer
|
|
44
|
+
# capture as it is written; its stderr, then its exit status, are captured
|
|
45
|
+
# within, and follow it with their length, so the value is cut from the end and
|
|
46
|
+
# no delimiter has to be absent from the output. Lengths and patterns count
|
|
47
|
+
# bytes (LC_ALL=C), set only once the command has run.
|
|
48
|
+
#
|
|
49
|
+
# The one residual difference: a shell variable cannot hold a NUL byte, so a
|
|
50
|
+
# NUL in either stream is dropped. Two outputs that differ only in NUL bytes
|
|
51
|
+
# share a key; a command that might print a NUL hex-encodes its output.
|
|
39
52
|
set -u
|
|
40
53
|
if [ "$#" -eq 0 ]; then
|
|
41
54
|
echo 'usage: runtime-input.sh <command> [argument...]' >&2
|
|
42
55
|
printf '\377'
|
|
43
56
|
exit 64
|
|
44
57
|
fi
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
both=$(
|
|
59
|
+
exec 3>&1
|
|
60
|
+
ran=$("$@" 2>&1 1>&3 3>&-; printf ':%s' "$?")
|
|
61
|
+
LC_ALL=C
|
|
62
|
+
printf '%s;%s' "$ran" "${#ran}"
|
|
63
|
+
)
|
|
64
|
+
LC_ALL=C
|
|
65
|
+
case $both in
|
|
66
|
+
*';'*) ;;
|
|
67
|
+
*)
|
|
49
68
|
printf 'runtime input could not capture streams: %s\n' "$*" >&2
|
|
50
69
|
printf '\377'
|
|
51
70
|
exit 73
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
;;
|
|
72
|
+
esac
|
|
73
|
+
length=${both##*;}
|
|
74
|
+
both=${both%;*}
|
|
75
|
+
tail=
|
|
76
|
+
while [ "${#tail}" -lt "$length" ]; do
|
|
77
|
+
tail="$tail?"
|
|
78
|
+
done
|
|
79
|
+
stdout=${both%$tail}
|
|
80
|
+
ran=${both#"$stdout"}
|
|
81
|
+
status=${ran##*:}
|
|
82
|
+
stderr=${ran%:*}
|
|
83
|
+
if [ "$status" -eq 0 ]; then
|
|
84
|
+
printf '%s' "$stdout"
|
|
56
85
|
exit 0
|
|
57
|
-
else
|
|
58
|
-
status=$?
|
|
59
86
|
fi
|
|
60
|
-
|
|
87
|
+
printf '%s' "$stderr" >&2
|
|
61
88
|
if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
|
|
62
89
|
mktemp -d "$PWD/.runtime-input-failures/failure.XXXXXXXXXX"); then
|
|
63
90
|
if printf '%s\000' "$@" >"$record/argv" &&
|
|
64
91
|
printf '%s\n' "$status" >"$record/exit-status" &&
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
printf '%s' "$stderr" >"$record/stderr" &&
|
|
93
|
+
printf '%s' "$stdout" >"$record/stdout" && {
|
|
67
94
|
printf 'runtime input exited %s: %s\n' "$status" "$*"
|
|
68
95
|
printf 'working directory: %s\n' "$PWD"
|
|
69
96
|
index=0
|
|
@@ -73,9 +100,9 @@ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
|
|
|
73
100
|
index=$((index + 1))
|
|
74
101
|
done
|
|
75
102
|
printf 'original stderr:\n'
|
|
76
|
-
|
|
103
|
+
printf '%s' "$stderr"
|
|
77
104
|
printf 'original stdout (never hashed):\n'
|
|
78
|
-
|
|
105
|
+
printf '%s' "$stdout"
|
|
79
106
|
} >"$record/report"; then
|
|
80
107
|
printf '\nruntime input exited %s: %s; evidence: %s/report\n' "$status" "$*" "$record" >&2
|
|
81
108
|
# Nx discards this stderr, so a controlling terminal is the one live display
|
|
@@ -91,12 +118,12 @@ if record=$(umask 077; mkdir -p "$PWD/.runtime-input-failures" &&
|
|
|
91
118
|
exec 4>&-
|
|
92
119
|
fi
|
|
93
120
|
else
|
|
94
|
-
printf '\nruntime input exited %s: %s; evidence incomplete: %s
|
|
95
|
-
"$status" "$*" "$record"
|
|
121
|
+
printf '\nruntime input exited %s: %s; evidence incomplete: %s\n' \
|
|
122
|
+
"$status" "$*" "$record" >&2
|
|
96
123
|
fi
|
|
97
124
|
else
|
|
98
|
-
printf '\nruntime input exited %s: %s; could not retain evidence
|
|
99
|
-
"$status" "$*"
|
|
125
|
+
printf '\nruntime input exited %s: %s; could not retain evidence\n' \
|
|
126
|
+
"$status" "$*" >&2
|
|
100
127
|
fi
|
|
101
128
|
printf '\377'
|
|
102
129
|
exit "$status"
|