Skip to content

Commit

The deploy's stages ride out a dropped npm connection as CI does. Each core, edge and front job keeps npm's downloads between runs (actions/cache on ~/.npm, keyed on the lockfile), and the deploy tool's install reads them first (npm ci --prefer-offline), so a registry connection reset mid-install no longer fails a stage, as it failed the web stage of Deploy 201.

syntaqxcommitted Parentdae1f7eBrowse files
3 files+16−30/3 viewed
+10−0
246246 - name: sccache
247247 if: ${{ matrix.rust || matrix.image }}
248248 run: bash scripts/sccache.sh install
249+ # npm's downloads, kept between runs as the check and migrate jobs
250+ # keep them: the install reads them first (--prefer-offline, in
251+ # scripts/deploy/stack.mjs) and asks the registry only for what
252+ # changed, so a connection it drops mid-install rarely stops a stage.
253+ - name: Cache npm's downloads
254+ uses: actions/cache@v4
255+ with:
256+ path: ~/.npm
257+ key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
258+ restore-keys: npm-${{ runner.os }}-
249259 - name: Install
250260 run: node scripts/deploy.mjs install --only "${{ matrix.units }}"
251261 - name: Deploy ${{ matrix.units }}
+2−2
602602
603603 test("a CI job installs only what its units need", () => {
604604 const npm = npmWorkspace();
605− assert.deepEqual(npmCiArgs([unit("events"), unit("repos")], npm), ["ci", "--no-audit", "--no-fund", "--workspaces=false"]);
605+ assert.deepEqual(npmCiArgs([unit("events"), unit("repos")], npm), ["ci", "--prefer-offline", "--no-audit", "--no-fund", "--workspaces=false"]);
606606 assert.deepEqual(npmCiArgs([unit("events"), unit("status")], npm), [
607− "ci", "--no-audit", "--no-fund", "--include-workspace-root",
607+ "ci", "--prefer-offline", "--no-audit", "--no-fund", "--include-workspace-root",
608608 "-w", "@g1t/contracts", "-w", "@g1t/status", "-w", "@g1t/theme",
609609 ]);
610610 });
+4−1
489489 * npm ci of only what the units need: Wrangler alone for Rust workers,
490490 * and each npm-built unit's workspace with the packages it uses. A CI job
491491 * that deploys three Rust workers does not install the site's toolchain.
492+ * --prefer-offline reads npm's cache first, which the deploy's jobs keep
493+ * between runs, so a registry connection dropped mid-install rarely
494+ * fails a stage.
492495 */
493496 export function npmCiArgs(units, npm) {
494497 const workspaces = new Set();
502505 stack.push(...(npm.get(name)?.deps ?? []));
503506 }
504507 }
505− const base = ["ci", "--no-audit", "--no-fund"];
508+ const base = ["ci", "--prefer-offline", "--no-audit", "--no-fund"];
506509 if (!workspaces.size) return [...base, "--workspaces=false"];
507510 return [...base, "--include-workspace-root", ...[...workspaces].sort().flatMap((name) => ["-w", name])];
508511 }