@smoothbricks/nx-plugin 0.4.19 → 0.4.21

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.
Files changed (44) hide show
  1. package/README.md +68 -18
  2. package/dist/bin/smoo-nx-cargo-hash.js +5 -3
  3. package/dist/cargo-source-hash.d.ts +3 -11
  4. package/dist/cargo-source-hash.d.ts.map +1 -1
  5. package/dist/cargo-source-hash.js +25 -14
  6. package/dist/cargo-workspace.d.ts +0 -1
  7. package/dist/cargo-workspace.d.ts.map +1 -1
  8. package/dist/cargo-workspace.js +9 -2
  9. package/dist/ensure-built.d.ts +6 -5
  10. package/dist/ensure-built.d.ts.map +1 -1
  11. package/dist/ensure-built.js +227 -30
  12. package/dist/index.js +18 -10
  13. package/dist/managed-files/ci-workflow.d.ts +20 -0
  14. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  15. package/dist/managed-files/ci-workflow.js +42 -13
  16. package/dist/managed-files/files.d.ts +1 -1
  17. package/dist/managed-files/files.d.ts.map +1 -1
  18. package/dist/managed-files/files.js +8 -1
  19. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +37 -0
  20. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
  21. package/dist/managed-files/pr-preview-cleanup-workflow.js +34 -6
  22. package/dist/workspace-manifest.d.ts +3 -1
  23. package/dist/workspace-manifest.d.ts.map +1 -1
  24. package/managed/raw/tooling/direnv/setup-environment.ts +23 -91
  25. package/managed/raw/tooling/git-hooks/commit-msg.sh +6 -0
  26. package/managed/raw/tooling/git-hooks/pre-commit.sh +6 -0
  27. package/managed/raw/tooling/git-hooks/pre-push.sh +6 -0
  28. package/managed/templates/github/actions/setup-devenv/action.yml +19 -7
  29. package/package.json +1 -1
  30. package/src/bin/smoo-nx-cargo-hash.ts +7 -3
  31. package/src/cargo-source-hash.test.ts +237 -1
  32. package/src/cargo-source-hash.ts +32 -16
  33. package/src/cargo-workspace.test.ts +17 -10
  34. package/src/cargo-workspace.ts +9 -3
  35. package/src/ensure-built.test.ts +87 -29
  36. package/src/ensure-built.ts +274 -29
  37. package/src/index.test.ts +117 -20
  38. package/src/index.ts +18 -11
  39. package/src/managed-files/ci-workflow.ts +45 -14
  40. package/src/managed-files/files.ts +9 -2
  41. package/src/managed-files/generator.test.ts +5 -1
  42. package/src/managed-files/github-host-cache-isolation.test.ts +32 -6
  43. package/src/managed-files/pr-preview-cleanup-workflow.ts +87 -6
  44. package/src/workspace-manifest.ts +3 -1
@@ -1,8 +1,8 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { randomUUID } from 'node:crypto';
3
- import { existsSync } from 'node:fs';
3
+ import { closeSync, existsSync, lstatSync, openSync, readdirSync, readlinkSync, readSync } from 'node:fs';
4
4
  import { createRequire } from 'node:module';
