@smoothbricks/nx-plugin 0.4.20 → 0.4.22
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 +89 -18
- package/dist/bin/smoo-nx-cargo-hash.js +32 -4
- package/dist/cargo-source-hash.d.ts +10 -1
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +251 -41
- package/dist/cargo-workspace.d.ts +0 -1
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +9 -2
- package/dist/ensure-built.d.ts +6 -5
- package/dist/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +227 -30
- package/dist/index.js +18 -10
- package/dist/managed-files/ci-workflow.d.ts +20 -0
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +42 -13
- package/dist/managed-files/files.d.ts +1 -1
- package/dist/managed-files/files.d.ts.map +1 -1
- package/dist/managed-files/files.js +8 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +37 -0
- package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -1
- package/dist/managed-files/pr-preview-cleanup-workflow.js +34 -6
- package/dist/workspace-manifest.d.ts +3 -1
- package/dist/workspace-manifest.d.ts.map +1 -1
- package/managed/raw/tooling/direnv/setup-environment.ts +23 -91
- package/managed/raw/tooling/git-hooks/commit-msg.sh +6 -0
- package/managed/raw/tooling/git-hooks/pre-commit.sh +6 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +6 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +19 -7
- package/package.json +1 -1
- package/src/bin/smoo-nx-cargo-hash.ts +29 -5
- package/src/cargo-source-hash.test.ts +291 -1
- package/src/cargo-source-hash.ts +190 -28
- package/src/cargo-workspace.test.ts +17 -10
- package/src/cargo-workspace.ts +9 -3
- package/src/ensure-built.test.ts +87 -29
- package/src/ensure-built.ts +274 -29
- package/src/index.test.ts +117 -20
- package/src/index.ts +18 -11
- package/src/managed-files/ci-workflow.ts +45 -14
- package/src/managed-files/files.ts +9 -2
- package/src/managed-files/generator.test.ts +5 -1
- package/src/managed-files/github-host-cache-isolation.test.ts +32 -6
- package/src/managed-files/pr-preview-cleanup-workflow.ts +87 -6
- package/src/workspace-manifest.ts +3 -1
|
@@ -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":"
|
|
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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* biome-ignore-all lint/suspicious/noTemplateCurlyInString: GitHub Actions expressions are emitted literally. */
|
|
2
|
+
import { CI_CONCURRENCY_GROUP, CiWorkflowStepKind, cargoCredentialJobEnvLines, cargoCredentialStepLines, cloudflareCredentialEnvLines, environmentLine, privateNpmReadTokenJobEnv, sourceCheckoutsStepLines, } from './ci-workflow.js';
|
|
2
3
|
import { renderRunsOnLine } from './github-runs-on.js';
|
|
3
4
|
export function renderPrPreviewCleanupWorkflowYaml(options = {}) {
|
|
4
5
|
return `name: PR Preview Cleanup
|
|
@@ -10,29 +11,56 @@ on:
|
|
|
10
11
|
permissions:
|
|
11
12
|
contents: read
|
|
12
13
|
|
|
14
|
+
# The pull request's CI group, named by its number whether the close merged it
|
|
15
|
+
# or not: closing it cancels its running CI run, so the cleanup starts only
|
|
16
|
+
# after that run's stage deploy has stopped.
|
|
17
|
+
concurrency:
|
|
18
|
+
group: ${CI_CONCURRENCY_GROUP}
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
|
|
13
21
|
jobs:
|
|
14
22
|
cleanup:
|
|
15
23
|
name: Cleanup PR environment
|
|
16
24
|
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
17
25
|
${renderRunsOnLine(options.runsOn)}
|
|
18
26
|
timeout-minutes: 15
|
|
19
|
-
defaults:
|
|
27
|
+
${environmentLine(options.environments?.staging)} defaults:
|
|
20
28
|
run:
|
|
21
29
|
working-directory: tooling/direnv
|
|
22
|
-
steps:
|
|
30
|
+
${setupJobEnv(options)} steps:
|
|
23
31
|
- name: Checkout
|
|
24
32
|
uses: actions/checkout@v6.0.2
|
|
25
33
|
with:
|
|
26
34
|
filter: blob:none
|
|
27
35
|
fetch-depth: 1
|
|
28
|
-
|
|
36
|
+
${preflightSteps(options)}
|
|
29
37
|
- name: Setup Nix/devenv
|
|
30
38
|
uses: ./.github/actions/setup-devenv
|
|
31
39
|
|
|
32
40
|
- name: Cleanup PR environment
|
|
33
|
-
|
|
34
|
-
CLOUDFLARE_API_TOKEN: \${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
35
|
-
CLOUDFLARE_ACCOUNT_ID: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
41
|
+
${cloudflareCredentialEnvLines(options.deploySecrets).join('\n')}
|
|
36
42
|
run: smoo wrangler cleanup-pr --pr \${{ github.event.pull_request.number }}
|
|
37
43
|
`;
|
|
38
44
|
}
|
|
45
|
+
/** The job env setup-devenv needs, as the CI jobs spell it; nothing for a repository that declares no credential. */
|
|
46
|
+
function setupJobEnv(options) {
|
|
47
|
+
const tokenLines = `${cargoCredentialJobEnvLines(options.cargoCredentials)}${privateNpmReadTokenJobEnv(options)}`;
|
|
48
|
+
return tokenLines === '' ? '' : ` env:\n${tokenLines}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The CI jobs' steps between checkout and setup-devenv, in their order and each
|
|
52
|
+
* set off by blank lines: the Cargo credential step, then the sibling-source
|
|
53
|
+
* clones. Nothing when neither is declared.
|
|
54
|
+
*/
|
|
55
|
+
function preflightSteps(options) {
|
|
56
|
+
const steps = [];
|
|
57
|
+
if (options.cargoCredentials !== undefined) {
|
|
58
|
+
const step = { kind: CiWorkflowStepKind.CargoCredentials, name: 'Prepare Cargo credentials', number: 0 };
|
|
59
|
+
steps.push(cargoCredentialStepLines(step, options.cargoCredentials));
|
|
60
|
+
}
|
|
61
|
+
if (options.sourceCheckouts?.length) {
|
|
62
|
+
const step = { kind: CiWorkflowStepKind.SourceCheckouts, name: 'Check out sibling sources', number: 0 };
|
|
63
|
+
steps.push(sourceCheckoutsStepLines(step, options.sourceCheckouts));
|
|
64
|
+
}
|
|
65
|
+
return steps.map((lines) => `\n${lines.join('\n')}\n`).join('');
|
|
66
|
+
}
|
|
@@ -32,7 +32,7 @@ export interface PackagePublishConfig {
|
|
|
32
32
|
registry?: string;
|
|
33
33
|
}
|
|
34
34
|
export interface PackageSmooGithubEnvironments {
|
|
35
|
-
/** GitHub Environment for the staging deploy and
|
|
35
|
+
/** GitHub Environment for the staging deploy, e2e and PR preview cleanup jobs. */
|
|
36
36
|
staging?: string;
|
|
37
37
|
/** GitHub Environment for the production-on-push deploy job. */
|
|
38
38
|
production?: string;
|
|
@@ -247,6 +247,8 @@ export interface PackageJson {
|
|
|
247
247
|
optionalDependencies?: StringMap;
|
|
248
248
|
/** Bun patchedDependencies map (package@version → patch path). */
|
|
249
249
|
patchedDependencies?: StringMap;
|
|
250
|
+
overrides?: StringMap;
|
|
251
|
+
resolutions?: StringMap;
|
|
250
252
|
engines?: StringMap;
|
|
251
253
|
scripts?: StringMap;
|
|
252
254
|
publishConfig?: PackagePublishConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-manifest.d.ts","sourceRoot":"","sources":["../src/workspace-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/C,2DAA2D;AAC3D,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAE3C,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAEnE;AAED,mHAAmH;AACnH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAE1D;;;G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
|
|
12
12
|
} from 'node:fs';
|
|
13
|
-
import { mkdir, rmdir, stat } from 'node:fs/promises';
|
|
14
13
|
import { createRequire } from 'node:module';
|
|
15
14
|
import path from 'node:path';
|
|
16
15
|
import { $ } from 'bun';
|
|
@@ -78,12 +77,6 @@ async function resolveProjectRoot(): Promise<string> {
|
|
|
78
77
|
|
|
79
78
|
const projectRoot = await resolveProjectRoot();
|
|
80
79
|
|
|
81
|
-
// A legitimate concurrent setup finishes well within this; anything older is a
|
|
82
|
-
// leftover from an interrupted run (CTRL-C/kill before the finally-cleanup) and
|
|
83
|
-
// would otherwise wedge every future shell load behind the 120s spin + EEXIST.
|
|
84
|
-
// NOTE: must be declared ABOVE the top-level setup block below — module consts
|
|
85
|
-
// are not hoisted, and the lock loop runs during that block.
|
|
86
|
-
const STALE_LOCK_MS = 10 * 60_000;
|
|
87
80
|
// Unscoped require("typescript") must expose the TS6 compiler API for Nx.
|
|
88
81
|
// @typescript/native installs another package also named "typescript" (TS7). Bun's
|
|
89
82
|
// isolated linker RACES the node_modules/.bun/node_modules/typescript fallback link
|
|
@@ -124,28 +117,24 @@ try {
|
|
|
124
117
|
// and package resolution/Typia transforms are not available yet.
|
|
125
118
|
if (process.env.CI) {
|
|
126
119
|
await resolveSecrets();
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
// skips the finally that releases the lock and strands it, so failures
|
|
132
|
-
// are captured inside and reported outside.
|
|
120
|
+
// Failures are captured and reported below. Exiting in the catch would
|
|
121
|
+
// skip the git-diff diagnostic that follows a frozen-lockfile miss.
|
|
122
|
+
// bun install already races concurrent installs with an atomic cache
|
|
123
|
+
// rename; this script does not add a second mutex around it.
|
|
133
124
|
let frozenError: unknown;
|
|
134
125
|
let fallbackError: unknown;
|
|
135
|
-
|
|
126
|
+
try {
|
|
127
|
+
await runSetupCommand('bun install --frozen-lockfile', $`bun install --frozen-lockfile`, { quiet: false });
|
|
128
|
+
} catch (error) {
|
|
129
|
+
frozenError = error;
|
|
130
|
+
console.error('! Failed to install dependencies with frozen lockfile');
|
|
131
|
+
replayCapturedOutput(error);
|
|
136
132
|
try {
|
|
137
|
-
await runSetupCommand('bun install
|
|
138
|
-
} catch (
|
|
139
|
-
|
|
140
|
-
console.error('! Failed to install dependencies with frozen lockfile');
|
|
141
|
-
replayCapturedOutput(error);
|
|
142
|
-
try {
|
|
143
|
-
await runSetupCommand('bun install', $`bun install`, { quiet: false });
|
|
144
|
-
} catch (fallback) {
|
|
145
|
-
fallbackError = fallback;
|
|
146
|
-
}
|
|
133
|
+
await runSetupCommand('bun install', $`bun install`, { quiet: false });
|
|
134
|
+
} catch (fallback) {
|
|
135
|
+
fallbackError = fallback;
|
|
147
136
|
}
|
|
148
|
-
}
|
|
137
|
+
}
|
|
149
138
|
if (fallbackError !== undefined) {
|
|
150
139
|
reportSetupFailure(fallbackError);
|
|
151
140
|
}
|
|
@@ -214,19 +203,15 @@ async function installLocalDependencies(): Promise<unknown> {
|
|
|
214
203
|
} catch (error) {
|
|
215
204
|
return error;
|
|
216
205
|
}
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
installError = error;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
return installError;
|
|
206
|
+
// Returned, not thrown: the caller still wires git config, then reports a
|
|
207
|
+
// degraded shell. Same reason as the CI branch — bun install's own rename
|
|
208
|
+
// is the concurrency control, not a lock in this script.
|
|
209
|
+
try {
|
|
210
|
+
await runSetupCommand('bun install --no-summary', $`bun install --no-summary`);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
return error;
|
|
213
|
+
}
|
|
214
|
+
return undefined;
|
|
230
215
|
}
|
|
231
216
|
|
|
232
217
|
function ensureTypeScriptApiPackage(root: string): void {
|
|
@@ -457,59 +442,6 @@ async function runSetupCommand(
|
|
|
457
442
|
}
|
|
458
443
|
}
|
|
459
444
|
|
|
460
|
-
async function withSetupLock<T>(fn: () => Promise<T>): Promise<T> {
|
|
461
|
-
const lockDir = path.join(projectRoot, 'tooling/direnv/.devenv/setup-environment.lock');
|
|
462
|
-
await acquireLock(lockDir);
|
|
463
|
-
try {
|
|
464
|
-
return await fn();
|
|
465
|
-
} finally {
|
|
466
|
-
await rmdir(lockDir).catch(() => undefined);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
async function acquireLock(lockDir: string): Promise<void> {
|
|
471
|
-
const deadline = Date.now() + 120_000;
|
|
472
|
-
while (true) {
|
|
473
|
-
try {
|
|
474
|
-
await mkdir(lockDir, { recursive: false });
|
|
475
|
-
return;
|
|
476
|
-
} catch (error) {
|
|
477
|
-
if (!isFileExistsError(error) || Date.now() > deadline) {
|
|
478
|
-
throw error;
|
|
479
|
-
}
|
|
480
|
-
if (await isStaleLock(lockDir)) {
|
|
481
|
-
// Surface the self-heal so an interrupted-run leftover is visible in
|
|
482
|
-
// the direnv log rather than silently absorbed.
|
|
483
|
-
console.error(`! Breaking stale setup lock (${lockDir}) left by an interrupted run`);
|
|
484
|
-
// Best-effort: if a concurrent process breaks it first, the rmdir
|
|
485
|
-
// fails silently and the next mkdir attempt settles the race.
|
|
486
|
-
await rmdir(lockDir).catch(() => undefined);
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
await Bun.sleep(100);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
async function isStaleLock(lockDir: string): Promise<boolean> {
|
|
495
|
-
try {
|
|
496
|
-
const info = await stat(lockDir);
|
|
497
|
-
return Date.now() - info.mtimeMs > STALE_LOCK_MS;
|
|
498
|
-
} catch (error) {
|
|
499
|
-
// Only "lock vanished" is expected here (a concurrent process released
|
|
500
|
-
// it); anything else must surface — a swallowed ReferenceError in this
|
|
501
|
-
// exact spot once disabled stale detection entirely.
|
|
502
|
-
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
503
|
-
return false; // gone — let the mkdir retry acquire it
|
|
504
|
-
}
|
|
505
|
-
throw error;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function isFileExistsError(error: unknown): boolean {
|
|
510
|
-
return error instanceof Error && 'code' in error && error.code === 'EEXIST';
|
|
511
|
-
}
|
|
512
|
-
|
|
513
445
|
function reportSetupFailure(error: unknown): never {
|
|
514
446
|
describeFailure('ERROR', error);
|
|
515
447
|
process.exit(1);
|
|
@@ -3,6 +3,12 @@ cd "$(git rev-parse --show-toplevel)"
|
|
|
3
3
|
TOOLING="$PWD/tooling"
|
|
4
4
|
|
|
5
5
|
export PATH="$("$TOOLING/direnv/repo-path")"
|
|
6
|
+
# ttsc compiles with the native TypeScript compiler, which the dev shell names in
|
|
7
|
+
# TTSC_TSGO_BINARY. A hook runs outside that shell, where ttsc would resolve the
|
|
8
|
+
# JavaScript compiler a package's `typescript` dependency names and refuse to run.
|
|
9
|
+
if [ -z "${TTSC_TSGO_BINARY:-}" ] && [ -x "$PWD/node_modules/@typescript/native/bin/tsc" ]; then
|
|
10
|
+
export TTSC_TSGO_BINARY="$PWD/node_modules/@typescript/native/bin/tsc"
|
|
11
|
+
fi
|
|
6
12
|
|
|
7
13
|
set -e -o pipefail
|
|
8
14
|
|
|
@@ -3,6 +3,12 @@ cd "$(git rev-parse --show-toplevel)"
|
|
|
3
3
|
TOOLING="$PWD/tooling"
|
|
4
4
|
|
|
5
5
|
export PATH="$("$TOOLING/direnv/repo-path")"
|
|
6
|
+
# ttsc compiles with the native TypeScript compiler, which the dev shell names in
|
|
7
|
+
# TTSC_TSGO_BINARY. A hook runs outside that shell, where ttsc would resolve the
|
|
8
|
+
# JavaScript compiler a package's `typescript` dependency names and refuse to run.
|
|
9
|
+
if [ -z "${TTSC_TSGO_BINARY:-}" ] && [ -x "$PWD/node_modules/@typescript/native/bin/tsc" ]; then
|
|
10
|
+
export TTSC_TSGO_BINARY="$PWD/node_modules/@typescript/native/bin/tsc"
|
|
11
|
+
fi
|
|
6
12
|
|
|
7
13
|
set -e -o pipefail
|
|
8
14
|
|
|
@@ -25,6 +25,12 @@ cd "$(git rev-parse --show-toplevel)"
|
|
|
25
25
|
TOOLING="$PWD/tooling"
|
|
26
26
|
|
|
27
27
|
export PATH="$("$TOOLING/direnv/repo-path")"
|
|
28
|
+
# ttsc compiles with the native TypeScript compiler, which the dev shell names in
|
|
29
|
+
# TTSC_TSGO_BINARY. A hook runs outside that shell, where ttsc would resolve the
|
|
30
|
+
# JavaScript compiler a package's `typescript` dependency names and refuse to run.
|
|
31
|
+
if [ -z "${TTSC_TSGO_BINARY:-}" ] && [ -x "$PWD/node_modules/@typescript/native/bin/tsc" ]; then
|
|
32
|
+
export TTSC_TSGO_BINARY="$PWD/node_modules/@typescript/native/bin/tsc"
|
|
33
|
+
fi
|
|
28
34
|
|
|
29
35
|
case "$(uname -s)" in
|
|
30
36
|
Darwin) ;;
|
|
@@ -73,19 +73,26 @@ runs:
|
|
|
73
73
|
# and that DB lives in workspace-data. Since CI and Publish sit in
|
|
74
74
|
# different concurrency groups they run simultaneously on one host, so a
|
|
75
75
|
# repository-wide tree let one workflow rewrite the other's graph state
|
|
76
|
-
# mid-read.
|
|
77
|
-
#
|
|
76
|
+
# mid-read. Per workflow alone is not enough either: CI's concurrency
|
|
77
|
+
# group is per pull request (by number), or per ref for pushes, so
|
|
78
|
+
# separate PRs and jobs run at once and must never share mutable graph
|
|
79
|
+
# or eval state. The scope hashes that same identity, not github.ref: a
|
|
80
|
+
# merged close carries the base branch's ref, so two pull requests'
|
|
81
|
+
# cleanups merged a minute apart would share one scope while running in
|
|
82
|
+
# different concurrency groups.
|
|
78
83
|
# Hash the exact identity (not a lossy path slug); keep cache artifacts
|
|
79
|
-
# and their metadata DB together, warm across runs of the same
|
|
84
|
+
# and their metadata DB together, warm across runs of the same pull
|
|
85
|
+
# request or ref and job.
|
|
80
86
|
- name: 📂 Locate the Nx cache on the shared bind
|
|
81
87
|
if: steps.runner-kind.outputs.host == 'true'
|
|
82
88
|
shell: bash
|
|
83
89
|
env:
|
|
84
90
|
NX_CACHE_REPO: ${{ github.repository }}
|
|
85
91
|
NX_CACHE_LANE: ${{ github.workflow }}
|
|
92
|
+
SCOPE_REF: ${{ github.event.pull_request.number || github.ref }}
|
|
86
93
|
run: |
|
|
87
94
|
lane=$(printf '%s' "$NX_CACHE_LANE" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9._-' '-')
|
|
88
|
-
scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$
|
|
95
|
+
scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$SCOPE_REF" "$GITHUB_JOB" "$RUNNER_OS" "$RUNNER_ARCH" | git hash-object --stdin)
|
|
89
96
|
NX_CACHE_ROOT="/var/cache/ci/nx/$NX_CACHE_REPO/${lane:-default}/$scope"
|
|
90
97
|
mkdir -p "$NX_CACHE_ROOT/cache" "$NX_CACHE_ROOT/workspace-data"
|
|
91
98
|
{
|
|
@@ -102,8 +109,12 @@ runs:
|
|
|
102
109
|
# .devenv (eval SQLite, gc roots, profile) and .direnv survive the job, so
|
|
103
110
|
# the next job on this host evaluates nothing and downloads nothing. The
|
|
104
111
|
# Actions cache segment below is the ephemeral runners' substitute for this.
|
|
105
|
-
# Scoped per workflow
|
|
106
|
-
# jobs can overlap, and one
|
|
112
|
+
# Scoped per workflow, pull request (by number) or ref for pushes, job and
|
|
113
|
+
# platform, like Nx: separate PR runs and jobs can overlap, and one
|
|
114
|
+
# eval-cache.db must have only one writer. Not per github.ref: a merged
|
|
115
|
+
# close carries the base branch's ref, so two pull requests' cleanups
|
|
116
|
+
# would share this state and the second's bind mount below would shadow
|
|
117
|
+
# the first's workspace.
|
|
107
118
|
#
|
|
108
119
|
# The eval cache keys on canonical absolute paths, and act's host executor
|
|
109
120
|
# checks out under <cache>/<random 8 chars>/hostexecutor - a new path every
|
|
@@ -124,9 +135,10 @@ runs:
|
|
|
124
135
|
DEVENV_STATE_REPO: ${{ github.repository }}
|
|
125
136
|
DEVENV_STATE_LANE: ${{ github.workflow }}
|
|
126
137
|
DEVENV_STATE_JOB: ${{ github.job }}
|
|
138
|
+
SCOPE_REF: ${{ github.event.pull_request.number || github.ref }}
|
|
127
139
|
run: |
|
|
128
140
|
lane=$(printf '%s' "$DEVENV_STATE_LANE" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9._-' '-')
|
|
129
|
-
scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$
|
|
141
|
+
scope=$(printf '%s\0%s\0%s\0%s\0%s' "$GITHUB_WORKFLOW" "$SCOPE_REF" "$GITHUB_JOB" "$RUNNER_OS" "$RUNNER_ARCH" | git hash-object --stdin)
|
|
130
142
|
root="/var/cache/ci/devenv/$DEVENV_STATE_REPO/${lane:-default}/$DEVENV_STATE_JOB/$scope"
|
|
131
143
|
mkdir -p "$root/.devenv" "$root/.direnv"
|
|
132
144
|
rm -rf tooling/direnv/.devenv tooling/direnv/.direnv
|
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { hashCargoPathInputs } from '../cargo-source-hash.js';
|
|
3
|
+
import { type CargoPathInputsOptions, hashCargoPathInputs } from '../cargo-source-hash.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** Flags first, in any order and at most once each, then at most one manifest; anything else is refused. */
|
|
6
|
+
function parseArguments(args: readonly string[]): { manifest: string; options: CargoPathInputsOptions } | undefined {
|
|
7
|
+
const options: CargoPathInputsOptions = {};
|
|
8
|
+
let index = 0;
|
|
9
|
+
for (; index < args.length; index += 1) {
|
|
10
|
+
const arg = args[index];
|
|
11
|
+
if (arg === '--include-workspace' && options.includeWorkspace === undefined) {
|
|
12
|
+
options.includeWorkspace = true;
|
|
13
|
+
} else if (arg === '--closure' && options.closure === undefined) {
|
|
14
|
+
const directory = args[index + 1];
|
|
15
|
+
if (directory === undefined || directory.startsWith('-')) return undefined;
|
|
16
|
+
options.closure = directory;
|
|
17
|
+
index += 1;
|
|
18
|
+
} else if (arg?.startsWith('-')) {
|
|
19
|
+
return undefined;
|
|
20
|
+
} else {
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const rest = args.slice(index);
|
|
25
|
+
if (rest.length > 1) return undefined;
|
|
26
|
+
return { manifest: rest[0] ?? 'Cargo.toml', options };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const parsed = parseArguments(process.argv.slice(2));
|
|
30
|
+
if (parsed === undefined) {
|
|
31
|
+
process.stderr.write('usage: smoo-nx-cargo-hash [--include-workspace] [--closure <directory>] [Cargo.toml]\n');
|
|
8
32
|
process.exit(2);
|
|
9
33
|
}
|
|
10
34
|
try {
|
|
11
|
-
process.stdout.write(`${await hashCargoPathInputs(resolve(
|
|
35
|
+
process.stdout.write(`${await hashCargoPathInputs(resolve(parsed.manifest), process.cwd(), parsed.options)}\n`);
|
|
12
36
|
} catch (error) {
|
|
13
37
|
process.stderr.write(`smoo-nx-cargo-hash: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
14
38
|
process.stderr.write(
|