@smoothbricks/nx-plugin 0.6.2 → 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 +417 -171
- package/dist/.build-inputs.json +39 -28
- 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/bin/smoo-nx-publish.d.ts +3 -0
- package/dist/bin/smoo-nx-publish.d.ts.map +1 -0
- package/dist/bin/smoo-nx-publish.js +3 -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-retention-hook.d.ts +6 -2
- package/dist/cargo-retention-hook.d.ts.map +1 -1
- package/dist/cargo-retention-hook.js +13 -7
- 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/eslint-file-set.d.ts +4 -1
- package/dist/eslint-file-set.d.ts.map +1 -1
- package/dist/eslint-sources.d.ts +25 -0
- package/dist/eslint-sources.d.ts.map +1 -0
- package/dist/eslint-sources.js +99 -0
- package/dist/executors/all-verdicts/executor.d.ts +2 -1
- package/dist/executors/all-verdicts/executor.d.ts.map +1 -1
- package/dist/executors/all-verdicts/executor.js +48 -2
- package/dist/executors/all-verdicts/schema.d.ts +13 -0
- package/dist/executors/all-verdicts/schema.d.ts.map +1 -1
- package/dist/executors/all-verdicts/schema.js +7 -0
- package/dist/executors/bounded-exec/bounds.d.ts +57 -8
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +100 -11
- package/dist/executors/bounded-exec/executor.d.ts +2 -1
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +289 -34
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +2 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +2 -2
- package/dist/executors/bounded-exec/mbx-pool.d.ts +56 -10
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +145 -11
- package/dist/executors/bounded-exec/mbx-queue.d.ts +30 -0
- package/dist/executors/bounded-exec/mbx-queue.d.ts.map +1 -0
- package/dist/executors/bounded-exec/mbx-queue.js +229 -0
- package/dist/executors/bounded-exec/progress.d.ts +9 -2
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +151 -25
- 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/test-result-writer.d.ts +30 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-result-writer.js +126 -0
- package/dist/executors/bounded-exec/test-results.d.ts +33 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -0
- package/dist/executors/bounded-exec/test-results.js +33 -0
- package/dist/executors/bounded-exec/verdict.d.ts +26 -2
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +108 -4
- 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 +12 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -295
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +5 -0
- package/dist/nx-publish.d.ts +24 -0
- package/dist/nx-publish.d.ts.map +1 -0
- package/dist/nx-publish.js +150 -0
- package/dist/process-group.js +2 -2
- package/dist/runtime-input-policy.d.ts +17 -3
- package/dist/runtime-input-policy.d.ts.map +1 -1
- package/dist/runtime-input-policy.js +4 -4
- 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/tool-bins.d.ts +6 -8
- package/dist/tool-bins.d.ts.map +1 -1
- package/dist/tool-bins.js +7 -5
- 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-index.d.ts +7 -0
- package/dist/workspace-index.d.ts.map +1 -1
- package/dist/workspace-index.js +11 -0
- package/dist/workspace-manifest.js +3 -3
- package/executors.json +7 -6
- package/managed/raw/patches/nx@23.2.1.patch +118 -24
- package/managed/raw/patches/ttsc@0.34.1.patch +139 -0
- package/managed/raw/tooling/devenv +1 -2
- package/managed/raw/tooling/direnv/developer-links.ts +124 -51
- package/managed/raw/tooling/direnv/devenv.smoo.nix +34 -15
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +20 -10
- package/managed/raw/tooling/direnv/installed-bun-links.ts +7 -6
- package/managed/raw/tooling/direnv/setup-environment.ts +49 -24
- package/managed/raw/tooling/direnv/ttsc-env.sh +8 -6
- package/managed/raw/tooling/git-hooks/pinned-revisions-served.ts +252 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +34 -32
- package/managed/templates/github/actions/cache-node-modules/action.yml +1 -1
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +12 -11
- package/package.json +277 -11
- package/runtime/nx-publish/.build-inputs.json +11 -0
- package/runtime/nx-publish/cache_adapter.js +45 -0
- package/runtime/nx-publish/nx_publish.js +60 -0
- package/runtime-input.sh +62 -26
- package/src/bin/smoo-nx-go-test-build.ts +83 -0
- package/src/bin/smoo-nx-go-test-run.ts +140 -0
- package/src/bin/smoo-nx-publish.ts +4 -0
- package/src/bounded-test-policy.ts +9 -8
- package/src/cargo-retention-hook.ts +16 -10
- package/src/cargo-workspace.ts +12 -24
- package/src/cross-check-policy.ts +2 -2
- package/src/deploy-policy.ts +11 -0
- package/src/eslint-file-set.ts +4 -1
- package/src/eslint-sources.ts +134 -0
- package/src/executors/all-verdicts/executor.ts +58 -3
- package/src/executors/all-verdicts/schema.json +4 -0
- package/src/executors/all-verdicts/schema.ts +14 -0
- package/src/executors/bounded-exec/bounds.ts +132 -15
- package/src/executors/bounded-exec/executor.ts +329 -34
- package/src/executors/bounded-exec/hang-diagnostics.ts +3 -2
- package/src/executors/bounded-exec/mbx-pool.ts +158 -17
- package/src/executors/bounded-exec/mbx-queue.ts +170 -0
- package/src/executors/bounded-exec/progress.ts +171 -18
- 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/test-result-writer.ts +152 -0
- package/src/executors/bounded-exec/test-results.ts +39 -0
- package/src/executors/bounded-exec/verdict.ts +115 -5
- 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 +368 -323
- package/src/managed-files/files.ts +5 -0
- package/src/nx-publish.ts +157 -0
- package/src/process-group.ts +2 -2
- package/src/runtime-input-policy.ts +4 -4
- package/src/test-timings.ts +72 -14
- package/src/tool-bins.ts +13 -9
- package/src/version-actions.cts +10 -11
- package/src/workspace-config-policy.ts +20 -29
- package/src/workspace-index.ts +12 -0
- package/src/workspace-manifest.ts +3 -3
- package/test-timings.json +131 -125
- 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,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
|
|
@@ -8,7 +8,7 @@ runs:
|
|
|
8
8
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
9
9
|
with:
|
|
10
10
|
# Isolated Bun links and their targets are one dependency tree.
|
|
11
|
-
# ttsc
|
|
11
|
+
# ttsc plugins stay under $TTSC_CACHE_DIR (.cache/ttsc-plugins), its Go build cache under .cache/ttsc/go-build.
|
|
12
12
|
# v2 isolates restore-keys from older Darwin caches with a broken TS dual-package hoist.
|
|
13
13
|
path: |
|
|
14
14
|
node_modules
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
name: Cache ttsc plugins
|
|
2
2
|
description: >
|
|
3
|
-
Restore or save the compiled ttsc native plugin binaries (typia, etc.) under TTSC_CACHE_DIR/plugins
|
|
4
|
-
entry by a hash of what it was compiled from and skips the
|
|
5
|
-
them, and save-nix-devenv saves the entries the job used when
|
|
6
|
-
(go-build
|
|
3
|
+
Restore or save the compiled ttsc native plugin binaries (typia, etc.) under TTSC_CACHE_DIR/plugins
|
|
4
|
+
(.cache/ttsc-plugins/plugins). ttsc names every entry by a hash of what it was compiled from and skips the
|
|
5
|
+
multi-minute `go build` when one matches. Setup restores them, and save-nix-devenv saves the entries the job used when
|
|
6
|
+
the job ends, red or green. The Go object cache (.cache/ttsc/go-build, outside the plugin root) is NOT cached: it is
|
|
7
|
+
multi-GB and only helps when the plugin key misses.
|
|
7
8
|
|
|
8
9
|
inputs:
|
|
9
10
|
mode:
|
|
@@ -22,8 +23,8 @@ runs:
|
|
|
22
23
|
if: inputs.mode == 'restore'
|
|
23
24
|
shell: bash
|
|
24
25
|
run: |
|
|
25
|
-
mkdir -p .cache/ttsc
|
|
26
|
-
grep -E '^ +"(@ttsc/[^"]+|ttsc(/[^"]+)?)": |"ttsc": "' bun.lock > .cache/ttsc/plugin-lock-entries
|
|
26
|
+
mkdir -p .cache/ttsc-plugins
|
|
27
|
+
grep -E '^ +"(@ttsc/[^"]+|ttsc(/[^"]+)?)": |"ttsc": "' bun.lock > .cache/ttsc-plugins/plugin-lock-entries
|
|
27
28
|
|
|
28
29
|
# A prefix hit is safe. ttsc names every entry by a hash of what it was compiled from (the ttsc and tsgo versions,
|
|
29
30
|
# platform and architecture, the Go toolchain and its build environment, the plugin sources) and runs an entry only
|
|
@@ -35,10 +36,10 @@ runs:
|
|
|
35
36
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
36
37
|
with:
|
|
37
38
|
# Only the compiled plugin binaries (~30MB each). Path is relative to the
|
|
38
|
-
# workspace; devenv sets TTSC_CACHE_DIR to <repo>/.cache/ttsc.
|
|
39
|
-
path: .cache/ttsc/plugins
|
|
39
|
+
# workspace; devenv sets TTSC_CACHE_DIR to <repo>/.cache/ttsc-plugins.
|
|
40
|
+
path: .cache/ttsc-plugins/plugins
|
|
40
41
|
# prettier-ignore
|
|
41
|
-
key: ${{ runner.os }}-${{ runner.arch }}-ttsc-plugins-v1-${{ hashFiles('.cache/ttsc/plugin-lock-entries', 'patches/ttsc@*.patch', 'tooling/direnv/devenv.lock', 'tooling/direnv/devenv.smoo.nix') }}
|
|
42
|
+
key: ${{ runner.os }}-${{ runner.arch }}-ttsc-plugins-v1-${{ hashFiles('.cache/ttsc-plugins/plugin-lock-entries', 'patches/ttsc@*.patch', 'tooling/direnv/devenv.lock', 'tooling/direnv/devenv.smoo.nix') }}
|
|
42
43
|
restore-keys: |
|
|
43
44
|
${{ runner.os }}-${{ runner.arch }}-ttsc-plugins-v1-
|
|
44
45
|
|
|
@@ -73,7 +74,7 @@ runs:
|
|
|
73
74
|
shopt -s nullglob
|
|
74
75
|
: "${SMOO_TTSC_PLUGINS_RESTORED_AT_MS:?the restore of this action records when the job restored the cache}"
|
|
75
76
|
kept=0
|
|
76
|
-
for entry in "$GITHUB_WORKSPACE"/.cache/ttsc/plugins/*/; do
|
|
77
|
+
for entry in "$GITHUB_WORKSPACE"/.cache/ttsc-plugins/plugins/*/; do
|
|
77
78
|
entry="${entry%/}"
|
|
78
79
|
case "$entry" in *.lock | *.lock.*) continue ;; esac
|
|
79
80
|
used=0
|
|
@@ -92,5 +93,5 @@ runs:
|
|
|
92
93
|
if: inputs.mode == 'save' && steps.prune.outputs.kept > 0
|
|
93
94
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
94
95
|
with:
|
|
95
|
-
path: .cache/ttsc/plugins
|
|
96
|
+
path: .cache/ttsc-plugins/plugins
|
|
96
97
|
key: ${{ env.SMOO_TTSC_PLUGINS_SAVE_KEY }}
|