@smoothbricks/nx-plugin 0.4.27 → 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 +363 -125
- 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
|
@@ -177,7 +177,7 @@ describe('a second daemon started for a workspace a daemon serves', () => {
|
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
});
|
|
180
|
-
}
|
|
180
|
+
});
|
|
181
181
|
|
|
182
182
|
it('exits and leaves the serving daemon alone when both use one socket directory', async () => {
|
|
183
183
|
await withNxFixture('nx-daemon-claim-shared-', async ({ socketDirectory, workspace }) => {
|
|
@@ -187,7 +187,7 @@ describe('a second daemon started for a workspace a daemon serves', () => {
|
|
|
187
187
|
await secondDaemonDefers(workspace, env, env);
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
|
-
}
|
|
190
|
+
});
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
it('replaces a daemon whose socket was removed, which no client could reach', async () => {
|
|
@@ -204,7 +204,7 @@ it('replaces a daemon whose socket was removed, which no client could reach', as
|
|
|
204
204
|
const replacement = await daemonRecord(workspace);
|
|
205
205
|
expect(replacement?.processId).not.toBe(lost.processId);
|
|
206
206
|
});
|
|
207
|
-
}
|
|
207
|
+
});
|
|
208
208
|
|
|
209
209
|
it('keeps serving clients whose socket directory differs from the one it bound', async () => {
|
|
210
210
|
await withNxFixture('nx-daemon-claim-env-', async ({ socketDirectory, workspace }) => {
|
|
@@ -229,7 +229,7 @@ it('keeps serving clients whose socket directory differs from the one it bound',
|
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
});
|
|
232
|
-
}
|
|
232
|
+
});
|
|
233
233
|
|
|
234
234
|
it('replaces a record whose pid now belongs to an unrelated live process', async () => {
|
|
235
235
|
await withNxFixture('nx-daemon-claim-reused-', async ({ socketDirectory, workspace }) => {
|
|
@@ -274,4 +274,4 @@ it('replaces a record whose pid now belongs to an unrelated live process', async
|
|
|
274
274
|
await unrelatedExited;
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
|
-
}
|
|
277
|
+
});
|
|
@@ -4,7 +4,23 @@ import { readFileSync } from 'node:fs';
|
|
|
4
4
|
import { mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
|
|
5
5
|
import { createRequire } from 'node:module';
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
7
8
|
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
9
|
+
import { nxDaemonProcesses } from './testing.js';
|
|
10
|
+
|
|
11
|
+
// A graph plugin that asks its daemon for files, as globIndexedFiles does: from an isolated worker Nx routes the glob
|
|
12
|
+
// through the worker's own daemon client.
|
|
13
|
+
const DAEMON_GLOB_PLUGIN = `const { globWithWorkspaceContext } = require('nx/src/utils/workspace-context');
|
|
14
|
+
const { workspaceRoot } = require('nx/src/utils/workspace-root');
|
|
15
|
+
exports.createNodesV2 = ['**/project.json', async () => {
|
|
16
|
+
await globWithWorkspaceContext(workspaceRoot, ['**/project.json']);
|
|
17
|
+
return [];
|
|
18
|
+
}];
|
|
19
|
+
`;
|
|
20
|
+
// The daemon logs its open connection count on every connect and close.
|
|
21
|
+
const OPEN_CONNECTIONS = /Number of open connections: (\d+)$/;
|
|
22
|
+
// How long the daemon may take to see a closed connection: the aftermath of a reply, not an idle interval.
|
|
23
|
+
const CLOSE_SEEN_MS = 10_000;
|
|
8
24
|
|
|
9
25
|
it('serves real daemon requests with the installed five-minute inactivity policy', async () => {
|
|
10
26
|
const require = createRequire(import.meta.url);
|
|
@@ -34,6 +50,46 @@ it('serves real daemon requests with the installed five-minute inactivity policy
|
|
|
34
50
|
});
|
|
35
51
|
});
|
|
36
52
|
|
|
53
|
+
it('lets a resident plugin worker ask its daemon for files without holding the daemon open', async () => {
|
|
54
|
+
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
55
|
+
const nxEntry = join(repositoryRoot, 'node_modules/.bin/nx');
|
|
56
|
+
await withNxFixture('nx-worker-connection-', async ({ workspace, socketDirectory }) => {
|
|
57
|
+
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
58
|
+
await writeFile(join(workspace, 'nx.json'), JSON.stringify({ plugins: ['./daemon-glob-plugin.js'] }));
|
|
59
|
+
await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'worker-connection', private: true }));
|
|
60
|
+
await writeFile(join(workspace, 'daemon-glob-plugin.js'), DAEMON_GLOB_PLUGIN);
|
|
61
|
+
await mkdir(join(workspace, 'p'));
|
|
62
|
+
await writeFile(join(workspace, 'p/project.json'), JSON.stringify({ name: 'p' }));
|
|
63
|
+
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_DAEMON: 'true', NX_ISOLATE_PLUGINS: 'true' };
|
|
64
|
+
const requested = spawnSync('node', [nxEntry, 'show', 'projects', '--json'], {
|
|
65
|
+
cwd: workspace,
|
|
66
|
+
env,
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
});
|
|
69
|
+
expect(requested.status, requested.stdout + requested.stderr).toBe(0);
|
|
70
|
+
expect(JSON.parse(requested.stdout)).toEqual(['p']);
|
|
71
|
+
const logPath = join(workspace, '.nx/workspace-data/d/daemon.log');
|
|
72
|
+
const deadline = Date.now() + CLOSE_SEEN_MS;
|
|
73
|
+
let open: string | undefined;
|
|
74
|
+
for (;;) {
|
|
75
|
+
const log = await readFile(logPath, 'utf8');
|
|
76
|
+
expect(log).toContain('Handled json message GLOB');
|
|
77
|
+
open = log
|
|
78
|
+
.split('\n')
|
|
79
|
+
.map((line) => OPEN_CONNECTIONS.exec(line)?.[1])
|
|
80
|
+
.filter((count) => count !== undefined)
|
|
81
|
+
.at(-1);
|
|
82
|
+
if (open === '0' || Date.now() > deadline) break;
|
|
83
|
+
await sleep(50);
|
|
84
|
+
}
|
|
85
|
+
// A connection the worker kept would keep the daemon from its five-minute idle stop for as long as the worker
|
|
86
|
+
// lives, and the daemon keeps a worker with graph hooks for as long as it lives.
|
|
87
|
+
expect(open, `open daemon connections ${CLOSE_SEEN_MS}ms after the only client exited`).toBe('0');
|
|
88
|
+
const workers = (await nxDaemonProcesses(workspace)).filter(({ command }) => command.includes('plugin-worker'));
|
|
89
|
+
expect(workers.length, 'the resident plugin worker that asked the daemon for files').toBeGreaterThan(0);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
37
93
|
it('syntax-checks every JavaScript file patched in the actual installed Nx product', () => {
|
|
38
94
|
const installedNxRoot = dirname(createRequire(import.meta.url).resolve('nx/package.json'));
|
|
39
95
|
const patch = readFileSync(new URL('../../../patches/nx@23.2.1.patch', import.meta.url), 'utf8');
|
|
@@ -154,7 +154,7 @@ it('keeps serving when a watched ignore file is rewritten with the bytes the dae
|
|
|
154
154
|
await client.end();
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
|
-
}
|
|
157
|
+
});
|
|
158
158
|
|
|
159
159
|
/** A workspace whose context walk takes long enough that a write right after `watch()` lands before it. */
|
|
160
160
|
async function largeWorkspace(workspace: string): Promise<void> {
|
|
@@ -207,4 +207,4 @@ it('stops when an ignore file changes after the watcher read it and before the d
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
});
|
|
210
|
-
}
|
|
210
|
+
});
|
|
@@ -575,7 +575,7 @@ it('awaits an answerable daemon after a closed PING without another socket-direc
|
|
|
575
575
|
await closed.promise;
|
|
576
576
|
}
|
|
577
577
|
});
|
|
578
|
-
}
|
|
578
|
+
});
|
|
579
579
|
|
|
580
580
|
/** Valid lockfiles keep the real graph usable while the watcher judges byte changes. */
|
|
581
581
|
async function lockContents(
|
|
@@ -665,7 +665,7 @@ for (const lockfile of LOCKFILES) {
|
|
|
665
665
|
},
|
|
666
666
|
FIXTURE_WORKSPACE,
|
|
667
667
|
);
|
|
668
|
-
}
|
|
668
|
+
});
|
|
669
669
|
}
|
|
670
670
|
|
|
671
671
|
it('does not serve a request sent on a connection opened before a lockfile change', async () => {
|
|
@@ -703,7 +703,7 @@ it('does not serve a request sent on a connection opened before a lockfile chang
|
|
|
703
703
|
},
|
|
704
704
|
FIXTURE_WORKSPACE,
|
|
705
705
|
);
|
|
706
|
-
}
|
|
706
|
+
});
|
|
707
707
|
|
|
708
708
|
it('stops a daemon at the next request after an ignored lockfile changes, then its successor within its safety poll with no request', async () => {
|
|
709
709
|
await withNxFixture(
|
|
@@ -753,7 +753,7 @@ it('stops a daemon at the next request after an ignored lockfile changes, then i
|
|
|
753
753
|
},
|
|
754
754
|
FIXTURE_WORKSPACE,
|
|
755
755
|
);
|
|
756
|
-
}
|
|
756
|
+
});
|
|
757
757
|
|
|
758
758
|
it('stops a daemon, refusing its next request, once the installed nx version changes in place', async () => {
|
|
759
759
|
await withNxFixture(
|
|
@@ -781,7 +781,7 @@ it('stops a daemon, refusing its next request, once the installed nx version cha
|
|
|
781
781
|
},
|
|
782
782
|
FIXTURE_WORKSPACE,
|
|
783
783
|
);
|
|
784
|
-
}
|
|
784
|
+
});
|
|
785
785
|
|
|
786
786
|
it('stops a daemon once the workspace nx link points at a different version', async () => {
|
|
787
787
|
await withNxFixture(
|
|
@@ -806,7 +806,7 @@ it('stops a daemon once the workspace nx link points at a different version', as
|
|
|
806
806
|
},
|
|
807
807
|
FIXTURE_WORKSPACE,
|
|
808
808
|
);
|
|
809
|
-
}
|
|
809
|
+
});
|
|
810
810
|
|
|
811
811
|
it('leaves a successor record and socket in place when another process takes the record', async () => {
|
|
812
812
|
await withNxFixture(
|
|
@@ -840,7 +840,7 @@ it('leaves a successor record and socket in place when another process takes the
|
|
|
840
840
|
},
|
|
841
841
|
FIXTURE_WORKSPACE,
|
|
842
842
|
);
|
|
843
|
-
}
|
|
843
|
+
});
|
|
844
844
|
|
|
845
845
|
it("leaves a replacement socket in place when the daemon's own socket path is replaced", async () => {
|
|
846
846
|
await withNxFixture(
|
|
@@ -863,7 +863,7 @@ it("leaves a replacement socket in place when the daemon's own socket path is re
|
|
|
863
863
|
},
|
|
864
864
|
FIXTURE_WORKSPACE,
|
|
865
865
|
);
|
|
866
|
-
}
|
|
866
|
+
});
|
|
867
867
|
|
|
868
868
|
it('stops a daemon whose own socket path is removed with nothing taking its place', async () => {
|
|
869
869
|
await withNxFixture(
|
|
@@ -878,6 +878,28 @@ it('stops a daemon whose own socket path is removed with nothing taking its plac
|
|
|
878
878
|
},
|
|
879
879
|
FIXTURE_WORKSPACE,
|
|
880
880
|
);
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
it('stops a daemon whose workspace files are all deleted before it reads the emptied workspace', async () => {
|
|
884
|
+
await withNxFixture(
|
|
885
|
+
'nx-daemon-validity-emptied-',
|
|
886
|
+
async ({ socketDirectory, workspace }) => {
|
|
887
|
+
await fixtureWorkspace(workspace);
|
|
888
|
+
const env = fixtureNxEnv(workspace, socketDirectory);
|
|
889
|
+
const daemon = await startDaemon(workspace, env);
|
|
890
|
+
expect(JSON.parse(nx(workspace, { ...env, NX_DAEMON: 'true' }, 'show', 'projects', '--json'))).toEqual(['p']);
|
|
891
|
+
// Every tracked file goes, as when a checkout is removed or unmounted under its daemon; the daemon's own record
|
|
892
|
+
// under .nx stays, so only the workspace check can stop it. Reading the emptied file map instead would block
|
|
893
|
+
// the daemon's only thread for good, where no SIGTERM handler runs.
|
|
894
|
+
await rm(join(workspace, 'p'), { recursive: true });
|
|
895
|
+
await unlink(join(workspace, 'package.json'));
|
|
896
|
+
await unlink(join(workspace, 'nx.json'));
|
|
897
|
+
await awaitExit([daemon.entry], `daemon ${daemon.record.processId} after every workspace file was deleted`);
|
|
898
|
+
const log = await readFile(join(workspace, '.nx', 'workspace-data', 'd', 'daemon.log'), 'utf8');
|
|
899
|
+
expect(log).toMatch(/Server stopped because: "its workspace \S+ has no nx\.json any more"/);
|
|
900
|
+
},
|
|
901
|
+
FIXTURE_WORKSPACE,
|
|
902
|
+
);
|
|
881
903
|
}, 180_000);
|
|
882
904
|
|
|
883
905
|
it('keeps an idle daemon off the lockfiles, record, and socket between its safety polls', async () => {
|
|
@@ -922,4 +944,4 @@ it('keeps an idle daemon off the lockfiles, record, and socket between its safet
|
|
|
922
944
|
},
|
|
923
945
|
FIXTURE_WORKSPACE,
|
|
924
946
|
);
|
|
925
|
-
}
|
|
947
|
+
});
|
|
@@ -167,7 +167,7 @@ it('indexes every tracked dot input and none of the untracked dot state', async
|
|
|
167
167
|
expect(after).toEqual(before.filter((path) => tracked.includes(path)));
|
|
168
168
|
expect(after).toContain('.github/workflows/ci.yml');
|
|
169
169
|
expect(after).toContain('.cargo/config.toml');
|
|
170
|
-
}
|
|
170
|
+
});
|
|
171
171
|
|
|
172
172
|
it('keeps the watcher reporting tracked dot inputs and silent about untracked dot state', async () => {
|
|
173
173
|
const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
|
|
@@ -179,7 +179,7 @@ it('keeps the watcher reporting tracked dot inputs and silent about untracked do
|
|
|
179
179
|
const current = await withWorkspace(nxignore, reportedAfterWrites);
|
|
180
180
|
expect(current).toContain(TRACKED_DOT_WRITE);
|
|
181
181
|
expect(current.filter((path) => RUNTIME_DOT_STATE.includes(path))).toEqual([]);
|
|
182
|
-
}
|
|
182
|
+
});
|
|
183
183
|
|
|
184
184
|
it('fails the lint when a tracked dot path lacks its re-include line, and passes with it', async () => {
|
|
185
185
|
const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
|
|
@@ -203,7 +203,7 @@ it('fails the lint when a tracked dot path lacks its re-include line, and passes
|
|
|
203
203
|
const checkout = runLint(repositoryRoot);
|
|
204
204
|
expect(checkout.stderr).toBe('');
|
|
205
205
|
expect(checkout.status).toBe(0);
|
|
206
|
-
}
|
|
206
|
+
});
|
|
207
207
|
|
|
208
208
|
it('rejects a newly tracked dot input until its explicit negation is added', async () => {
|
|
209
209
|
const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
|
|
@@ -217,7 +217,7 @@ it('rejects a newly tracked dot input until its explicit negation is added', asy
|
|
|
217
217
|
const included = runLint(root);
|
|
218
218
|
expect(included.status, included.stderr).toBe(0);
|
|
219
219
|
});
|
|
220
|
-
}
|
|
220
|
+
});
|
|
221
221
|
|
|
222
222
|
it('preserves tracked input hashes and the graph while dot staging never causes graph passes', async () => {
|
|
223
223
|
const nxignore = await readFile(join(repositoryRoot, '.nxignore'), 'utf8');
|
|
@@ -350,4 +350,4 @@ it('preserves tracked input hashes and the graph while dot staging never causes
|
|
|
350
350
|
await ended;
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
|
-
}
|
|
353
|
+
});
|
|
@@ -41,7 +41,7 @@ it('names the duplicate project and both roots when local plugin resolution fail
|
|
|
41
41
|
expect(output).toContain('- packages/second');
|
|
42
42
|
expect(output).not.toContain('fixture-plugin-executed');
|
|
43
43
|
});
|
|
44
|
-
}
|
|
44
|
+
});
|
|
45
45
|
|
|
46
46
|
for (const fixture of [
|
|
47
47
|
{
|
|
@@ -116,5 +116,5 @@ throw failure;
|
|
|
116
116
|
for (const message of fixture.messages) expect(output).toContain(message);
|
|
117
117
|
if (fixture.repeated !== undefined) expect(output.split(fixture.repeated).length - 1).toBe(2);
|
|
118
118
|
});
|
|
119
|
-
}
|
|
119
|
+
});
|
|
120
120
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { expect, it } from 'bun:test';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { mkdir, symlink, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Guards the project-graph error hunks of patches/nx@23.2.1.patch (nrwl/nx#37103 carried, with cause chains) against
|
|
9
|
+
* the actual Bun-installed Nx: a createNodes failure names itself without --verbose. Before, `nx run-many` printed
|
|
10
|
+
* only "Failed to process project graph." and a consumer's CI could not say which plugin refused or why.
|
|
11
|
+
*/
|
|
12
|
+
const repositoryRoot = join(import.meta.dir, '../../..');
|
|
13
|
+
const nxEntry = join(repositoryRoot, 'node_modules/.bin/nx');
|
|
14
|
+
|
|
15
|
+
const FAILURE = 'fixture.rs names @smoothbricks/nx-plugin/dist/bin/smoo-nx-absent.js, which the plugin does not ship';
|
|
16
|
+
const CAUSE = 'fixture cause of the refusal';
|
|
17
|
+
const STACK_FRAME = /failure\.cjs:\d+:\d+/;
|
|
18
|
+
|
|
19
|
+
for (const command of [
|
|
20
|
+
['run-many', '-t', 'build'],
|
|
21
|
+
['show', 'projects', '--json'],
|
|
22
|
+
]) {
|
|
23
|
+
for (const isolate of ['false', 'true']) {
|
|
24
|
+
it(`names a createNodes failure and its cause for nx ${command[0]} (isolated plugins: ${isolate})`, async () => {
|
|
25
|
+
await withNxFixture('nx-graph-errors-', async ({ workspace, socketDirectory }) => {
|
|
26
|
+
await symlink(join(repositoryRoot, 'node_modules'), join(workspace, 'node_modules'), 'dir');
|
|
27
|
+
await writeFile(join(workspace, 'package.json'), JSON.stringify({ name: 'graph-errors', private: true }));
|
|
28
|
+
await mkdir(join(workspace, 'packages/app'), { recursive: true });
|
|
29
|
+
await writeFile(
|
|
30
|
+
join(workspace, 'packages/app/package.json'),
|
|
31
|
+
JSON.stringify({ name: 'app', scripts: { build: 'true' } }),
|
|
32
|
+
);
|
|
33
|
+
const plugin = join(workspace, 'failure.cjs');
|
|
34
|
+
await writeFile(
|
|
35
|
+
plugin,
|
|
36
|
+
`exports.createNodes = ['**/package.json', () => {
|
|
37
|
+
throw new Error(${JSON.stringify(FAILURE)}, { cause: new Error(${JSON.stringify(CAUSE)}) });
|
|
38
|
+
}];
|
|
39
|
+
`,
|
|
40
|
+
);
|
|
41
|
+
await writeFile(join(workspace, 'nx.json'), JSON.stringify({ plugins: [plugin] }));
|
|
42
|
+
const run = (verbose: boolean) => {
|
|
43
|
+
const env = { ...fixtureNxEnv(workspace, socketDirectory), NX_ISOLATE_PLUGINS: isolate };
|
|
44
|
+
const ran = spawnSync('bun', [nxEntry, ...command], {
|
|
45
|
+
cwd: workspace,
|
|
46
|
+
env: verbose ? { ...env, NX_VERBOSE_LOGGING: 'true' } : env,
|
|
47
|
+
encoding: 'utf8',
|
|
48
|
+
});
|
|
49
|
+
return { status: ran.status, output: `${ran.stdout}${ran.stderr}` };
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const quiet = run(false);
|
|
53
|
+
expect(quiet.status, quiet.output).toBe(1);
|
|
54
|
+
expect(quiet.output).toContain('Failed to process project graph.');
|
|
55
|
+
expect(quiet.output).toContain(FAILURE);
|
|
56
|
+
expect(quiet.output).toContain(`Caused by: ${CAUSE}`);
|
|
57
|
+
expect(quiet.output).toContain('Pass --verbose to see the stacktraces.');
|
|
58
|
+
expect(quiet.output).not.toMatch(STACK_FRAME);
|
|
59
|
+
|
|
60
|
+
// Verbose keeps the stack frames and the cause chain. Stack text is the runtime's own: under Bun an
|
|
61
|
+
// in-process plugin error's stack (its cause's too) can read as a bare `Error`, so naming the messages is the
|
|
62
|
+
// non-verbose body's job, asserted above for every command and isolation mode.
|
|
63
|
+
const verbose = run(true);
|
|
64
|
+
expect(verbose.status, verbose.output).toBe(1);
|
|
65
|
+
expect(verbose.output).toContain('Caused by:');
|
|
66
|
+
expect(verbose.output).toMatch(STACK_FRAME);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -66,7 +66,7 @@ it('exits 1, not 130, when a failed task leaves a task that depends on it unrun'
|
|
|
66
66
|
expect(JSON.parse(await readFile(join(workspace, 'task-results.json'), 'utf8'))).toEqual({ 'p:fail': 'failure' });
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
}
|
|
69
|
+
});
|
|
70
70
|
|
|
71
71
|
it('distinguishes parallel failure bailout from a real interrupt with pending tasks', async () => {
|
|
72
72
|
for (const interrupt of [false, true]) {
|
|
@@ -177,4 +177,4 @@ if (existsSync(wanted)) { watcher.close(); process.exit(1); }
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
}
|
|
180
|
+
});
|
|
@@ -5,7 +5,6 @@ import { createRequire } from 'node:module';
|
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { resolveFromWorkspace } from 'nx/src/utils/installation-directory.js';
|
|
7
7
|
import { readModulePackageJson } from 'nx/src/utils/package-json.js';
|
|
8
|
-
import { guardEvent } from './__tests__/counted-cargo.js';
|
|
9
8
|
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -58,7 +57,6 @@ it('keeps the source-import edges of the installed Nx, resolving typescript from
|
|
|
58
57
|
const child = spawn('node', [join(nx, 'dist/bin/nx.js'), 'graph', `--file=${graphFile}`], {
|
|
59
58
|
cwd: root,
|
|
60
59
|
env: fixtureNxEnv(root, socketDirectory),
|
|
61
|
-
detached: process.platform !== 'win32',
|
|
62
60
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
63
61
|
});
|
|
64
62
|
let output = '';
|
|
@@ -68,29 +66,13 @@ it('keeps the source-import edges of the installed Nx, resolving typescript from
|
|
|
68
66
|
child.stderr?.setEncoding('utf8').on('data', (text: string) => {
|
|
69
67
|
output += text;
|
|
70
68
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'nx graph to close',
|
|
79
|
-
() => `pid ${child.pid}, exit ${child.exitCode}, signal ${child.signalCode}\n${output}`,
|
|
80
|
-
);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (child.pid !== undefined && child.exitCode === null && child.signalCode === null) {
|
|
83
|
-
try {
|
|
84
|
-
process.kill(process.platform === 'win32' ? child.pid : -child.pid, 'SIGKILL');
|
|
85
|
-
} catch (killError) {
|
|
86
|
-
if (!(killError instanceof Error && 'code' in killError && killError.code === 'ESRCH')) {
|
|
87
|
-
throw new AggregateError([error, killError], 'could not retire the failed fixture Nx command');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
await ended.catch(() => undefined);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
69
|
+
// The test waits for what it needs, the command's close, however long a loaded host makes the real Nx take: a
|
|
70
|
+
// deadline here measured the host, not the resolution (a 15 s guard failed a land gate at load 20 with the command
|
|
71
|
+
// still running). A command that never closes is the runner's idle-hang backstop's to report.
|
|
72
|
+
const code = await new Promise<number | null>((resolve, reject) => {
|
|
73
|
+
child.once('error', reject);
|
|
74
|
+
child.once('close', resolve);
|
|
75
|
+
});
|
|
94
76
|
expect(code, output).toBe(0);
|
|
95
77
|
expect(JSON.parse(await readFile(graphFile, 'utf8'))).toMatchObject({
|
|
96
78
|
graph: { dependencies: { b: [{ source: 'b', target: 'a', type: 'static' }] } },
|
|
@@ -186,7 +186,7 @@ it('leases a target across clients through producer completion, cache capture an
|
|
|
186
186
|
await Promise.all(children.map((child) => child.exited));
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
|
-
}
|
|
189
|
+
});
|
|
190
190
|
|
|
191
191
|
it('shares ownership across configurations without blocking independent targets, and cancels lock waiters', async () => {
|
|
192
192
|
const owner = new TaskOutputLeases(2, null, 'output');
|
|
@@ -287,7 +287,7 @@ it('refuses an ancestor-owned target before waiting for its output lease', async
|
|
|
287
287
|
await child.exited;
|
|
288
288
|
}
|
|
289
289
|
});
|
|
290
|
-
}
|
|
290
|
+
});
|
|
291
291
|
|
|
292
292
|
it('shares one continuous producer between simultaneous cold clients without waiting for its lifetime lease', async () => {
|
|
293
293
|
await withNxFixture('nx-task-output-continuous-', async ({ workspace, socketDirectory }) => {
|
|
@@ -411,4 +411,4 @@ SharedRunningTask.prototype.waitForTaskToFinish = async function(...args) {
|
|
|
411
411
|
await Promise.all(children.map((child) => child.exited));
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
|
-
}
|
|
414
|
+
});
|
package/src/nx-use-local.test.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { expect, it } from 'bun:test';
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { chmod, mkdir, readFile, symlink, unlink, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { delimiter, join } from 'node:path';
|
|
5
|
-
import { guardEvent } from './__tests__/counted-cargo.js';
|
|
6
5
|
import { fixtureNxEnv, withNxFixture } from './__tests__/fixture-nx-env.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -32,10 +31,13 @@ async function run(
|
|
|
32
31
|
child.stderr?.setEncoding('utf8').on('data', (text: string) => {
|
|
33
32
|
output += text;
|
|
34
33
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const code = await
|
|
34
|
+
// The test waits for what it needs, the command's close, however long a loaded host makes the real Nx take: a
|
|
35
|
+
// deadline here measured the host, not the daemon's behaviour (a 15 s guard failed SB land gates at load 3 and 80
|
|
36
|
+
// with `oracle-control` still running). A command that never closes is the runner's idle-hang backstop's to report.
|
|
37
|
+
const code = await new Promise<number | null>((resolve, reject) => {
|
|
38
|
+
child.once('error', reject);
|
|
39
|
+
child.once('close', resolve);
|
|
40
|
+
});
|
|
39
41
|
expect(code, output).toBe(expectedCode);
|
|
40
42
|
return output;
|
|
41
43
|
}
|