@smoothbricks/nx-plugin 0.4.21 โ 0.4.23
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 +95 -18
- package/dist/bin/smoo-nx-cargo-hash.js +32 -6
- package/dist/bin/smoo-nx-exec.js +35 -11
- package/dist/cargo-closure-input.d.ts +63 -0
- package/dist/cargo-closure-input.d.ts.map +1 -0
- package/dist/cargo-closure-input.js +197 -0
- package/dist/cargo-source-hash.d.ts +46 -2
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +238 -114
- package/dist/cross-check-policy.d.ts +14 -0
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +15 -1
- package/dist/ensure-built.d.ts +3 -2
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +33 -56
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +112 -76
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +12 -15
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +10 -0
- package/dist/managed-files/publish-workflow.d.ts.map +1 -1
- package/dist/managed-files/publish-workflow.js +12 -6
- package/dist/manifest-hash.d.ts.map +1 -1
- package/dist/manifest-hash.js +24 -30
- package/dist/package-target-policy.js +1 -1
- package/dist/platform-targets.d.ts +7 -0
- package/dist/platform-targets.d.ts.map +1 -1
- package/dist/platform-targets.js +7 -0
- package/dist/workspace-config-policy.d.ts +1 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +1 -1
- package/managed/raw/envrc +38 -1
- package/managed/raw/tooling/direnv/developer-links.ts +201 -0
- package/managed/raw/tooling/direnv/devenv.smoo.nix +75 -51
- package/managed/raw/tooling/direnv/secret-references.ts +3 -1
- package/managed/raw/tooling/direnv/setup-environment.ts +562 -78
- package/managed/raw/tooling/direnv/shared-caches.sh +53 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +22 -1
- package/managed/templates/github/workflows/managed-files.yml +4 -3
- package/nextest.toml +5 -5
- package/package.json +2 -2
- package/src/__tests__/fixture-nx-env.ts +31 -0
- package/src/__tests__/in-process-nx-index.ts +9 -0
- package/src/bin/smoo-nx-cargo-hash.ts +29 -9
- package/src/bin/smoo-nx-exec.ts +40 -11
- package/src/cargo-closure-input.test.ts +184 -0
- package/src/cargo-closure-input.ts +247 -0
- package/src/cargo-source-hash.test.ts +104 -10
- package/src/cargo-source-hash.ts +290 -37
- package/src/cross-check-policy.ts +15 -3
- package/src/ensure-built.test.ts +65 -5
- package/src/ensure-built.ts +40 -85
- package/src/index.test.ts +94 -53
- package/src/index.ts +164 -84
- package/src/managed-files/ci-workflow.ts +12 -15
- package/src/managed-files/files.ts +10 -0
- package/src/managed-files/generator.test.ts +29 -0
- package/src/managed-files/publish-workflow.ts +17 -6
- package/src/manifest-hash.test.ts +21 -1
- package/src/manifest-hash.ts +26 -29
- package/src/package-target-policy.ts +1 -1
- package/src/platform-targets.ts +8 -0
- package/src/workspace-config-policy.ts +6 -1
package/dist/ensure-built.js
CHANGED
|
@@ -92,7 +92,7 @@ export function unvouched(entries, verdicts) {
|
|
|
92
92
|
* on every invocation. So it never spawns the `nx` CLI: a native filesystem
|
|
93
93
|
* snapshot refreshes the daemon's inputs, the task hashes and on-disk output
|
|
94
94
|
* verification are daemon round-trips, and the cache lookup is a local SQLite
|
|
95
|
-
* read.
|
|
95
|
+
* read. Only a miss starts the workspace's `nx` CLI, to run the target.
|
|
96
96
|
*
|
|
97
97
|
* With the daemon disabled there is no probe to make โ hashing would have to
|
|
98
98
|
* build the project graph in this process, and no service holds the recorded
|
|
@@ -141,7 +141,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
141
141
|
// this explicit fallback path, which also lets a deliberately minimal
|
|
142
142
|
// checkout-local CLI stand in for Nx.
|
|
143
143
|
if (process.env.NX_DAEMON === 'false') {
|
|
144
|
-
return runViaCli(workspaceRoot, selector);
|
|
144
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
145
145
|
}
|
|
146
146
|
// Nx rejects daemon access when the client package's version differs from
|
|
147
147
|
// the workspace's running daemon. Resolve every runtime module from the
|
|
@@ -151,7 +151,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
151
151
|
bindWorkspaceRoot(workspaceRoot, requireNx);
|
|
152
152
|
const { daemonClient } = requireNx('nx/src/daemon/client/client');
|
|
153
153
|
if (!daemonClient.enabled()) {
|
|
154
|
-
return runViaCli(workspaceRoot, selector);
|
|
154
|
+
return runViaCli(workspaceRoot, selector, { kind: 'no-daemon', taskId: selectorTaskId(selector) });
|
|
155
155
|
}
|
|
156
156
|
// An outer Nx task exports its own cache-bypass setting to the process it
|
|
157
157
|
// launches. That setting describes the outer task, not the nested target:
|
|
@@ -199,32 +199,34 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
|
|
|
199
199
|
});
|
|
200
200
|
performance.mark('ensureBuilt:probe:start');
|
|
201
201
|
let reason;
|
|
202
|
-
const selectorTaskId = selector.configuration === undefined
|
|
203
|
-
? `${selector.project}:${selector.target}`
|
|
204
|
-
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
205
202
|
if (process.env.NX_SKIP_NX_CACHE === 'true' || process.env.NX_DISABLE_NX_CACHE === 'true') {
|
|
206
|
-
reason = { kind: 'cache-disabled', taskId: selectorTaskId };
|
|
203
|
+
reason = { kind: 'cache-disabled', taskId: selectorTaskId(selector) };
|
|
207
204
|
}
|
|
208
205
|
else if (inputsChanged) {
|
|
209
|
-
reason = { kind: 'stale-inputs', taskId: selectorTaskId };
|
|
206
|
+
reason = { kind: 'stale-inputs', taskId: selectorTaskId(selector) };
|
|
210
207
|
}
|
|
211
208
|
else {
|
|
212
209
|
reason = await probe(workspaceRoot, nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
|
|
213
210
|
}
|
|
214
211
|
performance.measure('ensureBuilt:probe', 'ensureBuilt:probe:start');
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
// The CLI runs the hooks around its own run, under its own id. This process
|
|
213
|
+
// ran none of the tasks, so it reports none for the id it opened.
|
|
214
|
+
const result = reason === null ? HIT : await runViaCli(workspaceRoot, selector, reason);
|
|
218
215
|
await hooks.runPostTasksExecution({
|
|
219
216
|
id: runId,
|
|
220
|
-
taskResults:
|
|
217
|
+
taskResults: NO_TASK_RESULTS,
|
|
221
218
|
workspaceRoot,
|
|
222
219
|
nxJsonConfiguration: nxJson,
|
|
223
220
|
argv: process.argv,
|
|
224
221
|
startTime,
|
|
225
222
|
endTime: Date.now(),
|
|
226
223
|
});
|
|
227
|
-
return
|
|
224
|
+
return result;
|
|
225
|
+
}
|
|
226
|
+
function selectorTaskId(selector) {
|
|
227
|
+
return selector.configuration === undefined
|
|
228
|
+
? `${selector.project}:${selector.target}`
|
|
229
|
+
: `${selector.project}:${selector.target}:${selector.configuration}`;
|
|
228
230
|
}
|
|
229
231
|
/**
|
|
230
232
|
* Nx computes `workspaceRoot` once, at module load, from
|
|
@@ -576,56 +578,31 @@ function firstMovedClaim(observed) {
|
|
|
576
578
|
function isSystemError(error) {
|
|
577
579
|
return error instanceof Error && 'code' in error && typeof error.code === 'string';
|
|
578
580
|
}
|
|
579
|
-
async function runTarget(nxJson, nxArgs, overrides, selector, reason, requireNx) {
|
|
580
|
-
const { runCommandForTasks } = requireNx('nx/src/tasks-runner/run-command');
|
|
581
|
-
const { createProjectGraphAsync } = requireNx('nx/src/project-graph/project-graph');
|
|
582
|
-
const { signalToCode } = requireNx('nx/src/utils/exit-codes');
|
|
583
|
-
// `runCommandForTasks` derives its own task graph and hashes, so the probe's
|
|
584
|
-
// work is not reusable. That duplication is one daemon round-trip on a path
|
|
585
|
-
// that is about to run a build.
|
|
586
|
-
const projectGraph = await createProjectGraphAsync();
|
|
587
|
-
const { taskResults, completed } = await runCommandForTasks([requireProject(projectGraph, selector.project)], projectGraph, { nxJson }, nxArgs, overrides, selector.project, {}, { excludeTaskDependencies: false, loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false' });
|
|
588
|
-
if (!completed) {
|
|
589
|
-
// Nx's own encoding of an interrupted run: `runCommand` reports
|
|
590
|
-
// `signalToCode('SIGINT')` here. The runner does not surface which signal
|
|
591
|
-
// actually arrived, so there is none to forward โ only the code Nx's CLI
|
|
592
|
-
// would have exited with.
|
|
593
|
-
return {
|
|
594
|
-
result: { disposition: 'failed', reason, exitCode: signalToCode('SIGINT'), signal: null },
|
|
595
|
-
taskResults,
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
for (const taskResult of Object.values(taskResults)) {
|
|
599
|
-
if (taskResult.status === 'failure' || taskResult.status === 'skipped') {
|
|
600
|
-
return { result: { disposition: 'failed', reason, exitCode: 1, signal: null }, taskResults };
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return { result: { disposition: 'built', reason }, taskResults };
|
|
604
|
-
}
|
|
605
581
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
582
|
+
* Run the target through the workspace's own `nx`, the invocation whose hashes
|
|
583
|
+
* the probe reproduces, with the child's stdout on this process's stderr.
|
|
608
584
|
*
|
|
609
|
-
*
|
|
585
|
+
* A child, because Nx does not only write through `process.stdout`: its Rust
|
|
586
|
+
* pseudo-terminal and the forked executors it starts with inherited stdio
|
|
587
|
+
* write task output straight to file descriptor 1, and Node cannot point that
|
|
588
|
+
* descriptor elsewhere in its own process. In a child it is simply stderr, so
|
|
589
|
+
* the stdout of a wrapper that goes on to exec a binary carries nothing but
|
|
590
|
+
* that binary's output (`<cli> list | jq` reads only data).
|
|
591
|
+
*
|
|
592
|
+
* Inheriting rather than piping is the other half. The wrapper this facility
|
|
610
593
|
* replaces piped Nx's output so it could read a cache marker out of the log and
|
|
611
594
|
* stay silent on a hit โ a text heuristic over ANSI-coloured, format-unstable
|
|
612
|
-
* output.
|
|
613
|
-
*
|
|
614
|
-
* child's exit status is forwarded verbatim.
|
|
595
|
+
* output. The probe already decided this is no hit, so the output is the run's
|
|
596
|
+
* own, and the child's exit status is forwarded verbatim.
|
|
615
597
|
*/
|
|
616
|
-
async function runViaCli(workspaceRoot, selector) {
|
|
598
|
+
async function runViaCli(workspaceRoot, selector, reason) {
|
|
617
599
|
const nxCli = join(workspaceRoot, 'node_modules', '.bin', 'nx');
|
|
618
600
|
if (!existsSync(nxCli)) {
|
|
619
|
-
throw new Error(`ensureBuilt:
|
|
620
|
-
}
|
|
621
|
-
const
|
|
622
|
-
const targetSpec = selector.configuration
|
|
623
|
-
? `${selector.project}:${selector.target}:${selector.configuration}`
|
|
624
|
-
: `${selector.project}:${selector.target}`;
|
|
625
|
-
const signalToCode = nxSignalToCode;
|
|
626
|
-
const child = spawn(nxCli, ['run', targetSpec, '--outputStyle=stream'], {
|
|
601
|
+
throw new Error(`ensureBuilt: ${describeMiss(reason)}, and ${nxCli} does not exist`);
|
|
602
|
+
}
|
|
603
|
+
const child = spawn(nxCli, ['run', selectorTaskId(selector), '--outputStyle=stream'], {
|
|
627
604
|
cwd: workspaceRoot,
|
|
628
|
-
stdio: 'inherit',
|
|
605
|
+
stdio: ['inherit', 2, 'inherit'],
|
|
629
606
|
});
|
|
630
607
|
// `Promise.withResolvers` would read better but needs lib es2024; this
|
|
631
608
|
// package inherits lib es2022 from tsconfig.base.json.
|
|
@@ -633,7 +610,7 @@ async function runViaCli(workspaceRoot, selector) {
|
|
|
633
610
|
child.once('error', reject);
|
|
634
611
|
child.once('exit', (code, signal) => settle({ code, signal }));
|
|
635
612
|
});
|
|
636
|
-
return cliExitOutcome(reason, exit,
|
|
613
|
+
return cliExitOutcome(reason, exit, nxSignalToCode);
|
|
637
614
|
}
|
|
638
615
|
function nxSignalToCode(signal) {
|
|
639
616
|
switch (signal) {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,0BAA0B,CAAC;AAalC,OAAO,EAKL,yBAAyB,EAa1B,MAAM,sBAAsB,CAAC;AAsB9B,OAAO,EAAE,yBAAyB,EAAE,CAAC;AAErC,gEAAgE;AAChE,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAqQlD,KAAK,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;AACxC,KAAK,gBAAgB,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1C,UAAU,YAAY;IACpB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,YAAY,EAAE,gBAAgB,CAAC;CAChC;AAmID,UAAU,oBAAqB,SAAQ,YAAY;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AA0CD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,oBAAoB,GAAG,MAAM,CAEhF;AA+XD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAEvG;AAED,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,13 @@ import { readJsonFile, } from 'nx/src/devkit-exports.js';
|
|
|
7
7
|
import { AggregateCreateNodesError } from 'nx/src/project-graph/error-types.js';
|
|
8
8
|
import { parse as parseToml } from 'smol-toml';
|
|
9
9
|
import { BOUNDED_TEST_KILL_AFTER_MS, BOUNDED_TEST_TIMEOUT_MS } from './bounded-test-policy.js';
|
|
10
|
+
import { CARGO_CLOSURE_INPUT, cargoClosureInputs, indexedCargoManifests, resolveCargoClosureSource, } from './cargo-closure-input.js';
|
|
10
11
|
import { CARGO_TOOLCHAIN_NAMED_INPUT, CARGO_TOOLCHAIN_PIN_INPUTS } from './cargo-toolchain-policy.js';
|
|
11
12
|
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_COMPILE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestPackageTargetName, createCargoInputsCache, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, } from './cargo-workspace.js';
|
|
12
13
|
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_FROZEN_PREFIX, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, } from './cross-check-policy.js';
|
|
13
14
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
14
15
|
import { isNonSourceDirectory } from './source-directories.js';
|
|
15
|
-
import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS } from './workspace-config-policy.js';
|
|
16
|
+
import { isBuildOutputTargetName, isTestRunnerTargetName, PLATFORM_TARGET_GLOBS, RELEASE_CONFIGURATION, } from './workspace-config-policy.js';
|
|
16
17
|
export { CARGO_TEST_COMPILE_TARGET };
|
|
17
18
|
/** Makes a version live and proves it answers; never cached. */
|
|
18
19
|
export const DEPLOY_TARGET = 'deploy';
|
|
@@ -412,13 +413,33 @@ const NAPI_TOOLCHAIN_TARGET_PREFIX = 'napi-toolchain-';
|
|
|
412
413
|
export function napiToolchainTargetName(convention) {
|
|
413
414
|
return `${NAPI_TOOLCHAIN_TARGET_PREFIX}${convention.architecture}-${convention.targetFamily}`;
|
|
414
415
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
416
|
+
const CARGO_PROFILE_FLAG = { dev: '', release: ' --release' };
|
|
417
|
+
/** The directory under `target/<triple>/` each profile writes. */
|
|
418
|
+
const CARGO_PROFILE_OUTPUT_DIR = { dev: 'debug', release: 'release' };
|
|
419
|
+
/**
|
|
420
|
+
* Cargo's default target directory for a crate, relative to the command's cwd:
|
|
421
|
+
* `target/` beside the workspace root that owns the crate, or beside the
|
|
422
|
+
* crate's own manifest when no workspace claims it. Naming it rather than
|
|
423
|
+
* passing `--target-dir` keeps the wasm build in the directory every other
|
|
424
|
+
* build of the same workspace writes.
|
|
425
|
+
*/
|
|
426
|
+
function cargoWasmTargetDirectory(projectRoot, config, repoRooted, cargoWorkspace) {
|
|
427
|
+
const cwd = repoRooted ? '.' : projectRoot;
|
|
428
|
+
const crateDir = posix.join(cwd, posix.dirname(config.manifestPath));
|
|
429
|
+
const owner = cargoWorkspace !== undefined &&
|
|
430
|
+
cargoWorkspace.packages.some((plan) => posix.join(cargoWorkspace.projectRoot, plan.package.dir) === crateDir)
|
|
431
|
+
? cargoWorkspace.projectRoot
|
|
432
|
+
: crateDir;
|
|
433
|
+
return posix.relative(cwd, posix.join(owner, 'target'));
|
|
434
|
+
}
|
|
435
|
+
function createCargoWasmTarget(projectRoot, config, repoRooted, cargoTargetDirectory) {
|
|
420
436
|
const outputDirectory = repoRooted ? posix.join(projectRoot, config.outputDirectory) : config.outputDirectory;
|
|
421
437
|
const cargoSelection = repoRooted ? `-p ${config.cargoPackage}` : `--manifest-path ${config.manifestPath}`;
|
|
438
|
+
const commands = (profile) => [
|
|
439
|
+
cargoFrozen(`build${CARGO_PROFILE_FLAG[profile]} --target wasm32-unknown-unknown ${cargoSelection}`),
|
|
440
|
+
...config.targets.map(({ bindgenTarget, outputName }) => `wasm-bindgen --target ${bindgenTarget} --out-dir ${outputDirectory}/${outputName} ` +
|
|
441
|
+
`${cargoTargetDirectory}/wasm32-unknown-unknown/${CARGO_PROFILE_OUTPUT_DIR[profile]}/${config.libraryName}.wasm`),
|
|
442
|
+
];
|
|
422
443
|
return {
|
|
423
444
|
executor: 'nx:run-commands',
|
|
424
445
|
cache: true,
|
|
@@ -426,13 +447,11 @@ function createCargoWasmTarget(projectRoot, config, repoRooted) {
|
|
|
426
447
|
inputs: repoRooted ? REPO_ROOT_CARGO_OUTPUT_INPUTS : CARGO_OUTPUT_INPUTS,
|
|
427
448
|
outputs: [`{projectRoot}/${config.outputDirectory}`],
|
|
428
449
|
options: {
|
|
429
|
-
commands:
|
|
430
|
-
cargoFrozen(`build --release --target wasm32-unknown-unknown --target-dir ${cargoTargetDirectory} ${cargoSelection}`),
|
|
431
|
-
...config.targets.map(({ bindgenTarget, outputName }) => `wasm-bindgen --target ${bindgenTarget} --out-dir ${outputDirectory}/${outputName} ${wasmInput}`),
|
|
432
|
-
],
|
|
450
|
+
commands: commands('dev'),
|
|
433
451
|
cwd: repoRooted ? '.' : projectRoot,
|
|
434
452
|
parallel: false,
|
|
435
453
|
},
|
|
454
|
+
configurations: { [RELEASE_CONFIGURATION]: { commands: commands('release') } },
|
|
436
455
|
};
|
|
437
456
|
}
|
|
438
457
|
/**
|
|
@@ -448,13 +467,19 @@ function createCargoWasmTarget(projectRoot, config, repoRooted) {
|
|
|
448
467
|
* timeout. Inference serializes writers that share the default target dir
|
|
449
468
|
* (`napi-debug` after compile).
|
|
450
469
|
*
|
|
451
|
-
* Clippy
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
470
|
+
* Clippy runs ONCE over the whole workspace, in that same `target/`, rather
|
|
471
|
+
* than once per crate. Clippy of a crate is a check build of its whole
|
|
472
|
+
* closure, so 49 crates meant 49 closure rebuilds and 11 GiB of target
|
|
473
|
+
* directories on one repository, and no per-crate cache hit ever repaid that.
|
|
474
|
+
* Sharing the build's directory costs nothing: cargo's own lock serializes
|
|
475
|
+
* the invocations that use it, and the host units a dev build compiled are
|
|
476
|
+
* reused instead of compiled again.
|
|
477
|
+
*
|
|
478
|
+
* Tests compile the dev profile only, so no test target carries a
|
|
479
|
+
* RELEASE_CONFIGURATION: Nx forwards a run's configuration down every
|
|
480
|
+
* `dependsOn` edge to each target that has it, and a release `build` must
|
|
481
|
+
* warm the dev test binaries the test run will use, not release ones nobody
|
|
482
|
+
* runs.
|
|
458
483
|
*/
|
|
459
484
|
function createCargoTestCompileTarget(projectRoot) {
|
|
460
485
|
return {
|
|
@@ -466,9 +491,6 @@ function createCargoTestCompileTarget(projectRoot) {
|
|
|
466
491
|
command: cargoFrozen('test --workspace --no-run'),
|
|
467
492
|
cwd: projectRoot,
|
|
468
493
|
},
|
|
469
|
-
configurations: {
|
|
470
|
-
production: { command: cargoFrozen('test --workspace --release --no-run') },
|
|
471
|
-
},
|
|
472
494
|
};
|
|
473
495
|
}
|
|
474
496
|
/**
|
|
@@ -488,22 +510,19 @@ function createCargoTestCompileTarget(projectRoot) {
|
|
|
488
510
|
* clippy selection exactly, so both gates unify features the same way.
|
|
489
511
|
*/
|
|
490
512
|
function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
491
|
-
const archiveCommand = (profile) => cargoFrozen(`nextest archive --workspace${profile} --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`);
|
|
492
513
|
return {
|
|
493
514
|
executor: 'nx:run-commands',
|
|
494
515
|
cache: true,
|
|
495
516
|
inputs: CARGO_INPUTS,
|
|
496
517
|
outputs: [`{projectRoot}/${CARGO_TEST_ARCHIVE_FILE}`],
|
|
497
518
|
options: {
|
|
498
|
-
commands: [
|
|
519
|
+
commands: [
|
|
520
|
+
`mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`,
|
|
521
|
+
cargoFrozen(`nextest archive --workspace --archive-file ${CARGO_TEST_ARCHIVE_FILE} --user-config-file none ${toolConfig}`),
|
|
522
|
+
],
|
|
499
523
|
cwd: projectRoot,
|
|
500
524
|
parallel: false,
|
|
501
525
|
},
|
|
502
|
-
configurations: {
|
|
503
|
-
production: {
|
|
504
|
-
commands: [`mkdir -p ${posix.dirname(CARGO_TEST_ARCHIVE_FILE)}`, archiveCommand(' --release')],
|
|
505
|
-
},
|
|
506
|
-
},
|
|
507
526
|
};
|
|
508
527
|
}
|
|
509
528
|
/**
|
|
@@ -539,8 +558,6 @@ function createCargoTestArchiveTarget(projectRoot, toolConfig) {
|
|
|
539
558
|
function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archiveInputs) {
|
|
540
559
|
const { target: triple, cargo } = crossTarget;
|
|
541
560
|
const archiveFile = cargoCrossTestArchiveFile(triple);
|
|
542
|
-
const archiveCommand = (profile) => `cargo-nextest nextest archive --workspace${profile} --target ${triple} --frozen ` +
|
|
543
|
-
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`;
|
|
544
561
|
return {
|
|
545
562
|
[cargoCrossTestArchiveTargetName(triple)]: {
|
|
546
563
|
executor: 'nx:run-commands',
|
|
@@ -565,7 +582,11 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
565
582
|
outputs: [`{projectRoot}/${archiveFile}`],
|
|
566
583
|
dependsOn: [CARGO_FETCH_TARGET],
|
|
567
584
|
options: {
|
|
568
|
-
commands: [
|
|
585
|
+
commands: [
|
|
586
|
+
`mkdir -p ${posix.dirname(archiveFile)}`,
|
|
587
|
+
`cargo-nextest nextest archive --workspace --target ${triple} --frozen ` +
|
|
588
|
+
`--archive-file ${archiveFile} --user-config-file none ${toolConfig}`,
|
|
589
|
+
],
|
|
569
590
|
cwd: projectRoot,
|
|
570
591
|
parallel: false,
|
|
571
592
|
// `CARGO` is cargo's own driver variable and the only seam nextest
|
|
@@ -576,11 +597,6 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
576
597
|
// it applies to this archive and to nothing else cargo runs.
|
|
577
598
|
...(cargo === undefined ? {} : { env: { CARGO: cargo } }),
|
|
578
599
|
},
|
|
579
|
-
configurations: {
|
|
580
|
-
production: {
|
|
581
|
-
commands: [`mkdir -p ${posix.dirname(archiveFile)}`, archiveCommand(' --release')],
|
|
582
|
-
},
|
|
583
|
-
},
|
|
584
600
|
},
|
|
585
601
|
[cargoCrossTestTargetName(triple)]: {
|
|
586
602
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
@@ -595,9 +611,6 @@ function createCargoCrossTestTargets(projectRoot, toolConfig, crossTarget, archi
|
|
|
595
611
|
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
596
612
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
597
613
|
},
|
|
598
|
-
// The archive already holds the profile it was built with, and nextest
|
|
599
|
-
// rejects `--release` beside `--archive-file`.
|
|
600
|
-
configurations: { production: {} },
|
|
601
614
|
},
|
|
602
615
|
};
|
|
603
616
|
}
|
|
@@ -613,9 +626,6 @@ function createCargoTestTarget(projectRoot) {
|
|
|
613
626
|
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
614
627
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
615
628
|
},
|
|
616
|
-
configurations: {
|
|
617
|
-
production: { command: cargoFrozen('test --workspace --release') },
|
|
618
|
-
},
|
|
619
629
|
};
|
|
620
630
|
}
|
|
621
631
|
const PLUGIN_NEXTEST_CONFIG = fileURLToPath(new URL('../nextest.toml', import.meta.url));
|
|
@@ -692,6 +702,9 @@ function createNodesHandler(hostPlatform) {
|
|
|
692
702
|
errors.push([packageJsonPath, error instanceof Error ? error : new Error(String(error))]);
|
|
693
703
|
}
|
|
694
704
|
}));
|
|
705
|
+
// A project that failed before reaching its closure never awaited Cargo;
|
|
706
|
+
// no process this call started may outlive it.
|
|
707
|
+
await Promise.all(cargoWorkspaces.map((workspace) => workspace.closureSource));
|
|
695
708
|
if (errors.length > 0) {
|
|
696
709
|
throw new AggregateCreateNodesError(errors, results);
|
|
697
710
|
}
|
|
@@ -897,7 +910,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
897
910
|
validationTargets.push('typecheck');
|
|
898
911
|
}
|
|
899
912
|
if (inferCargoWasm && cargoWasmConfig) {
|
|
900
|
-
targets['cargo-wasm'] = createCargoWasmTarget(projectRoot, cargoWasmConfig, isRepoRootedCargoProject);
|
|
913
|
+
targets['cargo-wasm'] = createCargoWasmTarget(projectRoot, cargoWasmConfig, isRepoRootedCargoProject, cargoWasmTargetDirectory(projectRoot, cargoWasmConfig, isRepoRootedCargoProject, cargoWorkspace));
|
|
901
914
|
}
|
|
902
915
|
if (napiConfig) {
|
|
903
916
|
Object.assign(targets, createNapiTargets(projectRoot, napiConfig, hostPlatform, isRepoRootedCargoProject));
|
|
@@ -998,12 +1011,13 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
998
1011
|
aggregateDependencies.length > 0
|
|
999
1012
|
? { executor: 'nx:noop', cache: true, outputs: [], dependsOn: aggregateDependencies }
|
|
1000
1013
|
: createCargoTestTarget(cargoWorkspaceRoot);
|
|
1001
|
-
// One clippy over the whole workspace, in
|
|
1002
|
-
// is a check build of its closure; a target dir per crate
|
|
1003
|
-
// shared dependency once per crate (49 closures, 11 GiB on
|
|
1004
|
-
// and no per-crate cache hit ever repaid that. The
|
|
1005
|
-
// exactly the union of every crate's, so the verdict
|
|
1006
|
-
// key set the compile does. Non-root packages depend on
|
|
1014
|
+
// One clippy over the whole workspace, in the build's target dir. Clippy
|
|
1015
|
+
// of a crate is a check build of its closure; a target dir per crate
|
|
1016
|
+
// compiled every shared dependency once per crate (49 closures, 11 GiB on
|
|
1017
|
+
// one repository) and no per-crate cache hit ever repaid that. The
|
|
1018
|
+
// workspace inputs are exactly the union of every crate's, so the verdict
|
|
1019
|
+
// caches on the same key set the compile does. Non-root packages depend on
|
|
1020
|
+
// this target.
|
|
1007
1021
|
targets['cargo-lint'] = {
|
|
1008
1022
|
executor: 'nx:run-commands',
|
|
1009
1023
|
cache: true,
|
|
@@ -1120,7 +1134,6 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1120
1134
|
const target = targets[name];
|
|
1121
1135
|
if (target?.executor === 'nx:noop') {
|
|
1122
1136
|
target.outputs = [];
|
|
1123
|
-
target.configurations = { production: {} };
|
|
1124
1137
|
}
|
|
1125
1138
|
}
|
|
1126
1139
|
}
|
|
@@ -1291,7 +1304,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1291
1304
|
// The platform binaries therefore stay Nx siblings of cargo-test-compile and
|
|
1292
1305
|
// serialize on cargo's flock instead of on a graph edge. That is the same
|
|
1293
1306
|
// arrangement `cli-<arch>-<os>` and `napi-<arch>-<os>` already have with each
|
|
1294
|
-
// other โ both `napi build
|
|
1307
|
+
// other โ both `napi build` on one target dir โ so this adds a third
|
|
1295
1308
|
// participant to an existing wait, not a new hazard. The flock makes them wait;
|
|
1296
1309
|
// it does not corrupt anything, and these are unbounded `nx:run-commands`
|
|
1297
1310
|
// targets, so the wait is not charged against a test budget.
|
|
@@ -1398,11 +1411,11 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1398
1411
|
}
|
|
1399
1412
|
// Every cargo build directory this project's own commands write. `clean`
|
|
1400
1413
|
// cannot learn them from `outputs`: a clippy or nextest target dir is a
|
|
1401
|
-
// multi-GB build tree that must never enter the Nx cache
|
|
1402
|
-
// alone was 11 GiB when each of 49 crates had its own), so the targets
|
|
1414
|
+
// multi-GB build tree that must never enter the Nx cache, so the targets
|
|
1403
1415
|
// deliberately declare `outputs: []`. Reading `--target-dir` back off the
|
|
1404
1416
|
// commands means the list cannot drift from what actually gets written, and a
|
|
1405
1417
|
// directory is named relative to the command's own cwd, not the project root.
|
|
1418
|
+
// The workspace's default `target/` is not listed: every dev build shares it.
|
|
1406
1419
|
const cargoBuildDirs = [
|
|
1407
1420
|
...new Set(Object.entries(targets).flatMap(([name, target]) => {
|
|
1408
1421
|
const cwd = target.options?.cwd;
|
|
@@ -1483,6 +1496,18 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1483
1496
|
? { [CARGO_TOOLCHAIN_NAMED_INPUT]: [...CARGO_TOOLCHAIN_PIN_INPUTS] }
|
|
1484
1497
|
: {}),
|
|
1485
1498
|
};
|
|
1499
|
+
// A custom Cargo target names this instead of a hand-kept crate list or a
|
|
1500
|
+
// per-project runtime command: Cargo decides the closure once per graph
|
|
1501
|
+
// computation and Nx hashes its files from its own index. Defined for a
|
|
1502
|
+
// project with a workspace crate under its root โ the same projects the
|
|
1503
|
+
// `--closure <projectRoot>` command could describe.
|
|
1504
|
+
const closureSources = cargoWorkspaces.filter((workspace) => workspace.packages.some(({ package: pkg }) => {
|
|
1505
|
+
const crate = posix.join(workspace.projectRoot, pkg.dir);
|
|
1506
|
+
return projectRoot === '.' || crate === projectRoot || crate.startsWith(`${projectRoot}/`);
|
|
1507
|
+
}));
|
|
1508
|
+
if (closureSources.length > 0) {
|
|
1509
|
+
namedInputs[CARGO_CLOSURE_INPUT] = await cargoClosureInputs(projectRoot, await Promise.all(closureSources.map((workspace) => workspace.closureSource)));
|
|
1510
|
+
}
|
|
1486
1511
|
return {
|
|
1487
1512
|
projects: {
|
|
1488
1513
|
[projectRoot]: {
|
|
@@ -1669,13 +1694,14 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1669
1694
|
}
|
|
1670
1695
|
const targets = {};
|
|
1671
1696
|
const hostCompilerEnv = napiCompilerEnv(hostPlatform, hostPlatform);
|
|
1672
|
-
// The addon the test suite loads. A dev
|
|
1673
|
-
//
|
|
1674
|
-
//
|
|
1675
|
-
//
|
|
1676
|
-
//
|
|
1677
|
-
// dist/ would ship. native.ts resolves this
|
|
1678
|
-
// napi-test target sets NAPI_DEBUG_ADDON=1, so
|
|
1697
|
+
// The addon the test suite loads. A plain dev build shares target/debug with
|
|
1698
|
+
// cargo-test's dependency graph, so after the tests compile this is nearly
|
|
1699
|
+
// free, where a `--target <triple>` platform build compiles the graph again
|
|
1700
|
+
// under target/<triple>/. The output lives OUTSIDE dist/ because packages
|
|
1701
|
+
// publish `files: ["dist"]` wholesale: an addon the test run wrote under
|
|
1702
|
+
// dist/ would ship in place of the release build. native.ts resolves this
|
|
1703
|
+
// directory only when the napi-test target sets NAPI_DEBUG_ADDON=1, so
|
|
1704
|
+
// production loads never see it.
|
|
1679
1705
|
targets['napi-debug'] = {
|
|
1680
1706
|
executor: 'nx:run-commands',
|
|
1681
1707
|
cache: true,
|
|
@@ -1690,9 +1716,12 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1690
1716
|
};
|
|
1691
1717
|
if (nativeHostTargetName === null) {
|
|
1692
1718
|
// The platform target for this host triple is the same compilation, so a
|
|
1693
|
-
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
1694
|
-
//
|
|
1695
|
-
//
|
|
1719
|
+
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
1720
|
+
// (a plain build and a `--target` build write different target/
|
|
1721
|
+
// subdirectories); native.ts already resolves the identical
|
|
1722
|
+
// platform-suffixed filename from dist/native/<platform-dir> after
|
|
1723
|
+
// dist/native/host.
|
|
1724
|
+
const hostBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputPath('dist/native/host')}`;
|
|
1696
1725
|
targets['cargo-napi'] = {
|
|
1697
1726
|
executor: 'nx:run-commands',
|
|
1698
1727
|
cache: true,
|
|
@@ -1701,9 +1730,10 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1701
1730
|
outputs: ['{projectRoot}/dist/native/host'],
|
|
1702
1731
|
options: {
|
|
1703
1732
|
cwd: cargoCwd,
|
|
1704
|
-
command:
|
|
1733
|
+
command: hostBuild('dev'),
|
|
1705
1734
|
...(hostCompilerEnv ? { env: hostCompilerEnv } : {}),
|
|
1706
1735
|
},
|
|
1736
|
+
configurations: { [RELEASE_CONFIGURATION]: { command: hostBuild('release') } },
|
|
1707
1737
|
};
|
|
1708
1738
|
}
|
|
1709
1739
|
for (const triple of config.targets) {
|
|
@@ -1735,6 +1765,7 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1735
1765
|
const useNapiCross = usesNapiCross(convention, hostPlatform);
|
|
1736
1766
|
const crossFlag = useNapiCross ? ' --use-napi-cross' : '';
|
|
1737
1767
|
const compilerEnv = napiCompilerEnv(convention, hostPlatform);
|
|
1768
|
+
const platformBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple}${crossFlag} ${commonCommand} --output-dir ${outputPath(outputDirectory)}`;
|
|
1738
1769
|
targets[targetName] = {
|
|
1739
1770
|
executor: 'nx:run-commands',
|
|
1740
1771
|
cache: true,
|
|
@@ -1743,12 +1774,13 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1743
1774
|
outputs: [`{projectRoot}/${outputDirectory}`],
|
|
1744
1775
|
options: {
|
|
1745
1776
|
cwd: cargoCwd,
|
|
1746
|
-
command:
|
|
1777
|
+
command: platformBuild('dev'),
|
|
1747
1778
|
// Genuine Linux cross-compiles use Clang plus napi-rs's downloaded
|
|
1748
1779
|
// GNU sysroot. A native Linux target uses Nix's cc wrapper so C build
|
|
1749
1780
|
// scripts resolve the host libc headers instead.
|
|
1750
1781
|
...(compilerEnv ? { env: compilerEnv } : {}),
|
|
1751
1782
|
},
|
|
1783
|
+
configurations: { [RELEASE_CONFIGURATION]: { command: platformBuild('release') } },
|
|
1752
1784
|
};
|
|
1753
1785
|
}
|
|
1754
1786
|
return targets;
|
|
@@ -1758,10 +1790,11 @@ function createNapiTestTarget(projectRoot, hasDedicatedBunfig) {
|
|
|
1758
1790
|
return {
|
|
1759
1791
|
executor: '@smoothbricks/nx-plugin:bounded-exec',
|
|
1760
1792
|
cache: true,
|
|
1761
|
-
// Deliberately NOT `build`: the aggregate drags the host-platform
|
|
1762
|
-
//
|
|
1763
|
-
//
|
|
1764
|
-
// napi-debug supplies the addon
|
|
1793
|
+
// Deliberately NOT `build`: the aggregate drags the host-platform binaries
|
|
1794
|
+
// onto the test critical path, and a `--target <triple>` platform build
|
|
1795
|
+
// compiles the whole graph again. tsc-js supplies dist/ts for the suite's
|
|
1796
|
+
// own imports; napi-debug supplies the addon from the graph cargo-test
|
|
1797
|
+
// already built.
|
|
1765
1798
|
dependsOn: ['cargo-test', 'napi-debug', 'tsc-js', '^build'],
|
|
1766
1799
|
options: {
|
|
1767
1800
|
// cwd is src/, not the package root: `bun test <arg>` treats the arg as a
|
|
@@ -1872,7 +1905,7 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1872
1905
|
// createProjectTargets records the path-specific parse failure below.
|
|
1873
1906
|
}
|
|
1874
1907
|
}
|
|
1875
|
-
const
|
|
1908
|
+
const found = [];
|
|
1876
1909
|
for (const rootProject of projects) {
|
|
1877
1910
|
const absoluteRoot = join(workspaceRoot, rootProject.root);
|
|
1878
1911
|
const manifest = join(absoluteRoot, 'Cargo.toml');
|
|
@@ -1908,14 +1941,22 @@ async function resolveCargoWorkspaces(packageJsonPaths, workspaceRoot) {
|
|
|
1908
1941
|
}
|
|
1909
1942
|
packages.push({ package: pkg, pieces });
|
|
1910
1943
|
}
|
|
1911
|
-
|
|
1944
|
+
found.push({
|
|
1912
1945
|
packages,
|
|
1913
1946
|
rootProjectName: rootProject.name,
|
|
1914
1947
|
projectRoot: rootProject.root,
|
|
1915
1948
|
inputsCache: createCargoInputsCache(),
|
|
1916
1949
|
});
|
|
1917
1950
|
}
|
|
1918
|
-
|
|
1951
|
+
if (found.length === 0)
|
|
1952
|
+
return [];
|
|
1953
|
+
// Started only once every workspace listed cleanly, so a listing that throws
|
|
1954
|
+
// leaves no Cargo process behind.
|
|
1955
|
+
const indexedManifests = indexedCargoManifests(workspaceRoot);
|
|
1956
|
+
return found.map((workspace) => ({
|
|
1957
|
+
...workspace,
|
|
1958
|
+
closureSource: resolveCargoClosureSource(posix.join(workspace.projectRoot, 'Cargo.toml'), workspaceRoot, indexedManifests),
|
|
1959
|
+
}));
|
|
1919
1960
|
}
|
|
1920
1961
|
/**
|
|
1921
1962
|
* One bounded target per crate; a crate that declares `smoothbricks.test.shards`
|
|
@@ -2016,11 +2057,6 @@ async function addCargoTestTargets(targets, currentProjectName, projectRoot, wor
|
|
|
2016
2057
|
timeoutMs: BOUNDED_TEST_TIMEOUT_MS,
|
|
2017
2058
|
killAfterMs: BOUNDED_TEST_KILL_AFTER_MS,
|
|
2018
2059
|
},
|
|
2019
|
-
// The archive already holds the profile it was built with, and nextest
|
|
2020
|
-
// rejects `--release` beside `--archive-file`. Nx propagates the
|
|
2021
|
-
// configuration to this target's dependencies, so `:production` builds
|
|
2022
|
-
// the release archive and this command runs exactly what it finds.
|
|
2023
|
-
configurations: { production: {} },
|
|
2024
2060
|
};
|
|
2025
2061
|
}
|
|
2026
2062
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-workflow.d.ts","sourceRoot":"","sources":["../../src/managed-files/ci-workflow.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAE7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAGlC,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,eAAe,qBAAqB;IACpC,WAAW,iBAAiB;IAC5B,gBAAgB,sBAAsB;IACtC,SAAS,gBAAgB;IACzB,cAAc,qBAAqB;IACnC,KAAK,UAAU;IACf,YAAY,kBAAkB;IAC9B,IAAI,SAAS;IACb,S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AwB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,6BAA6B,GAAG,MAAM,EAAE,CAyG9G;AAqCD,6EAA6E;AAC7E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,6BAA6B,GAAG,6BAA6B,CAkC9G;AAqGD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AA6BF,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhE;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,EAAE,CAGjF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,EAAE,CAMxG;AAmRD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,EAC9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,GAAG,UAAU,EAC3B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,SAAS,SAAc,GACtB,MAAM,EAAE,CAmBV"}
|
|
@@ -60,7 +60,7 @@ export function defineCiWorkflow(options) {
|
|
|
60
60
|
if (options.browserTests) {
|
|
61
61
|
steps.push({ kind: CiWorkflowStepKind.BrowserTests, name: '๐ Browser Tests' });
|
|
62
62
|
}
|
|
63
|
-
steps.push({ kind: CiWorkflowStepKind.ManagedFilesCheck, name: '๐ฉบ Check managed-file drift' }, { kind: CiWorkflowStepKind.ManagedFilesDispatch, name: '๐ Dispatch managed-file drift healing' }, { kind: CiWorkflowStepKind.SaveNxCache, name: '๐พ Save Nx cache' }, { kind: CiWorkflowStepKind.UploadTraceDbs, name: '๐ Upload trace DBs' }, { kind: CiWorkflowStepKind.SaveNixDevenv, name: '๐งน Cleanup and cache Nix/devenv' });
|
|
63
|
+
steps.push({ kind: CiWorkflowStepKind.ManagedFilesCheck, name: '๐ฉบ Check monorepo policies and managed-file drift' }, { kind: CiWorkflowStepKind.ManagedFilesDispatch, name: '๐ Dispatch managed-file drift healing' }, { kind: CiWorkflowStepKind.SaveNxCache, name: '๐พ Save Nx cache' }, { kind: CiWorkflowStepKind.UploadTraceDbs, name: '๐ Upload trace DBs' }, { kind: CiWorkflowStepKind.SaveNixDevenv, name: '๐งน Cleanup and cache Nix/devenv' });
|
|
64
64
|
return steps.map((step, index) => ({ ...step, number: index + 2 }));
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
@@ -314,24 +314,21 @@ function yamlLinesForStep(step, options) {
|
|
|
314
314
|
` run: smoo github-ci nx-run-many --targets "${darwinCrossTestTargetNames(options).join(',')}"`,
|
|
315
315
|
];
|
|
316
316
|
case CiWorkflowStepKind.ManagedFilesCheck:
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
// `drifted=<count>` for the dispatch step below.
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
' id: managed-drift',
|
|
323
|
-
' if:',
|
|
324
|
-
" ${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}',",
|
|
325
|
-
' github.event.repository.default_branch) }}',
|
|
326
|
-
' run: smoo monorepo check --warn',
|
|
327
|
-
];
|
|
317
|
+
// Runs on every event, pull requests included: the package policies fail the job, since
|
|
318
|
+
// nothing heals them, while --warn keeps managed-file drift non-blocking and publishes the
|
|
319
|
+
// step output `drifted=<count>` for the dispatch step below. The check is nearly free here
|
|
320
|
+
// (devenv is already up).
|
|
321
|
+
return [` - name: ${step.name}`, ' id: managed-drift', ' run: smoo monorepo check --warn'];
|
|
328
322
|
case CiWorkflowStepKind.ManagedFilesDispatch:
|
|
329
323
|
// Dispatches the managed-files workflow, which maintains the persistent
|
|
330
|
-
// review PR. workflow_dispatch is exempt from
|
|
331
|
-
// recursion guard, so the default token suffices.
|
|
324
|
+
// review PR, from the default branch only. workflow_dispatch is exempt from
|
|
325
|
+
// GitHub's GITHUB_TOKEN recursion guard, so the default token suffices.
|
|
332
326
|
return [
|
|
333
327
|
` - name: ${step.name}`,
|
|
334
|
-
|
|
328
|
+
' if: >-',
|
|
329
|
+
" ${{ github.event_name == 'push' && github.ref == format('refs/heads/{0}',",
|
|
330
|
+
" github.event.repository.default_branch) && steps.managed-drift.outputs.drifted != '' &&",
|
|
331
|
+
" steps.managed-drift.outputs.drifted != '0' }}",
|
|
335
332
|
' run: smoo github-ci dispatch-workflow --workflow managed-files.yml --ref "$GITHUB_REF_NAME"',
|
|
336
333
|
];
|
|
337
334
|
case CiWorkflowStepKind.Deploy:
|