@smoothbricks/nx-plugin 0.4.28 → 0.4.29
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 +203 -83
- package/dist/bounded-test-policy.d.ts +10 -3
- package/dist/bounded-test-policy.d.ts.map +1 -1
- package/dist/bounded-test-policy.js +19 -25
- package/dist/cargo-closure-input.d.ts +12 -0
- package/dist/cargo-closure-input.d.ts.map +1 -1
- package/dist/cargo-closure-input.js +29 -7
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +42 -19
- package/dist/ensure-built-receipt.d.ts +34 -6
- package/dist/ensure-built-receipt.d.ts.map +1 -1
- package/dist/ensure-built-receipt.js +265 -159
- package/dist/ensure-built-witness.d.ts +27 -2
- package/dist/ensure-built-witness.d.ts.map +1 -1
- package/dist/ensure-built-witness.js +2176 -15
- package/dist/ensure-built.d.ts +99 -1
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +34 -53
- package/dist/executors/bounded-exec/cpu-pool.d.ts +16 -5
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +43 -19
- package/dist/executors/bounded-exec/executor.d.ts +11 -2
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +139 -39
- package/dist/executors/bounded-exec/ram-temp.d.ts +17 -11
- package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
- package/dist/executors/bounded-exec/ram-temp.js +27 -13
- package/dist/generators/bun-test-tracing/generator.js +2 -2
- package/dist/graph-input-contract.d.ts +98 -0
- package/dist/graph-input-contract.d.ts.map +1 -0
- package/dist/graph-input-contract.js +624 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -3
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +5 -2
- package/dist/managed-files/publish-workflow.d.ts +11 -1
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/producer-receipts.d.ts +19 -0
- package/dist/producer-receipts.d.ts.map +1 -0
- package/dist/producer-receipts.js +921 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +58 -0
- package/managed/raw/patches/nx@23.2.1.patch +328 -50
- package/managed/raw/tooling/direnv/developer-links.ts +147 -21
- package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
- package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
- package/managed/raw/tooling/direnv/repo-path +15 -2
- package/managed/raw/tooling/direnv/setup-environment.ts +179 -114
- package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
- package/nextest.toml +1 -1
- package/package.json +11 -6
- package/src/__tests__/fixture-nx-env.ts +7 -0
- package/src/__tests__/owned-installation.ts +174 -0
- package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
- package/src/bounded-test-policy.test.ts +36 -22
- package/src/bounded-test-policy.ts +19 -27
- package/src/bun-bootstrap.test.ts +1 -1
- package/src/cargo-closure-input.test.ts +60 -11
- package/src/cargo-closure-input.ts +28 -6
- package/src/cargo-resolve-cache.test.ts +140 -25
- package/src/cargo-source-hash.test.ts +78 -3
- package/src/cargo-source-hash.ts +48 -30
- package/src/cross-check-policy.test.ts +2 -2
- package/src/ensure-built-receipt.test.ts +111 -16
- package/src/ensure-built-receipt.ts +251 -149
- package/src/ensure-built-witness.test.ts +197 -13
- package/src/ensure-built-witness.ts +187 -15
- package/src/ensure-built.test.ts +156 -102
- package/src/ensure-built.ts +114 -64
- package/src/executors/bounded-exec/cpu-pool.test.ts +116 -32
- package/src/executors/bounded-exec/cpu-pool.ts +55 -17
- package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
- package/src/executors/bounded-exec/executor-host.test.ts +51 -41
- package/src/executors/bounded-exec/executor.test.ts +155 -35
- package/src/executors/bounded-exec/executor.ts +156 -45
- package/src/executors/bounded-exec/progress.test.ts +1 -1
- package/src/executors/bounded-exec/ram-temp-host.test.ts +46 -17
- package/src/executors/bounded-exec/ram-temp.test.ts +65 -3
- package/src/executors/bounded-exec/ram-temp.ts +32 -16
- package/src/executors/bounded-exec/verdict.test.ts +17 -12
- package/src/generators/bounded-test-targets/generator.test.ts +1 -3
- package/src/generators/bun-test-tracing/generator.test.ts +2 -2
- package/src/generators/bun-test-tracing/generator.ts +2 -2
- package/src/graph-input-contract.test.ts +371 -0
- package/src/graph-input-contract.ts +605 -0
- package/src/index.test.ts +3 -3
- package/src/index.ts +24 -3
- package/src/linked-snapshots.nx.test.ts +112 -30
- package/src/managed-files/ci-workflow.ts +5 -2
- package/src/managed-files/publish-workflow.ts +12 -1
- package/src/managed-files/repo-path.test.ts +44 -1
- package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
- package/src/nextest-code-bound.test.ts +23 -17
- package/src/nextest-partitions.test.ts +7 -1
- package/src/nx-cache-restore-mtime.test.ts +2 -2
- package/src/nx-daemon-claim.test.ts +5 -5
- package/src/nx-daemon-idle-cpu.test.ts +0 -1
- package/src/nx-daemon-idle-policy.test.ts +56 -0
- package/src/nx-daemon-ignore-files.test.ts +2 -2
- package/src/nx-daemon-validity.test.ts +31 -9
- package/src/nx-dot-input-policy.test.ts +5 -5
- package/src/nx-files-archive-racy.test.ts +1 -1
- package/src/nx-incomplete-run-summary.test.ts +1 -1
- package/src/nx-plugin-load-errors.test.ts +2 -2
- package/src/nx-project-graph-errors.test.ts +70 -0
- package/src/nx-skipped-task-exit.test.ts +2 -2
- package/src/nx-store-resolution.test.ts +7 -25
- package/src/nx-task-output-lease.test.ts +3 -3
- package/src/nx-use-local.test.ts +7 -5
- package/src/producer-receipts.test.ts +164 -0
- package/src/producer-receipts.ts +631 -0
- package/src/runtime-input.test.ts +1 -1
- package/src/serial-group-wiring.test.ts +4 -4
- package/src/task-results.test.ts +18 -16
- package/src/test-timings.test.ts +2 -2
- package/src/testing.test.ts +5 -5
- package/src/testing.ts +59 -0
- package/src/typecheck-test-policy.test.ts +1 -1
- package/src/typescript-resolution.test.ts +76 -0
- package/test-timings.json +5 -0
|
@@ -6,14 +6,21 @@ import { join } from 'node:path';
|
|
|
6
6
|
import type { Task } from 'nx/src/config/task-graph';
|
|
7
7
|
import { expandOutputs } from 'nx/src/native';
|
|
8
8
|
import { cargoRuntimeInput } from './cargo-toolchain-policy.js';
|
|
9
|
+
import type { EnsureBuiltProducerReceipt } from './ensure-built.js';
|
|
9
10
|
import {
|
|
10
11
|
boundedReceiptRuntimes,
|
|
12
|
+
captureProducerSource,
|
|
11
13
|
dirtyProviderPaths,
|
|
14
|
+
type ProducerSourceWitness,
|
|
12
15
|
type ProviderInputProof,
|
|
16
|
+
producerOutputPaths,
|
|
17
|
+
producerSourceUnchanged,
|
|
13
18
|
providerReceipt,
|
|
14
19
|
} from './ensure-built-receipt.js';
|
|
15
20
|
|
|
16
21
|
let root = '';
|
|
22
|
+
let source: ProducerSourceWitness;
|
|
23
|
+
let producer: Omit<EnsureBuiltProducerReceipt, 'outputSha256'>;
|
|
17
24
|
const task = {
|
|
18
25
|
id: 'app:build',
|
|
19
26
|
target: { project: 'app', target: 'build' },
|
|
@@ -46,6 +53,28 @@ beforeEach(async () => {
|
|
|
46
53
|
await symlink('file', join(root, 'output/link'));
|
|
47
54
|
await chmod(join(root, 'output/file'), 0o644);
|
|
48
55
|
await chmod(join(root, 'output/empty'), 0o755);
|
|
56
|
+
const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
|
|
57
|
+
if (!captured.ok) throw new Error(captured.detail);
|
|
58
|
+
source = captured.value;
|
|
59
|
+
producer = {
|
|
60
|
+
version: 1,
|
|
61
|
+
target: task.id,
|
|
62
|
+
argv: ['nx', 'run', task.id],
|
|
63
|
+
trackedTreeClean: true,
|
|
64
|
+
environmentIdentity: 'unit-fixture-nx-hash-identity',
|
|
65
|
+
tools: [],
|
|
66
|
+
wallTimeMs: 0,
|
|
67
|
+
inputs: [
|
|
68
|
+
{
|
|
69
|
+
taskId: task.id,
|
|
70
|
+
overrides: task.overrides,
|
|
71
|
+
declared: [],
|
|
72
|
+
expanded: inputs,
|
|
73
|
+
hashDetails: { command: 'unit-fixture', nodes: {} },
|
|
74
|
+
files: source.files.filter(({ path }) => inputs.files.includes(path)),
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
};
|
|
49
78
|
});
|
|
50
79
|
afterEach(async () => {
|
|
51
80
|
await rm(root, { recursive: true, force: true });
|
|
@@ -56,14 +85,36 @@ describe('provider receipt', () => {
|
|
|
56
85
|
const saved = process.env.GIT_DIR;
|
|
57
86
|
process.env.GIT_DIR = join(root, 'not-the-provider-git-directory');
|
|
58
87
|
try {
|
|
59
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('hit');
|
|
88
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
|
|
60
89
|
} finally {
|
|
61
90
|
if (saved === undefined) delete process.env.GIT_DIR;
|
|
62
91
|
else process.env.GIT_DIR = saved;
|
|
63
92
|
}
|
|
64
93
|
});
|
|
94
|
+
it("reads provider provenance without the operator's global git configuration", async () => {
|
|
95
|
+
// The cowshed sandbox denies the operator's global git configuration to a workspace's Nx daemon, which runs these
|
|
96
|
+
// hooks under a host client's HOME; git then dies "unable to access". A self-referencing link fails git the same
|
|
97
|
+
// way (ELOOP), where an unreadable file would only warn (EACCES).
|
|
98
|
+
const home = join(root, 'operator-home');
|
|
99
|
+
await mkdir(home);
|
|
100
|
+
await symlink('.gitconfig', join(home, '.gitconfig'));
|
|
101
|
+
const names = ['HOME', 'XDG_CONFIG_HOME', 'GIT_CONFIG_GLOBAL', 'GIT_CONFIG_NOSYSTEM'] as const;
|
|
102
|
+
const saved = names.map((name) => [name, process.env[name]] as const);
|
|
103
|
+
for (const name of names) delete process.env[name];
|
|
104
|
+
process.env.HOME = home;
|
|
105
|
+
try {
|
|
106
|
+
const captured = captureProducerSource(root, producerOutputPaths(root, [task], expandOutputs));
|
|
107
|
+
expect(captured.ok ? 'captured' : captured.detail).toBe('captured');
|
|
108
|
+
expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
|
|
109
|
+
} finally {
|
|
110
|
+
for (const [name, value] of saved) {
|
|
111
|
+
if (value === undefined) delete process.env[name];
|
|
112
|
+
else process.env[name] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
65
116
|
it('names current hashes, HEAD/tree, independent file digests, link text and empty directory modes', async () => {
|
|
66
|
-
const result = providerReceipt(root, task.id, [task], proof, expandOutputs);
|
|
117
|
+
const result = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
|
|
67
118
|
expect(result.disposition).toBe('hit');
|
|
68
119
|
if (result.disposition !== 'hit') throw new Error(result.reason.detail);
|
|
69
120
|
expect(result.receipt.head).toMatch(/^[a-f0-9]{40,64}$/);
|
|
@@ -91,51 +142,93 @@ describe('provider receipt', () => {
|
|
|
91
142
|
});
|
|
92
143
|
});
|
|
93
144
|
|
|
94
|
-
it('
|
|
145
|
+
it('ignores unrelated untracked files while retaining tracked-tree production provenance', async () => {
|
|
95
146
|
await writeFile(join(root, 'unrelated.ts'), 'unrelated');
|
|
96
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('hit');
|
|
147
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('hit');
|
|
97
148
|
expect(
|
|
98
|
-
providerReceipt(
|
|
99
|
-
|
|
100
|
-
|
|
149
|
+
providerReceipt(
|
|
150
|
+
root,
|
|
151
|
+
task.id,
|
|
152
|
+
[task],
|
|
153
|
+
{ ...proof, kind: 'conservative-provider-source' },
|
|
154
|
+
expandOutputs,
|
|
155
|
+
source,
|
|
156
|
+
producer,
|
|
157
|
+
).disposition,
|
|
158
|
+
).toBe('hit');
|
|
101
159
|
});
|
|
102
160
|
|
|
103
161
|
it('refuses modified, deleted, newly matched and index-only dirty FILE inputs', async () => {
|
|
104
162
|
await writeFile(join(root, 'source.txt'), 'changed');
|
|
105
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
|
|
163
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
|
|
106
164
|
git('add', 'source.txt');
|
|
107
165
|
await writeFile(join(root, 'source.txt'), 'source');
|
|
108
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
|
|
166
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
|
|
109
167
|
git('restore', '--staged', 'source.txt');
|
|
110
168
|
await writeFile(join(root, 'new-source.txt'), 'new');
|
|
111
169
|
expect(
|
|
112
|
-
providerReceipt(
|
|
113
|
-
|
|
170
|
+
providerReceipt(
|
|
171
|
+
root,
|
|
172
|
+
task.id,
|
|
173
|
+
[task],
|
|
174
|
+
{ ...proof, files: [...proof.files, 'new-source.txt'] },
|
|
175
|
+
expandOutputs,
|
|
176
|
+
source,
|
|
177
|
+
producer,
|
|
178
|
+
).disposition,
|
|
114
179
|
).toBe('failed');
|
|
115
180
|
await rm(join(root, 'source.txt'));
|
|
116
|
-
expect(
|
|
181
|
+
expect(
|
|
182
|
+
providerReceipt(root, task.id, [task], { ...proof, files: [] }, expandOutputs, source, producer).disposition,
|
|
183
|
+
).toBe('failed');
|
|
117
184
|
});
|
|
118
185
|
|
|
119
186
|
it('recomputes output byte/directory identities after every public mutation', async () => {
|
|
120
|
-
const first = providerReceipt(root, task.id, [task], proof, expandOutputs);
|
|
187
|
+
const first = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
|
|
121
188
|
if (first.disposition !== 'hit') throw new Error(first.reason.detail);
|
|
122
189
|
await writeFile(join(root, 'output/file'), 'PUBLIC BYTES');
|
|
123
190
|
await chmod(join(root, 'output/empty'), 0o700);
|
|
124
|
-
const next = providerReceipt(root, task.id, [task], proof, expandOutputs);
|
|
191
|
+
const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
|
|
125
192
|
if (next.disposition !== 'hit') throw new Error(next.reason.detail);
|
|
126
193
|
expect(next.receipt.tasks[0].outputs).not.toEqual(first.receipt.tasks[0].outputs);
|
|
127
194
|
expect(next.receipt.tasks[0].outputs.find(({ path }) => path === 'output/empty')).toMatchObject({ mode: 0o700 });
|
|
128
195
|
});
|
|
129
196
|
|
|
197
|
+
it('accepts a new HEAD at the same committed tree without rewriting the producer basis', () => {
|
|
198
|
+
const original = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
|
|
199
|
+
if (original.disposition !== 'hit') throw new Error(original.reason.detail);
|
|
200
|
+
git(
|
|
201
|
+
'-c',
|
|
202
|
+
'user.name=Receipt fixture',
|
|
203
|
+
'-c',
|
|
204
|
+
'user.email=receipt@example.invalid',
|
|
205
|
+
'commit',
|
|
206
|
+
'--allow-empty',
|
|
207
|
+
'-qm',
|
|
208
|
+
'same tree',
|
|
209
|
+
);
|
|
210
|
+
expect(producerSourceUnchanged(root, source)).toEqual({ ok: true, value: true });
|
|
211
|
+
const next = providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer);
|
|
212
|
+
if (next.disposition !== 'hit') throw new Error(next.reason.detail);
|
|
213
|
+
expect(next.receipt.head).toBe(original.receipt.head);
|
|
214
|
+
expect(next.receipt.headTree).toBe(original.receipt.headTree);
|
|
215
|
+
expect(next.receipt.producer.outputSha256).toBe(original.receipt.producer.outputSha256);
|
|
216
|
+
});
|
|
217
|
+
it('revokes a producer pre-source witness for a write/revert even when final bytes match HEAD', async () => {
|
|
218
|
+
await writeFile(join(root, 'source.txt'), 'edited');
|
|
219
|
+
await writeFile(join(root, 'source.txt'), 'source');
|
|
220
|
+
expect(producerSourceUnchanged(root, source).ok).toBe(false);
|
|
221
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
|
|
222
|
+
});
|
|
130
223
|
it('refuses unreadable public bytes, missing outputs and opaque runtime closure', async () => {
|
|
131
224
|
await chmod(join(root, 'output/file'), 0);
|
|
132
225
|
try {
|
|
133
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
|
|
226
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
|
|
134
227
|
} finally {
|
|
135
228
|
await chmod(join(root, 'output/file'), 0o600);
|
|
136
229
|
}
|
|
137
230
|
await rm(join(root, 'output'), { recursive: true });
|
|
138
|
-
expect(providerReceipt(root, task.id, [task], proof, expandOutputs).disposition).toBe('failed');
|
|
231
|
+
expect(providerReceipt(root, task.id, [task], proof, expandOutputs, source, producer).disposition).toBe('failed');
|
|
139
232
|
expect(
|
|
140
233
|
providerReceipt(
|
|
141
234
|
root,
|
|
@@ -143,6 +236,8 @@ describe('provider receipt', () => {
|
|
|
143
236
|
[task],
|
|
144
237
|
{ ...proof, runtimeSource: { kind: 'opaque', detail: 'unnameable command input closure' } },
|
|
145
238
|
expandOutputs,
|
|
239
|
+
source,
|
|
240
|
+
producer,
|
|
146
241
|
),
|
|
147
242
|
).toMatchObject({
|
|
148
243
|
disposition: 'failed',
|