@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
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
planDeclaredLinks,
|
|
34
34
|
reportDeveloperLinks,
|
|
35
35
|
reportUnavailableDeclaredLinks,
|
|
36
|
+
unreadableDeveloperLinks,
|
|
36
37
|
} from './developer-links.ts';
|
|
37
38
|
import {
|
|
38
39
|
type DeferredSecret,
|
|
@@ -205,7 +206,8 @@ const POST_COMMIT_BLOCK = [
|
|
|
205
206
|
// (cargoFetcher) live in smoo's user cache and count only while CARGO_HOME
|
|
206
207
|
// names the directory they were fetched into, which no checkout-relative
|
|
207
208
|
// change detection can see.
|
|
208
|
-
// `--links` repairs stale install links (including external Nx aliases
|
|
209
|
+
// `--links` repairs stale install links (including external Nx aliases and
|
|
210
|
+
// store links whose install-cache entry is gone), then
|
|
209
211
|
// points the packages `smoo.developerLinks` declares at their local checkouts.
|
|
210
212
|
// devenv's smoo:developer-links task uses `--links --check` as its status:
|
|
211
213
|
// links can change without any smoo:install input changing.
|
|
@@ -248,12 +250,20 @@ try {
|
|
|
248
250
|
// A refused or unclaimed snapshot is current only when said: the exec that follows names its cause.
|
|
249
251
|
const current =
|
|
250
252
|
plan.changes.length === 0 && plan.unavailable.every((unavailable) => unavailable.kind === 'absent');
|
|
251
|
-
process.exit(
|
|
253
|
+
process.exit(
|
|
254
|
+
current && !hasStaleDeveloperLinks(projectRoot, ['nx']) && danglingStoreLinks(projectRoot).length === 0 ? 0 : 1,
|
|
255
|
+
);
|
|
252
256
|
}
|
|
253
257
|
await withInstallLock(async () => {
|
|
254
258
|
// Recheck under the install lock: another shell may already have repaired
|
|
255
259
|
// the aliases. Use the same installer as smoo:install, never a second linker.
|
|
256
|
-
|
|
260
|
+
const store = danglingStoreLinks(projectRoot);
|
|
261
|
+
for (const link of store) {
|
|
262
|
+
console.error(
|
|
263
|
+
`! ${link} -> ${readlinkSync(link)}: that Bun install-cache entry no longer exists; reinstalling`,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
if (store.length > 0 || hasStaleDeveloperLinks(projectRoot, ['nx'])) {
|
|
257
267
|
const error = await installLocalDependencies([bunInstaller(bunInstallInputs())]);
|
|
258
268
|
if (error !== undefined) reportSetupFailure(error);
|
|
259
269
|
ensureTypeScriptApiPackage(projectRoot);
|
|
@@ -907,6 +917,9 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
907
917
|
let actualPath = store;
|
|
908
918
|
let expectedTarget = store;
|
|
909
919
|
let operation: BunInstallIntegrityOperation = 'inspect isolated store';
|
|
920
|
+
// Developer links whose target this process may not read (developer-links.ts): the install
|
|
921
|
+
// did not make them and nothing here can read what they name, so they are not admitted here.
|
|
922
|
+
let unreadable: ReadonlySet<string> = new Set();
|
|
910
923
|
|
|
911
924
|
const select = (candidate: string, symbolicLink: boolean): void => {
|
|
912
925
|
actualPath = candidate;
|
|
@@ -920,6 +933,7 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
920
933
|
realpathSync(candidate);
|
|
921
934
|
};
|
|
922
935
|
const manifest = (candidate: string, symbolicLink: boolean): void => {
|
|
936
|
+
if (unreadable.has(candidate)) return;
|
|
923
937
|
select(candidate, symbolicLink);
|
|
924
938
|
operation = 'read installed package manifest';
|
|
925
939
|
JSON.parse(readFileSync(path.join(candidate, 'package.json'), 'utf8'));
|
|
@@ -952,6 +966,7 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
952
966
|
// at. Same package and version alone is never reachability proof.
|
|
953
967
|
const identityOf = (name: string): string | null => /^(.+@\d[^+]*)(\+.*)?$/.exec(name)?.[1] ?? null;
|
|
954
968
|
try {
|
|
969
|
+
unreadable = new Set(unreadableDeveloperLinks(root));
|
|
955
970
|
const state = lstatSync(store, { throwIfNoEntry: false });
|
|
956
971
|
// A hoisted install has no isolated store to admit.
|
|
957
972
|
if (state === undefined) return undefined;
|
|
@@ -964,112 +979,8 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
964
979
|
const identity = identityOf(entry.name) ?? entry.name;
|
|
965
980
|
identityCounts.set(identity, (identityCounts.get(identity) ?? 0) + 1);
|
|
966
981
|
}
|
|
967
|
-
|
|
968
|
-
const referenced =
|
|
969
|
-
const knownEntries = new Set(entries.filter((entry) => entry.name !== 'node_modules').map((entry) => entry.name));
|
|
970
|
-
// Where each store entry actually lives: a link can reach an entry through its install
|
|
971
|
-
// cache target (whose basename carries a cache suffix the entry name does not), so live
|
|
972
|
-
// reachability is also containment inside an entry's real directory, not name matching.
|
|
973
|
-
const entryReals = new Map<string, string>();
|
|
974
|
-
for (const entry of entries) {
|
|
975
|
-
if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
|
|
976
|
-
try {
|
|
977
|
-
entryReals.set(entry.name, realpathSync(path.join(store, entry.name)));
|
|
978
|
-
} catch {
|
|
979
|
-
// A dangling entry has no real directory for a live alias to land inside.
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
const scanLinks = (dir: string, owner: string | null): void => {
|
|
983
|
-
let children: Dirent[];
|
|
984
|
-
try {
|
|
985
|
-
children = readdirSync(dir, { withFileTypes: true });
|
|
986
|
-
} catch {
|
|
987
|
-
return;
|
|
988
|
-
}
|
|
989
|
-
for (const child of children) {
|
|
990
|
-
if (child.name.startsWith('.')) continue;
|
|
991
|
-
const childPath = path.join(dir, child.name);
|
|
992
|
-
if (child.name.startsWith('@')) {
|
|
993
|
-
// A scope is a namespace, symlinked or not: traverse it, never treat it as a package.
|
|
994
|
-
let isDirectory = false;
|
|
995
|
-
try {
|
|
996
|
-
isDirectory = statSync(childPath).isDirectory();
|
|
997
|
-
} catch {
|
|
998
|
-
isDirectory = false;
|
|
999
|
-
}
|
|
1000
|
-
if (isDirectory) {
|
|
1001
|
-
scanLinks(childPath, owner);
|
|
1002
|
-
continue;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
if (!child.isSymbolicLink()) continue;
|
|
1006
|
-
let target: string;
|
|
1007
|
-
try {
|
|
1008
|
-
target = readlinkSync(childPath);
|
|
1009
|
-
} catch {
|
|
1010
|
-
continue;
|
|
1011
|
-
}
|
|
1012
|
-
// The alias's canonical endpoint is what it actually reaches — through intermediate
|
|
1013
|
-
// symlinks as well as its literal target — and is what select() already witnesses.
|
|
1014
|
-
// A dangling alias has no endpoint; fall back to resolving its literal target
|
|
1015
|
-
// against the physical parent, so a live reference to a broken entry still marks
|
|
1016
|
-
// that entry referenced.
|
|
1017
|
-
let physicalDir = path.dirname(childPath);
|
|
1018
|
-
try {
|
|
1019
|
-
physicalDir = realpathSync(physicalDir);
|
|
1020
|
-
} catch {
|
|
1021
|
-
// Keep the lexical parent; the segment mark below still applies.
|
|
1022
|
-
}
|
|
1023
|
-
let endpoint: string | null = null;
|
|
1024
|
-
try {
|
|
1025
|
-
endpoint = realpathSync(childPath);
|
|
1026
|
-
} catch {
|
|
1027
|
-
endpoint = null;
|
|
1028
|
-
}
|
|
1029
|
-
const resolved = endpoint ?? path.resolve(physicalDir, target);
|
|
1030
|
-
if (endpoint !== null) {
|
|
1031
|
-
// The canonical endpoint is authoritative: the entry whose real directory
|
|
1032
|
-
// contains it is the live target, whatever any path segment happens to name.
|
|
1033
|
-
for (const [name, real] of entryReals) {
|
|
1034
|
-
if (name !== owner && (endpoint === real || endpoint.startsWith(`${real}${path.sep}`))) {
|
|
1035
|
-
referenced.add(name);
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
} else {
|
|
1040
|
-
for (const segment of resolved.split(path.sep)) {
|
|
1041
|
-
if (knownEntries.has(segment) && segment !== owner) {
|
|
1042
|
-
referenced.add(segment);
|
|
1043
|
-
break;
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
};
|
|
1049
|
-
scanLinks(path.join(root, 'node_modules'), null);
|
|
1050
|
-
scanLinks(path.join(store, 'node_modules'), null);
|
|
1051
|
-
// Workspace members keep their own node_modules beside their manifests; links there are
|
|
1052
|
-
// as live as root links, so the closure starts from them too. The enumeration is the one
|
|
1053
|
-
// bunInstallInputs owns: both workspace forms, full glob patterns, exclusions.
|
|
1054
|
-
const rootManifest = parseOrUndefined(() => JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')));
|
|
1055
|
-
const workspaces = field(rootManifest, 'workspaces');
|
|
1056
|
-
const memberPatterns = Array.isArray(workspaces)
|
|
1057
|
-
? stringList(workspaces)
|
|
1058
|
-
: stringList(field(workspaces, 'packages'));
|
|
1059
|
-
for (const manifestPath of workspaceFiles(memberPatterns, 'package.json')) {
|
|
1060
|
-
scanLinks(path.join(root, path.dirname(manifestPath), 'node_modules'), null);
|
|
1061
|
-
}
|
|
1062
|
-
let grew = true;
|
|
1063
|
-
while (grew) {
|
|
1064
|
-
grew = false;
|
|
1065
|
-
for (const entry of entries) {
|
|
1066
|
-
if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
|
|
1067
|
-
if (!referenced.has(entry.name)) continue;
|
|
1068
|
-
const before = referenced.size;
|
|
1069
|
-
scanLinks(path.join(store, entry.name, 'node_modules'), entry.name);
|
|
1070
|
-
if (referenced.size > before) grew = true;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
982
|
+
const members = workspaceMemberModules(root);
|
|
983
|
+
const referenced = referencedStoreEntries(root, store, entries, members);
|
|
1073
984
|
// Package aliases are what every consumer actually resolves: each package they name must
|
|
1074
985
|
// resolve to a readable manifest, wherever it points — into the store, into the install
|
|
1075
986
|
// cache, or at a workspace member. The same strict walk applies at the root and in every
|
|
@@ -1099,11 +1010,10 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
1099
1010
|
}
|
|
1100
1011
|
};
|
|
1101
1012
|
walkPackageAliases(path.join(root, 'node_modules'));
|
|
1102
|
-
for (const
|
|
1103
|
-
const memberModules = path.join(root, path.dirname(manifestPath), 'node_modules');
|
|
1013
|
+
for (const modules of members) {
|
|
1104
1014
|
// A member with nothing installed has no aliases to validate; a present directory is
|
|
1105
1015
|
// walked with the root's strictness.
|
|
1106
|
-
if (existsSync(
|
|
1016
|
+
if (existsSync(modules)) walkPackageAliases(modules);
|
|
1107
1017
|
}
|
|
1108
1018
|
for (const entry of entries) {
|
|
1109
1019
|
const candidate = path.join(store, entry.name);
|
|
@@ -1125,6 +1035,157 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
1125
1035
|
}
|
|
1126
1036
|
}
|
|
1127
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* The store entries the installed tree reaches. Every link in the root's node_modules, the
|
|
1040
|
+
* store's own and each workspace member's that resolves into an entry makes that entry live,
|
|
1041
|
+
* and so does every link in a live entry's own node_modules, to a fixed point. Member links
|
|
1042
|
+
* are as live as root links.
|
|
1043
|
+
*/
|
|
1044
|
+
function referencedStoreEntries(
|
|
1045
|
+
root: string,
|
|
1046
|
+
store: string,
|
|
1047
|
+
entries: readonly Dirent[],
|
|
1048
|
+
members: readonly string[],
|
|
1049
|
+
): Set<string> {
|
|
1050
|
+
const referenced = new Set<string>();
|
|
1051
|
+
const knownEntries = new Set(entries.filter((entry) => entry.name !== 'node_modules').map((entry) => entry.name));
|
|
1052
|
+
// Where each store entry actually lives: a link can reach an entry through its install
|
|
1053
|
+
// cache target (whose basename carries a cache suffix the entry name does not), so live
|
|
1054
|
+
// reachability is also containment inside an entry's real directory, not name matching.
|
|
1055
|
+
const entryReals = new Map<string, string>();
|
|
1056
|
+
for (const entry of entries) {
|
|
1057
|
+
if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
|
|
1058
|
+
try {
|
|
1059
|
+
entryReals.set(entry.name, realpathSync(path.join(store, entry.name)));
|
|
1060
|
+
} catch {
|
|
1061
|
+
// A dangling entry has no real directory for a live alias to land inside.
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
const scanLinks = (dir: string, owner: string | null): void => {
|
|
1065
|
+
let children: Dirent[];
|
|
1066
|
+
try {
|
|
1067
|
+
children = readdirSync(dir, { withFileTypes: true });
|
|
1068
|
+
} catch {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
for (const child of children) {
|
|
1072
|
+
if (child.name.startsWith('.')) continue;
|
|
1073
|
+
const childPath = path.join(dir, child.name);
|
|
1074
|
+
if (child.name.startsWith('@')) {
|
|
1075
|
+
// A scope is a namespace, symlinked or not: traverse it, never treat it as a package.
|
|
1076
|
+
let isDirectory = false;
|
|
1077
|
+
try {
|
|
1078
|
+
isDirectory = statSync(childPath).isDirectory();
|
|
1079
|
+
} catch {
|
|
1080
|
+
isDirectory = false;
|
|
1081
|
+
}
|
|
1082
|
+
if (isDirectory) {
|
|
1083
|
+
scanLinks(childPath, owner);
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (!child.isSymbolicLink()) continue;
|
|
1088
|
+
let target: string;
|
|
1089
|
+
try {
|
|
1090
|
+
target = readlinkSync(childPath);
|
|
1091
|
+
} catch {
|
|
1092
|
+
continue;
|
|
1093
|
+
}
|
|
1094
|
+
// The alias's canonical endpoint is what it actually reaches — through intermediate
|
|
1095
|
+
// symlinks as well as its literal target — and is what select() already witnesses.
|
|
1096
|
+
// A dangling alias has no endpoint; fall back to resolving its literal target
|
|
1097
|
+
// against the physical parent, so a live reference to a broken entry still marks
|
|
1098
|
+
// that entry referenced.
|
|
1099
|
+
let physicalDir = path.dirname(childPath);
|
|
1100
|
+
try {
|
|
1101
|
+
physicalDir = realpathSync(physicalDir);
|
|
1102
|
+
} catch {
|
|
1103
|
+
// Keep the lexical parent; the segment mark below still applies.
|
|
1104
|
+
}
|
|
1105
|
+
let endpoint: string | null = null;
|
|
1106
|
+
try {
|
|
1107
|
+
endpoint = realpathSync(childPath);
|
|
1108
|
+
} catch {
|
|
1109
|
+
endpoint = null;
|
|
1110
|
+
}
|
|
1111
|
+
const resolved = endpoint ?? path.resolve(physicalDir, target);
|
|
1112
|
+
if (endpoint !== null) {
|
|
1113
|
+
// The canonical endpoint is authoritative: the entry whose real directory
|
|
1114
|
+
// contains it is the live target, whatever any path segment happens to name.
|
|
1115
|
+
for (const [name, real] of entryReals) {
|
|
1116
|
+
if (name !== owner && (endpoint === real || endpoint.startsWith(`${real}${path.sep}`))) {
|
|
1117
|
+
referenced.add(name);
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
} else {
|
|
1122
|
+
for (const segment of resolved.split(path.sep)) {
|
|
1123
|
+
if (knownEntries.has(segment) && segment !== owner) {
|
|
1124
|
+
referenced.add(segment);
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
scanLinks(path.join(root, 'node_modules'), null);
|
|
1132
|
+
scanLinks(path.join(store, 'node_modules'), null);
|
|
1133
|
+
for (const modules of members) scanLinks(modules, null);
|
|
1134
|
+
let grew = true;
|
|
1135
|
+
while (grew) {
|
|
1136
|
+
grew = false;
|
|
1137
|
+
for (const entry of entries) {
|
|
1138
|
+
if (entry.name === 'node_modules' || !(entry.isDirectory() || entry.isSymbolicLink())) continue;
|
|
1139
|
+
if (!referenced.has(entry.name)) continue;
|
|
1140
|
+
const before = referenced.size;
|
|
1141
|
+
scanLinks(path.join(store, entry.name, 'node_modules'), entry.name);
|
|
1142
|
+
if (referenced.size > before) grew = true;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return referenced;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* The node_modules directory of every workspace member, beside its manifest. The enumeration
|
|
1150
|
+
* is the one bunInstallInputs owns: both workspace forms, full glob patterns, exclusions.
|
|
1151
|
+
*/
|
|
1152
|
+
function workspaceMemberModules(root: string): string[] {
|
|
1153
|
+
const rootManifest = parseOrUndefined(() => JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8')));
|
|
1154
|
+
const workspaces = field(rootManifest, 'workspaces');
|
|
1155
|
+
const memberPatterns = Array.isArray(workspaces) ? stringList(workspaces) : stringList(field(workspaces, 'packages'));
|
|
1156
|
+
return workspaceFiles(memberPatterns, 'package.json').map((manifestPath) =>
|
|
1157
|
+
path.join(root, path.dirname(manifestPath), 'node_modules'),
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* The store links the installed tree reaches whose target in Bun's install cache is gone. Under
|
|
1163
|
+
* `globalStore` each node_modules/.bun/<entry> is a link into that cache, and one that dangles
|
|
1164
|
+
* names a cache entry that no longer exists: the install is out of date, as it is while a
|
|
1165
|
+
* developer link dangles, and `bun install` links the entry again (measured, Bun 1.4.3). A
|
|
1166
|
+
* dangling variant nothing live reaches is superseded garbage the install leaves in place (see
|
|
1167
|
+
* verifyInstalledBunLinks), so it never makes the install stale: no install would change it.
|
|
1168
|
+
* The closure is walked only when some store link dangles.
|
|
1169
|
+
*/
|
|
1170
|
+
function danglingStoreLinks(root: string): string[] {
|
|
1171
|
+
const store = path.join(root, 'node_modules', '.bun');
|
|
1172
|
+
let entries: Dirent[];
|
|
1173
|
+
try {
|
|
1174
|
+
entries = readdirSync(store, { withFileTypes: true }).filter((entry) => !entry.name.startsWith('.'));
|
|
1175
|
+
} catch (error) {
|
|
1176
|
+
// A hoisted install, or none yet, has no store to link from.
|
|
1177
|
+
if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR')) return [];
|
|
1178
|
+
throw error;
|
|
1179
|
+
}
|
|
1180
|
+
const dangling = entries.filter(
|
|
1181
|
+
(entry) =>
|
|
1182
|
+
entry.isSymbolicLink() && statSync(path.join(store, entry.name), { throwIfNoEntry: false }) === undefined,
|
|
1183
|
+
);
|
|
1184
|
+
if (dangling.length === 0) return [];
|
|
1185
|
+
const referenced = referencedStoreEntries(root, store, entries, workspaceMemberModules(root));
|
|
1186
|
+
return dangling.filter((entry) => referenced.has(entry.name)).map((entry) => path.join(store, entry.name));
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1128
1189
|
/**
|
|
1129
1190
|
* `bun install`. Its result is location-independent: the isolated linker
|
|
1130
1191
|
* links packages from the install cache by absolute path and workspace
|
|
@@ -1135,7 +1196,10 @@ function verifyInstalledBunLinks(root: string): BunInstallIntegrityError | undef
|
|
|
1135
1196
|
* was pruned out from under node_modules. The native compiler binary ttsc
|
|
1136
1197
|
* runs is witnessed the same way when the manifest declares it: a pruned
|
|
1137
1198
|
* restore that kept the stamp and the API package but lost that binary
|
|
1138
|
-
* otherwise reads as current and no install ever repairs it. A dangling
|
|
1199
|
+
* otherwise reads as current and no install ever repairs it. A dangling
|
|
1200
|
+
* developer target, a live link to Nx, or a store link the installed tree
|
|
1201
|
+
* reaches whose install-cache entry is gone (danglingStoreLinks) also
|
|
1202
|
+
* invalidates a matching stamp.
|
|
1139
1203
|
*
|
|
1140
1204
|
* Frozen: shell entry installs what bun.lock records and never rewrites it. An unfrozen install migrated a
|
|
1141
1205
|
* repository's lockfile format and re-resolved its ranges, a lockfile diff nobody asked for. A manifest that needs a
|
|
@@ -1150,7 +1214,8 @@ function bunInstaller(inputs: readonly string[]): Installer {
|
|
|
1150
1214
|
findInstalledTypeScriptApiPackage(projectRoot) !== null &&
|
|
1151
1215
|
(!declaresNativeTypeScript(projectRoot) ||
|
|
1152
1216
|
existsSync(path.join(projectRoot, 'node_modules', '@typescript', 'native', 'bin', 'tsc'))) &&
|
|
1153
|
-
!hasStaleDeveloperLinks(projectRoot, ['nx'])
|
|
1217
|
+
!hasStaleDeveloperLinks(projectRoot, ['nx']) &&
|
|
1218
|
+
danglingStoreLinks(projectRoot).length === 0,
|
|
1154
1219
|
install: async ({ quiet }) => {
|
|
1155
1220
|
await keepDeveloperLinks(
|
|
1156
1221
|
projectRoot,
|
|
@@ -17,3 +17,12 @@ runs:
|
|
|
17
17
|
key: ${{ runner.os }}-${{ runner.arch }}-node-v2-{{NODE_MODULES_CACHE_KEY}}
|
|
18
18
|
restore-keys: |
|
|
19
19
|
${{ runner.os }}-${{ runner.arch }}-node-v2-
|
|
20
|
+
|
|
21
|
+
# The archive holds node_modules/.smoo-install, the stamp devenv's smoo:install watches, but not the
|
|
22
|
+
# workspace members' own node_modules links. A restored tree is a seed: only an install in this
|
|
23
|
+
# checkout may claim it current. A `!node_modules/.smoo-install` path cannot do this: actions/cache
|
|
24
|
+
# archives a listed directory whole and drops excludes inside it (actions/toolkit#713), so Publish
|
|
25
|
+
# run 39143439571 still restored the stamp and skipped the install.
|
|
26
|
+
- name: Drop the restored install stamp
|
|
27
|
+
shell: bash
|
|
28
|
+
run: rm -f node_modules/.smoo-install
|
|
@@ -159,6 +159,46 @@ runs:
|
|
|
159
159
|
shell: bash
|
|
160
160
|
run: echo "DEVENV_WORKDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
|
|
161
161
|
|
|
162
|
+
# GitHub's hosted Ubuntu images promise only 14 GB free and fill the rest of
|
|
163
|
+
# the disk with toolchains a Nix-built shell never uses. The store can need
|
|
164
|
+
# more: the largest measured is 17.1 GB unpacked, and a restore or save also
|
|
165
|
+
# holds its 4.9 GB archive in RUNNER_TEMP. A 2-vCPU runner ran out of disk
|
|
166
|
+
# with about 15 GB of store on it, and nothing had printed free space.
|
|
167
|
+
# Delete those trees, most GiB per second first, until / has 32 GiB free.
|
|
168
|
+
# That is an estimate: the store at its peak with its archive, node_modules
|
|
169
|
+
# and build scratch, plus a few GiB of margin; the df lines record what a
|
|
170
|
+
# run really had. A runner that already has it deletes nothing, and the
|
|
171
|
+
# Android SDK, which alone takes minutes to delete, goes only when the rest
|
|
172
|
+
# was not enough.
|
|
173
|
+
# What goes stays gone for the rest of the job: a later actions/setup-*
|
|
174
|
+
# step downloads its runtime instead of finding it in the tool cache, a
|
|
175
|
+
# pwsh step loses the image's PowerShell modules (pwsh itself stays), and
|
|
176
|
+
# a step that runs the image's .NET, GHCup, Swift or Android SDK directly
|
|
177
|
+
# fails. Only a runner that started short of space deletes anything, so
|
|
178
|
+
# such a step would fail on some runs and pass on others.
|
|
179
|
+
# Synchronous on purpose: a background rm would race the store extraction
|
|
180
|
+
# for space and disk I/O. A failed delete warns and the job goes on: this
|
|
181
|
+
# is an optimisation, never a gate. Self-hosted machines keep everything.
|
|
182
|
+
- name: 🧹 Free runner disk
|
|
183
|
+
if: steps.runner-kind.outputs.host != 'true' && runner.os == 'Linux' && runner.environment == 'github-hosted'
|
|
184
|
+
shell: bash
|
|
185
|
+
run: |
|
|
186
|
+
want_kib=$((32 * 1024 * 1024))
|
|
187
|
+
free_kib() { df -k --output=avail / | tail -n 1 | tr -d ' '; }
|
|
188
|
+
df -h /
|
|
189
|
+
for dir in /usr/share/swift /usr/local/share/powershell /usr/local/.ghcup \
|
|
190
|
+
/usr/share/dotnet "${AGENT_TOOLSDIRECTORY:-}" /usr/local/lib/android; do
|
|
191
|
+
[ "$(free_kib)" -lt "$want_kib" ] || break
|
|
192
|
+
[ -n "$dir" ] && [ -d "$dir" ] || continue
|
|
193
|
+
start=$SECONDS
|
|
194
|
+
if sudo rm -rf "$dir"; then
|
|
195
|
+
echo "removed $dir in $((SECONDS - start)) s"
|
|
196
|
+
else
|
|
197
|
+
echo "::warning::could not remove $dir; going on without its space"
|
|
198
|
+
fi
|
|
199
|
+
done
|
|
200
|
+
df -h /
|
|
201
|
+
|
|
162
202
|
# Devenv segment (own key): tooling/direnv/.devenv + .direnv — includes
|
|
163
203
|
# nix-eval-cache.db. Independent of the store cache; restored on ephemeral
|
|
164
204
|
# runners whether or not the store cache hit. Missing store paths are fine:
|
|
@@ -207,6 +247,20 @@ runs:
|
|
|
207
247
|
# arrives inside /nix, so install-devenv's `nix profile add` of the locked
|
|
208
248
|
# rev is a link rather than a download, and the devenv in play is the one
|
|
209
249
|
# devenv.lock names instead of whichever run last populated the prefix.
|
|
250
|
+
#
|
|
251
|
+
# The key is two hashes: the pins (devenv.lock, devenv.yaml), then the files
|
|
252
|
+
# that choose and override packages on top of them (devenv.nix,
|
|
253
|
+
# devenv.smoo.nix, the nixpkgs overlay). The restore prefix ends after the
|
|
254
|
+
# pins, so a miss falls back only to a store saved from the same pins. Once
|
|
255
|
+
# nixpkgs or devenv moved, a store built from other pins is mostly dead
|
|
256
|
+
# weight that still costs its full unpacked size: measured, a pull request
|
|
257
|
+
# whose pins differed from the default branch's restored 7.55 GB, then
|
|
258
|
+
# fetched the same 1319 paths as a cold run, and the runner ran out of
|
|
259
|
+
# disk. The overlay is hashed itself because devenv.lock locks it as a
|
|
260
|
+
# relative path with no narHash: an overlay edit moved neither the lock nor
|
|
261
|
+
# the key, so every later run got an exact hit on a stale store that was
|
|
262
|
+
# never saved again. nix-v7 keeps the bare nix-v6- prefix of the old layout
|
|
263
|
+
# from restoring a store saved under this one.
|
|
210
264
|
- name: 🧊 Cache Nix store
|
|
211
265
|
id: nix-cache
|
|
212
266
|
if: steps.runner-kind.outputs.host != 'true'
|
|
@@ -216,8 +270,9 @@ runs:
|
|
|
216
270
|
/nix
|
|
217
271
|
~/.cache/nix
|
|
218
272
|
# prettier-ignore
|
|
219
|
-
primary-key: ${{ runner.os }}-${{ runner.arch }}-nix-
|
|
220
|
-
|
|
273
|
+
primary-key: ${{ runner.os }}-${{ runner.arch }}-nix-v7-${{ hashFiles('tooling/direnv/devenv.lock', 'tooling/direnv/devenv.yaml') }}-${{ hashFiles('tooling/direnv/devenv.nix', 'tooling/direnv/devenv.smoo.nix', 'tooling/direnv/nixpkgs-overlay/**') }}
|
|
274
|
+
# prettier-ignore
|
|
275
|
+
restore-prefixes-first-match: ${{ runner.os }}-${{ runner.arch }}-nix-v7-${{ hashFiles('tooling/direnv/devenv.lock', 'tooling/direnv/devenv.yaml') }}-
|
|
221
276
|
gc-max-store-size: 1G
|
|
222
277
|
|
|
223
278
|
# cache-nix-action unpacks through sudo, so the directory it creates on the
|
|
@@ -245,11 +300,12 @@ runs:
|
|
|
245
300
|
name: devenv
|
|
246
301
|
|
|
247
302
|
# A host runner's devenv belongs to its image, so install-devenv accepts
|
|
248
|
-
# whatever is on PATH there. On an ephemeral runner
|
|
249
|
-
#
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
#
|
|
303
|
+
# whatever is on PATH there. On an ephemeral runner it is held to
|
|
304
|
+
# devenv.lock's rev. The store cache once restored ~/.nix-profile, and a
|
|
305
|
+
# prefix match handed the job the CLI of whichever run last populated the
|
|
306
|
+
# key, which outlived a lock bump until the check existed. It now restores
|
|
307
|
+
# no profiles, and only a store saved from the same pins (devenv.lock,
|
|
308
|
+
# devenv.yaml).
|
|
253
309
|
- name: 🧰 Install devenv
|
|
254
310
|
shell: bash
|
|
255
311
|
working-directory: ${{ env.DEVENV_WORKDIR }}/tooling/direnv
|
package/nextest.toml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Injected by @smoothbricks/nx-plugin as `--config-file` on inferred cargo-test
|
|
2
|
-
# package targets. `period`
|
|
2
|
+
# package targets. A 30 s `period` names a slow test early. A slow-timeout here
|
|
3
3
|
# only warns: nextest prints a `SLOW` line naming the test every period, and
|
|
4
4
|
# never kills it. The run's no-progress bound (`idleTimeoutMs`, README "Bounded
|
|
5
5
|
# Test Targets") ends a test that never returns, and names it from those lines.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -68,6 +68,11 @@
|
|
|
68
68
|
"import": "./dist/test-timings.js",
|
|
69
69
|
"default": "./dist/test-timings.js"
|
|
70
70
|
},
|
|
71
|
+
"./graph-input-contract": {
|
|
72
|
+
"types": "./dist/graph-input-contract.d.ts",
|
|
73
|
+
"import": "./dist/graph-input-contract.js",
|
|
74
|
+
"default": "./dist/graph-input-contract.js"
|
|
75
|
+
},
|
|
71
76
|
"./ensure-built": {
|
|
72
77
|
"types": "./dist/ensure-built.d.ts",
|
|
73
78
|
"import": "./dist/ensure-built.js",
|
|
@@ -203,7 +208,7 @@
|
|
|
203
208
|
"test-shard1": {
|
|
204
209
|
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
205
210
|
"options": {
|
|
206
|
-
"command": "bun test --timeout=
|
|
211
|
+
"command": "bun test --timeout=0 --timings=test-timings.json --shard=1/4 --path-ignore-patterns='**/*-host.test.ts'",
|
|
207
212
|
"cwd": "{projectRoot}",
|
|
208
213
|
"idleTimeoutMs": 180000,
|
|
209
214
|
"killAfterMs": 10000
|
|
@@ -212,7 +217,7 @@
|
|
|
212
217
|
"test-shard2": {
|
|
213
218
|
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
214
219
|
"options": {
|
|
215
|
-
"command": "bun test --timeout=
|
|
220
|
+
"command": "bun test --timeout=0 --timings=test-timings.json --shard=2/4 --path-ignore-patterns='**/*-host.test.ts'",
|
|
216
221
|
"cwd": "{projectRoot}",
|
|
217
222
|
"idleTimeoutMs": 180000,
|
|
218
223
|
"killAfterMs": 10000
|
|
@@ -221,7 +226,7 @@
|
|
|
221
226
|
"test-shard3": {
|
|
222
227
|
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
223
228
|
"options": {
|
|
224
|
-
"command": "bun test --timeout=
|
|
229
|
+
"command": "bun test --timeout=0 --timings=test-timings.json --shard=3/4 --path-ignore-patterns='**/*-host.test.ts'",
|
|
225
230
|
"cwd": "{projectRoot}",
|
|
226
231
|
"idleTimeoutMs": 180000,
|
|
227
232
|
"killAfterMs": 10000
|
|
@@ -230,7 +235,7 @@
|
|
|
230
235
|
"test-shard4": {
|
|
231
236
|
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
232
237
|
"options": {
|
|
233
|
-
"command": "bun test --timeout=
|
|
238
|
+
"command": "bun test --timeout=0 --timings=test-timings.json --shard=4/4 --path-ignore-patterns='**/*-host.test.ts'",
|
|
234
239
|
"cwd": "{projectRoot}",
|
|
235
240
|
"idleTimeoutMs": 180000,
|
|
236
241
|
"killAfterMs": 10000
|
|
@@ -247,7 +252,7 @@
|
|
|
247
252
|
}
|
|
248
253
|
],
|
|
249
254
|
"options": {
|
|
250
|
-
"command": "bun test --timeout=
|
|
255
|
+
"command": "bun test --timeout=0 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts",
|
|
251
256
|
"cwd": "{projectRoot}",
|
|
252
257
|
"env": {
|
|
253
258
|
"COWSHED_EXECUTABLE": "{workspaceRoot}/packages/cowshed/bin/cowshed"
|
|
@@ -42,6 +42,12 @@ const repositoryRoot = join(import.meta.dir, '../../../..');
|
|
|
42
42
|
* daemons of one workspace bind two paths. With the directory named, they bind
|
|
43
43
|
* one: a test whose subject is two daemons on two socket paths names a second
|
|
44
44
|
* directory for the second. Building the environment publishes nothing.
|
|
45
|
+
*
|
|
46
|
+
* NX_NATIVE_FILE_CACHE_DIRECTORY is the fixture's own too. Nx loads its native
|
|
47
|
+
* binding from a copy in that cache, by default `/tmp/.nx/<uid>/native-cache`,
|
|
48
|
+
* which every Nx on the host shares and any `nx reset` deletes. A load that loses
|
|
49
|
+
* that race falls back to Nx's WASI binding without a word, and fails later on
|
|
50
|
+
* what WASI lacks (`FileLock is not a constructor`, from a task output lease).
|
|
45
51
|
*/
|
|
46
52
|
export function fixtureNxEnv(workspace: string, socketDirectory: string): Record<string, string> {
|
|
47
53
|
const env: Record<string, string> = {};
|
|
@@ -59,6 +65,7 @@ export function fixtureNxEnv(workspace: string, socketDirectory: string): Record
|
|
|
59
65
|
NX_SOCKET_DIR: socketDirectory,
|
|
60
66
|
NX_WORKSPACE_DATA_DIRECTORY: join(workspace, '.nx/workspace-data'),
|
|
61
67
|
NX_CACHE_DIRECTORY: join(workspace, '.nx/cache'),
|
|
68
|
+
NX_NATIVE_FILE_CACHE_DIRECTORY: join(workspace, '.nx/native-file-cache'),
|
|
62
69
|
};
|
|
63
70
|
}
|
|
64
71
|
|