5
- import { join, resolve } from 'node:path';
5
+ import { isAbsolute, join, resolve } from 'node:path';
6
6
  function createWorkspaceNxRequire(workspaceRoot) {
7
7
  const requireFromWorkspace = createRequire(join(workspaceRoot, 'package.json'));
8
8
  return function requireNx(specifier) {
@@ -74,19 +74,15 @@ export function firstCacheMiss(tasks, cachedCodeByHash) {
74
74
  return null;
75
75
  }
76
76
  /**
77
- * First task whose recorded outputs are no longer the bytes on disk.
77
+ * The entries the daemon does not vouch for.
78
78
  *
79
- * `matches[index]` is the daemon's verdict for `tasks[index]`. A short or
80
- * ragged array counts as stale rather than as a hit: a missing verdict is not a
81
- * positive one, and being wrong here means exec'ing a binary that was deleted.
79
+ * `verdicts[index]` is the daemon's verdict for `entries[index]`. A short or
80
+ * ragged array leaves the remainder unvouched rather than cleared: a missing
81
+ * verdict is not a positive one, and being wrong here means exec'ing a binary
82
+ * that was deleted.
82
83
  */
83
- export function firstStaleOutputs(tasks, matches) {
84
- for (let index = 0; index < tasks.length; index += 1) {
85
- if (matches[index] !== true) {
86
- return { kind: 'stale-outputs', taskId: tasks[index].id };
87
- }
88
- }
89
- return null;
84
+ export function unvouched(entries, verdicts) {
85
+ return entries.filter((_, index) => verdicts[index] !== true);
90
86
  }
91
87
  /**
92
88
  * Make sure an Nx target's outputs are on disk, doing as little as possible
@@ -213,7 +209,7 @@ async function ensureBuiltInWorkspace(workspaceRoot, selector, onMiss) {
213
209
  reason = { kind: 'stale-inputs', taskId: selectorTaskId };
214
210
  }
215
211
  else {
216
- reason = await probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
212
+ reason = await probe(workspaceRoot, nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx);
217
213
  }
218
214
  performance.measure('ensureBuilt:probe', 'ensureBuilt:probe:start');
219
215
  const outcome = reason === null
@@ -309,13 +305,14 @@ async function refreshWorkspaceContext(workspaceRoot, tasks, requireNx) {
309
305
  return inputsChanged;
310
306
  }
311
307
  /** `null` when the target is already built; otherwise the first reason it is not. */
312
- async function probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx) {
308
+ async function probe(workspaceRoot, nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx) {
313
309
  const { daemonClient } = requireNx('nx/src/daemon/client/client');
314
310
  const { DaemonBasedTaskHasher } = requireNx('nx/src/hasher/task-hasher');
315
311
  const { getTaskDetails, hashTasks } = requireNx('nx/src/hasher/hash-task');
316
312
  const { getTaskSpecificEnv } = requireNx('nx/src/tasks-runner/task-env');
317
313
  const { getCache } = requireNx('nx/src/tasks-runner/cache');
318
314
  const { getRunnerOptions } = requireNx('nx/src/tasks-runner/run-command');
315
+ const { getExecutorNameForTask } = requireNx('nx/src/tasks-runner/utils');
319
316
  // `isCloudDefault: false` because these options are only read here by the
320
317
  // hasher, which looks at `selectivelyHashTsConfig`; the cloud credentials the
321
318
  // flag would add belong to the cloud runner, and the run path calls Nx's own
@@ -341,20 +338,28 @@ async function probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx)
341
338
  }
342
339
  await hashTasks(hasher, projectGraph, taskGraph, perTaskEnvs, getTaskDetails(), tasks);
343
340
  performance.measure('ensureBuilt:hash', 'ensureBuilt:hash:start');
341
+ // An `nx:noop` task has no command: Nx completes it without spawning
342
+ // anything, and normalizes a command-less target that only names dependencies
343
+ // to one. A cache record would vouch for no work — the tasks it aggregates are
344
+ // in this graph and answer for themselves — so none is required. Demanding one
345
+ // made every call through an uncacheable aggregate hand the whole graph to Nx,
346
+ // which replays each dependency's cached log. Outputs a noop declares are
347
+ // still verified below, with every other task's.
348
+ const recordedTasks = tasks.filter((task) => getExecutorNameForTask(task, projectGraph) !== 'nx:noop');
344
349
  // Nx's own factory, but deliberately never `init()`ed: that is what makes
345
350
  // this a local-only, side-effect-free question. `init()` attaches the remote
346
351
  // cache — a network round-trip, and a download is precisely the work this
347
352
  // probe exists to detect — and asserts that the cache directory matches the
348
- // database. Neither matters here: a hit is only declared when the outputs on
349
- // disk already match, so the cache directory is never read.
353
+ // database. Neither matters here: the directory is read only to compare
354
+ // outputs against, and an artifact missing from it is a miss.
350
355
  performance.mark('ensureBuilt:cache:start');
351
356
  const cache = getCache(runnerOptions);
352
- const cachedResults = await cache.getBatch(tasks.filter((task) => task.cache && task.hash));
357
+ const cachedResults = await cache.getBatch(recordedTasks.filter((task) => task.cache && task.hash));
353
358
  const cachedCodeByHash = new Map();
354
359
  for (const [hash, result] of cachedResults) {
355
360
  cachedCodeByHash.set(hash, result.code);
356
361
  }
357
- const cacheMiss = firstCacheMiss(tasks, cachedCodeByHash);
362
+ const cacheMiss = firstCacheMiss(recordedTasks, cachedCodeByHash);
358
363
  performance.measure('ensureBuilt:cache', 'ensureBuilt:cache:start');
359
364
  if (cacheMiss) {
360
365
  return cacheMiss;
@@ -362,22 +367,214 @@ async function probe(nxJson, nxArgs, projectGraph, taskGraph, tasks, requireNx)
362
367
  // A cache record only proves the task once succeeded with these inputs. The
363
368
  // artifact this facility is about — the binary that is about to be exec'd —
364
369
  // lives in the working tree, where anything may have deleted or rewritten it
365
- // since. Only the daemon can settle that, because it holds the recorded
366
- // output hashes.
367
- const withOutputs = [];
368
- const outputEntries = [];
370
+ // since. The daemon answers that cheaply from the output hashes it recorded
371
+ // when Nx last wrote them.
372
+ const claims = [];
369
373
  for (const task of tasks) {
370
- const hash = task.hash;
371
- if (task.outputs.length === 0 || hash === undefined) {
372
- continue;
374
+ if (task.outputs.length > 0 && task.hash !== undefined) {
375
+ claims.push({ taskId: task.id, outputs: task.outputs, hash: task.hash });
373
376
  }
374
- withOutputs.push(task);
375
- outputEntries.push({ outputs: task.outputs, hash });
376
377
  }
377
378
  performance.mark('ensureBuilt:outputs:start');
378
- const matches = await daemonClient.outputsHashesMatchBatch(outputEntries);
379
+ const verdicts = await daemonClient.outputsHashesMatchBatch(claims.map(({ outputs, hash }) => ({ outputs, hash })));
379
380
  performance.measure('ensureBuilt:outputs', 'ensureBuilt:outputs:start');
380
- return firstStaleOutputs(withOutputs, matches);
381
+ const doubted = unvouched(claims, verdicts);
382
+ if (doubted.length === 0) {
383
+ return null;
384
+ }
385
+ // Its records are lossy, though, and a lost record is not a changed output.
386
+ // They live in memory, so a restart drops every one. They are kept per
387
+ // collapsed directory (Nx tracks at most three paths per level), so a write
388
+ // anywhere under `packages/` voids a task whose outputs span four projects.
389
+ // And a write the daemon processes more than 2 s after a record erases it,
390
+ // which a daemon busy hashing does to a restore's own writes — so each
391
+ // restore guarantees the next one. What settles the question is what a hit
392
+ // would restore: Nx's own local artifact for this exact hash. A working tree
393
+ // that already holds every entry of it is what the restore would leave.
394
+ // Anything else — no artifact, a difference, an error while reading — stays
395
+ // a miss.
396
+ performance.mark('ensureBuilt:artifacts:start');
397
+ const { expandOutputs } = requireNx('nx/src/native');
398
+ const comparison = {
399
+ expandOutputs,
400
+ left: Buffer.allocUnsafe(COMPARE_CHUNK_BYTES),
401
+ right: Buffer.allocUnsafe(COMPARE_CHUNK_BYTES),
402
+ observed: [],
403
+ realDirectories: new Set(),
404
+ };
405
+ for (const claim of doubted) {
406
+ // `recordedTasks` excludes `nx:noop`, so a noop's declared outputs have no
407
+ // artifact here and stay a miss.
408
+ const artifact = cachedResults.get(claim.hash);
409
+ if (artifact === undefined || !outputsMatchArtifact(comparison, workspaceRoot, artifact.outputsPath, claim)) {
410
+ return { kind: 'stale-outputs', taskId: claim.taskId };
411
+ }
412
+ }
413
+ // A write that landed while the bytes were being compared would otherwise be
414
+ // recorded as current.
415
+ const movedBeforeRecord = firstMovedClaim(comparison.observed);
416
+ if (movedBeforeRecord !== null) {
417
+ return { kind: 'stale-outputs', taskId: movedBeforeRecord };
418
+ }
419
+ // Re-arm the daemon the way Nx's runner does after restoring outputs, so the
420
+ // next call is back on the cheap path.
421
+ await daemonClient.recordOutputsHashBatch(doubted.map(({ outputs, hash }) => ({ outputs, hash })));
422
+ const movedDuringRecord = firstMovedClaim(comparison.observed);
423
+ performance.measure('ensureBuilt:artifacts', 'ensureBuilt:artifacts:start');
424
+ return movedDuringRecord === null ? null : { kind: 'stale-outputs', taskId: movedDuringRecord };
425
+ }
426
+ /** Read size for byte comparison: large enough to stream a binary quickly, small enough never to load one whole. */
427
+ const COMPARE_CHUNK_BYTES = 1 << 20;
428
+ /**
429
+ * Whether restoring `claim` from the artifact would leave the working tree as
430
+ * it is.
431
+ *
432
+ * The entries are the ones Nx's restore copies: `expandOutputs` over the
433
+ * artifact root with the task's outputs, globs and negations included. That
434
+ * walk is bounded by the artifact, which holds nothing but outputs, and it
435
+ * needs no reading of the pattern here. A restore replaces each entry whole
436
+ * and touches nothing else, so a working-tree file that matches a glob but is
437
+ * absent from the artifact survives it and is no difference. An output path
438
+ * Nx would refuse to restore (absolute, or climbing out with `..`), an
439
+ * artifact holding no entry at all, and system errors while reading are all
440
+ * misses.
441
+ */
442
+ function outputsMatchArtifact(comparison, workspaceRoot, artifactRoot, claim) {
443
+ if (claim.outputs.some((output) => isAbsolute(output) || output.split('/').includes('..'))) {
444
+ return false;
445
+ }
446
+ try {
447
+ const entries = comparison.expandOutputs(artifactRoot, claim.outputs);
448
+ return (entries.length > 0 &&
449
+ entries.every((entry) => throughRealDirectories(comparison.realDirectories, workspaceRoot, entry) &&
450
+ sameTree(comparison, claim.taskId, join(workspaceRoot, entry), join(artifactRoot, entry))));
451
+ }
452
+ catch (error) {
453
+ if (isSystemError(error)) {
454
+ return false;
455
+ }
456
+ throw error;
457
+ }
458
+ }
459
+ /**
460
+ * Whether every directory between the workspace root and `entry` is a real
461
+ * directory. A restore realizes a symlinked parent as a directory, so reading
462
+ * an entry through one would compare bytes the restore does not leave there —
463
+ * and would read the filesystem behind a link.
464
+ */
465
+ function throughRealDirectories(realDirectories, workspaceRoot, entry) {
466
+ let directory = workspaceRoot;
467
+ const segments = entry.split('/');
468
+ for (const segment of segments.slice(0, -1)) {
469
+ directory = join(directory, segment);
470
+ if (realDirectories.has(directory)) {
471
+ continue;
472
+ }
473
+ if (lstatSync(directory, { throwIfNoEntry: false })?.isDirectory() !== true) {
474
+ return false;
475
+ }
476
+ realDirectories.add(directory);
477
+ }
478
+ return true;
479
+ }
480
+ /**
481
+ * Whether `actual` is `expected` as a restore would recreate it: same node
482
+ * type; a symlink by its text, never followed, because the link is what Nx
483
+ * stores and restores; a file by permission bits and bytes; a directory by its
484
+ * entry names and each entry in turn. Every working-tree node compared is
485
+ * observed, so a write during the comparison can be caught afterwards.
486
+ */
487
+ function sameTree(comparison, taskId, actual, expected) {
488
+ const actualStats = lstatSync(actual, { bigint: true, throwIfNoEntry: false });
489
+ const expectedStats = lstatSync(expected, { bigint: true, throwIfNoEntry: false });
490
+ if (actualStats === undefined || expectedStats === undefined) {
491
+ return false;
492
+ }
493
+ comparison.observed.push({ taskId, path: actual, stats: actualStats });
494
+ if (expectedStats.isSymbolicLink()) {
495
+ return actualStats.isSymbolicLink() && readlinkSync(actual) === readlinkSync(expected);
496
+ }
497
+ if (expectedStats.isFile()) {
498
+ return (actualStats.isFile() &&
499
+ actualStats.size === expectedStats.size &&
500
+ (actualStats.mode & 4095n) === (expectedStats.mode & 4095n) &&
501
+ sameBytes(comparison, actual, expected, Number(expectedStats.size)));
502
+ }
503
+ if (expectedStats.isDirectory()) {
504
+ if (!actualStats.isDirectory()) {
505
+ return false;
506
+ }
507
+ const names = readdirSync(actual).sort();
508
+ const expectedNames = readdirSync(expected).sort();
509
+ if (names.length !== expectedNames.length) {
510
+ return false;
511
+ }
512
+ for (let index = 0; index < names.length; index += 1) {
513
+ if (names[index] !== expectedNames[index]) {
514
+ return false;
515
+ }
516
+ }
517
+ return names.every((name) => sameTree(comparison, taskId, join(actual, name), join(expected, name)));
518
+ }
519
+ return false;
520
+ }
521
+ /** Byte equality of two files already known to be `size` bytes, streamed through the comparison's buffers. */
522
+ function sameBytes(comparison, actual, expected, size) {
523
+ const actualFd = openSync(actual, 'r');
524
+ try {
525
+ const expectedFd = openSync(expected, 'r');
526
+ try {
527
+ for (let offset = 0; offset < size; offset += COMPARE_CHUNK_BYTES) {
528
+ const length = Math.min(COMPARE_CHUNK_BYTES, size - offset);
529
+ // A short read means the file changed length since it was sized.
530
+ if (readSync(actualFd, comparison.left, 0, length, offset) !== length ||
531
+ readSync(expectedFd, comparison.right, 0, length, offset) !== length ||
532
+ comparison.left.compare(comparison.right, 0, length, 0, length) !== 0) {
533
+ return false;
534
+ }
535
+ }
536
+ return true;
537
+ }
538
+ finally {
539
+ closeSync(expectedFd);
540
+ }
541
+ }
542
+ finally {
543
+ closeSync(actualFd);
544
+ }
545
+ }
546
+ /**
547
+ * The task owning the first observed node that is no longer the node it was
548
+ * compared as: replaced (device, inode), rewritten (size, mtime) or otherwise
549
+ * touched (mode, ctime).
550
+ */
551
+ function firstMovedClaim(observed) {
552
+ for (const { taskId, path, stats } of observed) {
553
+ let current;
554
+ try {
555
+ current = lstatSync(path, { bigint: true, throwIfNoEntry: false });
556
+ }
557
+ catch (error) {
558
+ if (isSystemError(error)) {
559
+ return taskId;
560
+ }
561
+ throw error;
562
+ }
563
+ if (current === undefined ||
564
+ current.dev !== stats.dev ||
565
+ current.ino !== stats.ino ||
566
+ current.mode !== stats.mode ||
567
+ current.size !== stats.size ||
568
+ current.mtimeNs !== stats.mtimeNs ||
569
+ current.ctimeNs !== stats.ctimeNs) {
570
+ return taskId;
571
+ }
572
+ }
573
+ return null;
574
+ }
575
+ /** An operating-system or native-binding failure, as opposed to a programming error. */
576
+ function isSystemError(error) {
577
+ return error instanceof Error && 'code' in error && typeof error.code === 'string';
381
578
  }
382
579
  async function runTarget(nxJson, nxArgs, overrides, selector, reason, requireNx) {
383
580
  const { runCommandForTasks } = requireNx('nx/src/tasks-runner/run-command');
package/dist/index.js CHANGED
@@ -1361,20 +1361,26 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
1361
1361
  options: { command: WRANGLER_DEPLOY_COMMAND, cwd: projectRoot },
1362
1362
  };
1363
1363
  }
1364
- // No `outputs`, deliberately: this aggregate runs no command, so every file
1365
- // under dist belongs to the concrete target that emitted it. Claiming
1366
- // `{projectRoot}/dist` here would cache the children's bytes a second time
1367
- // under the aggregate's hash, and would make `smoo github-ci nx-run-many
1368
- // --collect-outputs` attribute to `build` whatever sits under dist — including
1369
- // platform-target artifacts the collect excludes on purpose and stale
1370
- // artifacts of targets that never ran. Two collected trees then claim one
1371
- // binary and `apply-outputs` rejects the overlap. `lint` and `test` are
1364
+ // Empty `outputs`, deliberately and explicitly: this aggregate runs no
1365
+ // command, so every file under dist belongs to the concrete target that
1366
+ // emitted it. Claiming `{projectRoot}/dist` here would cache the children's
1367
+ // bytes a second time under the aggregate's hash, and would make `smoo
1368
+ // github-ci nx-run-many --collect-outputs` attribute to `build` whatever sits
1369
+ // under dist — including platform-target artifacts the collect excludes on
1370
+ // purpose and stale artifacts of targets that never ran. Two collected trees
1371
+ // then claim one binary and `apply-outputs` rejects the overlap. Omitting the
1372
+ // key is not the same thing: Nx gives a `build` or `prepare` target without
1373
+ // `outputs` its legacy defaults (`{projectRoot}/dist`, `/build`, `/public`,
1374
+ // `dist/{projectRoot}`), so a cache hit on the aggregate — whose key does
1375
+ // not move when only a child's own inputs do — restored the children's
1376
+ // previous dist over what they had just emitted. `lint` and `test` are
1372
1377
  // aggregates on the same terms. Same reason nx.json must not put `outputs` in
1373
1378
  // targetDefaults.build (see validateBuildTargetDefault).
1374
1379
  if (hasOrdinaryBuildOutputTarget) {
1375
1380
  targets.build = {
1376
1381
  executor: 'nx:noop',
1377
1382
  cache: true,
1383
+ outputs: [],
1378
1384
  // `cargo-napi` is both an output family and a serialized cargo writer, so
1379
1385
  // the two sources overlap; the Set keeps one edge per target while holding
1380
1386
  // the order the families are listed in.
@@ -1967,7 +1973,10 @@ async function addCargoTestTargets(targets, currentProjectName, projectRoot, wor
1967
1973
  if (plan.package.projectRoot !== projectRoot) {
1968
1974
  continue;
1969
1975
  }
1970
- const inputRoot = projectRoot === workspace.projectRoot ? '{projectRoot}' : posix.join('{workspaceRoot}', workspace.projectRoot);
1976
+ // Workspace-anchored for the reason `cargoPackageTestInputs` gives: a
1977
+ // `{projectRoot}` glob hashes only files this project owns, and sibling
1978
+ // manifests belong to whichever nested project holds them.
1979
+ const inputRoot = posix.join('{workspaceRoot}', workspace.projectRoot);
1971
1980
  // A workspace nextest build unifies features across every selected member.
1972
1981
  // A sibling manifest can therefore change this crate's tests without being
1973
1982
  // a path dependency. Track those manifests, not unrelated sibling sources.
@@ -1981,7 +1990,6 @@ async function addCargoTestTargets(targets, currentProjectName, projectRoot, wor
1981
1990
  workspaceRoot,
1982
1991
  absoluteProjectRoot: join(workspaceRoot, workspace.projectRoot),
1983
1992
  memberDir: plan.package.dir,
1984
- inputRoot,
1985
1993
  cache: workspace.inputsCache,
1986
1994
  })),
1987
1995
  ...workspace.packages.map((member) => posix.join(inputRoot, member.package.dir, 'Cargo.toml')),
@@ -133,6 +133,17 @@ export interface CiWorkflowDefinitionOptions extends DeployStepSecretConfig {
133
133
  platformProducer?: PackageSmooGithub['platformProducer'];
134
134
  }
135
135
  export declare function defineCiWorkflow(options: CiWorkflowDefinitionOptions): CiWorkflowStep[];
136
+ /**
137
+ * CI's concurrency group: one per pull request, by its number, and one per ref
138
+ * for pushes. The PR preview cleanup joins the same group, so a pull request's
139
+ * close cancels its running CI and the cleanup starts only after that run's
140
+ * stage deploy has stopped. The number, not `github.ref`, names a pull
141
+ * request's group: a close that merged it carries the base branch's ref, which
142
+ * would put the cleanup in the base branch's own group, and a forge may spell a
143
+ * pull request's ref after its merge or after its head. Spelled literally
144
+ * rather than from `github.workflow`, which a forge may fill with the file name.
145
+ */
146
+ export declare const CI_CONCURRENCY_GROUP = "CI-${{ github.event.pull_request.number || github.ref }}";
136
147
  export declare function renderCiWorkflowYaml(options: CiWorkflowDefinitionOptions): string;
137
148
  /** Job env for `.npmrc` token expansion. Registry URL is not a GitHub variable. */
138
149
  export declare function privateNpmReadTokenJobEnv(options: Pick<CiWorkflowDefinitionOptions, 'privateNpm'>): string;
@@ -199,6 +210,8 @@ export declare function normalizeCargoCredentials(config: PackageCargoCredential
199
210
  * checked-in managed output byte-identical across regeneration and hooks.
200
211
  */
201
212
  export declare const SAME_REPO_GATE_FOLDED: string[];
213
+ /** A job's `environment:` line, or nothing when no GitHub Environment is declared. */
214
+ export declare function environmentLine(name: string | undefined): string;
202
215
  /**
203
216
  * The step-scoped `env:` block for a deploy step. Step scope is the property
204
217
  * being rendered, not an accident of indentation: job env would hand the
@@ -211,5 +224,12 @@ export declare const SAME_REPO_GATE_FOLDED: string[];
211
224
  * once in `deploySecrets` instead of being overridden here.
212
225
  */
213
226
  export declare function deployStepSecretEnvLines(config: DeployStepSecretConfig): string[];
227
+ /**
228
+ * The step env for a step that acts on Cloudflare as the stage deploy did: the
229
+ * two Cloudflare credentials, read from the secrets `deployStepSecretEnvLines`
230
+ * names for them, and none of the other deploy secrets, which such a step
231
+ * never uses.
232
+ */
233
+ export declare function cloudflareCredentialEnvLines(deploySecrets: Record<string, string> | undefined): string[];
214
234
  export declare function artifactStepLines(provider: PackageSmooGithub['actionsProvider'], name: string, kind: 'upload' | 'download', inputs: readonly string[], condition?: string): string[];
215
235
  //# sourceMappingURL=ci-workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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6E;AAC7E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,CAgB/F;AA+BD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,6BAA6B,GAAG,SAAS,GAAG,MAAM,CASpG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,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"}
@@ -63,6 +63,17 @@ export function defineCiWorkflow(options) {
63
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' });
64
64
  return steps.map((step, index) => ({ ...step, number: index + 2 }));
65
65
  }
66
+ /**
67
+ * CI's concurrency group: one per pull request, by its number, and one per ref
68
+ * for pushes. The PR preview cleanup joins the same group, so a pull request's
69
+ * close cancels its running CI and the cleanup starts only after that run's
70
+ * stage deploy has stopped. The number, not `github.ref`, names a pull
71
+ * request's group: a close that merged it carries the base branch's ref, which
72
+ * would put the cleanup in the base branch's own group, and a forge may spell a
73
+ * pull request's ref after its merge or after its head. Spelled literally
74
+ * rather than from `github.workflow`, which a forge may fill with the file name.
75
+ */
76
+ export const CI_CONCURRENCY_GROUP = 'CI-${{ github.event.pull_request.number || github.ref }}';
66
77
  export function renderCiWorkflowYaml(options) {
67
78
  const steps = defineCiWorkflow(options);
68
79
  return [
@@ -90,17 +101,18 @@ ${options.deploy ? ' deployments: write\n' : ''} statuses: write
90
101
 
91
102
  concurrency:
92
103
  ${options.deploy
93
- ? ` # One in-flight run per ref. Pushes to the staging push branch queue behind a
94
- # running workflow instead of canceling it, so a newer push never cancels the
95
- # deploy job mid-flight. Pull requests and other branches keep canceling
96
- # superseded runs.
97
- group: \${{ github.workflow }}-\${{ github.ref }}
104
+ ? ` # One in-flight run per pull request, and per ref for pushes. Pushes to the
105
+ # staging push branch queue behind a running workflow instead of canceling it,
106
+ # so a newer push never cancels the deploy job mid-flight. Pull requests and
107
+ # other branches keep canceling superseded runs.
108
+ group: ${CI_CONCURRENCY_GROUP}
98
109
  cancel-in-progress: \${{ github.ref != ${stagingRefLiteral(options)} }}`
99
110
  : ` # This workflow validates and never deploys, so there is no in-flight
100
- # deployment for a newer push to protect: every ref cancels its superseded
101
- # runs. Queuing them instead serializes the staging branch, and a burst of
102
- # pushes then reports the newest commit one full run per queued push late.
103
- group: \${{ github.workflow }}-\${{ github.ref }}
111
+ # deployment for a newer push to protect: every pull request, and every ref
112
+ # for pushes, cancels its superseded runs. Queuing them instead serializes
113
+ # the staging branch, and a burst of pushes then reports the newest commit
114
+ # one full run per queued push late.
115
+ group: ${CI_CONCURRENCY_GROUP}
104
116
  cancel-in-progress: true`}
105
117
 
106
118
  defaults:
@@ -806,9 +818,15 @@ function yamlScalar(value) {
806
818
  function stagingRefLiteral(options) {
807
819
  return `'refs/heads/${stagingPushBranch(options).replaceAll("'", "''")}'`;
808
820
  }
809
- function environmentLine(name) {
821
+ /** A job's `environment:` line, or nothing when no GitHub Environment is declared. */
822
+ export function environmentLine(name) {
810
823
  return name ? ` environment: ${yamlScalar(name)}\n` : '';
811
824
  }
825
+ /** The Cloudflare credentials a deploy step carries, env var name → default repository secret name. */
826
+ const CLOUDFLARE_DEPLOY_SECRETS = {
827
+ CLOUDFLARE_API_TOKEN: 'CLOUDFLARE_API_TOKEN',
828
+ CLOUDFLARE_ACCOUNT_ID: 'CLOUDFLARE_ACCOUNT_ID',
829
+ };
812
830
  /**
813
831
  * The step-scoped `env:` block for a deploy step. Step scope is the property
814
832
  * being rendered, not an accident of indentation: job env would hand the
@@ -821,11 +839,22 @@ function environmentLine(name) {
821
839
  * once in `deploySecrets` instead of being overridden here.
822
840
  */
823
841
  export function deployStepSecretEnvLines(config) {
824
- const cloudflare = config.deployProvider === 'cloudflare'
825
- ? { CLOUDFLARE_API_TOKEN: 'CLOUDFLARE_API_TOKEN', CLOUDFLARE_ACCOUNT_ID: 'CLOUDFLARE_ACCOUNT_ID' }
826
- : {};
842
+ const cloudflare = config.deployProvider === 'cloudflare' ? CLOUDFLARE_DEPLOY_SECRETS : {};
827
843
  return secretEnvLines({ ...cloudflare, ...config.deploySecrets });
828
844
  }
845
+ /**
846
+ * The step env for a step that acts on Cloudflare as the stage deploy did: the
847
+ * two Cloudflare credentials, read from the secrets `deployStepSecretEnvLines`
848
+ * names for them, and none of the other deploy secrets, which such a step
849
+ * never uses.
850
+ */
851
+ export function cloudflareCredentialEnvLines(deploySecrets) {
852
+ const credentials = Object.entries(CLOUDFLARE_DEPLOY_SECRETS).map(([name, secret]) => [
853
+ name,
854
+ deploySecrets?.[name] ?? secret,
855
+ ]);
856
+ return secretEnvLines(Object.fromEntries(credentials));
857
+ }
829
858
  /** A step-level `env:` block mapping env var names to repository secrets; nothing when there are none. */
830
859
  function secretEnvLines(secrets) {
831
860
  const entries = Object.entries(secrets);
@@ -55,5 +55,5 @@ export declare function managedFileTargetsForContext(context: ManagedFileContext
55
55
  /** Render all packaged templates before staging any workspace changes. */
56
56
  export declare function renderManagedFiles(context: ManagedFileContext): ManagedFile[];
57
57
  /** Renders a generated workflow through its real managed-file descriptor, so the context wiring is covered. */
58
- export declare function renderManagedWorkflowForTest(source: 'ci-workflow' | 'publish-workflow', context: ManagedFileContext): string;
58
+ export declare function renderManagedWorkflowForTest(source: 'ci-workflow' | 'publish-workflow' | 'pr-preview-cleanup-workflow', context: ManagedFileContext): string;
59
59
  //# sourceMappingURL=files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/managed-files/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,kBAAkB,EAAmD,MAAM,kBAAkB,CAAC;AAI5G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAa7C,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,uBAAuB,EAAE,OAAO,CAAC;IACjC,0BAA0B,EAAE,OAAO,CAAC;IACpC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,uBAAuB,EAAE,OAAO,CAAC;IACjC,8BAA8B,EAAE,OAAO,CAAC;IACxC,qBAAqB,CAAC,EAAE,YAAY,CAAC;IACrC,wBAAwB,CAAC,EAAE,YAAY,CAAC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AC,CAAC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,qFAAqF;IACrF,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC,wFAAwF;IACxF,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,sFAAsF;IACtF,eAAe,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAChD,kGAAkG;IAClG,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD,uGAAuG;IACvG,WAAW,CAAC,EAAE,wBAAwB,CAAC;IACvC;;;;OAIG;IACH,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;CACzC;AAED,sFAAsF;AACtF,eAAO,MAAM,gBAAgB;aAC3B,OAAO,EAAE,QAAQ;aACjB,GAAG,EAAE,aAAa;aAClB,IAAI,EAAE,2BAA2B;CACzB,CAAC;AAmJX,eAAO,MAAM,yBAAyB;;;GAAyE,CAAC;AAchH,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAElF;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,EAAE,CAM7E;AAED,+GAA+G;AAC/G,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,GAAG,kBAAkB,GAAG,6BAA6B,EAC1E,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAMR"}
@@ -235,7 +235,14 @@ function getManagedContent(file, context) {
235
235
  });
236
236
  }
237
237
  if (file.source === 'pr-preview-cleanup-workflow') {
238
- return renderPrPreviewCleanupWorkflowYaml({ runsOn: context.ciRunsOn });
238
+ return renderPrPreviewCleanupWorkflowYaml({
239
+ runsOn: context.ciRunsOn,
240
+ privateNpm: context.privateNpm,
241
+ sourceCheckouts: context.sourceCheckouts,
242
+ cargoCredentials: context.cargoCredentials,
243
+ environments: context.ciEnvironments,
244
+ deploySecrets: context.ciDeploySecrets,
245
+ });
239
246
  }
240
247
  throw new Error(`Unknown generated managed file source ${file.source}`);
241
248
  }
@@ -1,5 +1,42 @@
1
+ import type { PackageCargoCredentialsConfig, PackagePrivateNpmConfig, PackageSmooGithubEnvironments, PackageSourceCheckoutConfig } from '../workspace-manifest.js';
1
2
  export interface PrPreviewCleanupWorkflowOptions {
2
3
  runsOn?: string | string[];
4
+ /**
5
+ * Declared private-npm opt-in. The job runs setup-devenv, whose dependency
6
+ * install refuses in CI when a declared registry credential is absent from
7
+ * the job environment, so the read token rides the job env exactly as it
8
+ * does on every CI job that runs setup-devenv. The remote-cache token stays
9
+ * out: shell entry defers it, and nothing in this job runs Nx.
10
+ */
11
+ privateNpm?: PackagePrivateNpmConfig;
12
+ /**
13
+ * Declared sibling source checkouts, cloned before setup-devenv as on every
14
+ * CI job that runs it: the devenv shell and the install resolve path
15
+ * dependencies on them.
16
+ */
17
+ sourceCheckouts?: PackageSourceCheckoutConfig[];
18
+ /**
19
+ * Declared Cargo credentials, rendered as on every CI job that runs
20
+ * setup-devenv: the tokens at job level, where setup resolves the declared
21
+ * secrets, and the credential step before the sibling clones. That step is
22
+ * not only for Cargo: later git commands in the job read the git
23
+ * configuration it writes to GITHUB_ENV (the credential helper, the runner
24
+ * proxy, the rewrite from each origin to its internal mirror), so a sibling
25
+ * clone declared without `tokenEnv` takes the mirror as it does in CI. One
26
+ * declared with `tokenEnv` sets GIT_CONFIG_COUNT=1 for its own auth header,
27
+ * which replaces that configuration: it gets no helper, proxy or rewrite.
28
+ */
29
+ cargoCredentials?: PackageCargoCredentialsConfig;
30
+ /**
31
+ * The cleanup deletes what the stage deploy created, in the account the
32
+ * deploy's CLOUDFLARE_ACCOUNT_ID names, so it must read the credentials
33
+ * that deploy read. The job therefore runs in the staging Environment the
34
+ * stage deploy runs in, whose secrets shadow the repository's, and reads
35
+ * the Cloudflare credentials through the same `deploySecrets` mapping.
36
+ */
37
+ environments?: PackageSmooGithubEnvironments;
38
+ /** Deploy-step secrets; only the two Cloudflare credentials reach the cleanup. */
39
+ deploySecrets?: Record<string, string>;
3
40
  }
4
41
  export declare function renderPrPreviewCleanupWorkflowYaml(options?: PrPreviewCleanupWorkflowOptions): string;
5
42
  //# sourceMappingURL=pr-preview-cleanup-workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pr-preview-cleanup-workflow.d.ts","sourceRoot":"","sources":["../../src/managed-files/pr-preview-cleanup-workflow.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,+BAA+B;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED,wBAAgB,kCAAkC,CAAC,OAAO,GAAE,+BAAoC,GAAG,MAAM,CAmCxG"}
1
+ {"version":3,"file":"pr-preview-cleanup-workflow.d.ts","sourceRoot":"","sources":["../../src/managed-files/pr-preview-cleanup-workflow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,0BAA0B,CAAC;AAalC,MAAM,WAAW,+BAA+B;IAC9C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC;;;;OAIG;IACH,eAAe,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAChD;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,6BAA6B,CAAC;IAC7C,kFAAkF;IAClF,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED,wBAAgB,kCAAkC,CAAC,OAAO,GAAE,+BAAoC,GAAG,MAAM,CAwCxG"}