ci: reuse portable Turbo outputs across verification runs

This commit is contained in:
morluto
2026-10-11 18:43:22 +08:00
parent 12c416005f
commit a00c34dcb1
11 changed files with 63 additions and 4 deletions
@@ -0,0 +1,40 @@
name: Portable build cache
description: Reuse Turbo build outputs without serializing verification jobs.
inputs:
save:
description: Save newly built outputs after the job succeeds.
default: "false"
runs:
using: composite
steps:
- name: Resolve portable build task hashes
id: plan
shell: bash
env:
BUILD_CACHE_PREFIX: rea-portable-build-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.npmrc') }}
run: |
npm run --silent test:prepare -- --dry=json |
node --input-type=module -e '
import { createHash } from "node:crypto";
import { readFileSync } from "node:fs";
const { tasks } = JSON.parse(readFileSync(0, "utf8"));
const hashes = tasks.map(({ taskId, hash }) => {
if (typeof hash !== "string")
throw new Error(`Build task ${taskId} must have an eager Turbo hash`);
return `${taskId}:${hash}`;
}).sort();
const hash = createHash("sha256").update(hashes.join("\n")).digest("hex");
console.log(`key=${process.env.BUILD_CACHE_PREFIX}-${hash}`);
' >> "$GITHUB_OUTPUT"
- name: Restore portable build outputs
if: inputs.save != 'true'
uses: actions/cache/restore@v4
with:
path: .turbo/cache/
key: ${{ steps.plan.outputs.key }}
- name: Restore and save portable build outputs
if: inputs.save == 'true'
uses: actions/cache@v4
with:
path: .turbo/cache/
key: ${{ steps.plan.outputs.key }}
+4
View File
@@ -145,6 +145,10 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- name: Reuse portable build outputs across runs
uses: ./.github/actions/portable-build-cache
with:
save: "true"
- run: npm run test:prepare
- name: Find successful default-branch timing history
id: history
+1
View File
@@ -32,6 +32,7 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Acquire exact upstream libraries in an isolated runner environment
shell: bash
run: |
+2 -1
View File
@@ -22,9 +22,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- run: npm run verify:browser
env:
REA_BROWSER_EXECUTABLE: /usr/bin/google-chrome
+1
View File
@@ -26,6 +26,7 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Acquire unchanged fixture compiler in isolated runner storage
shell: bash
run: |
@@ -24,9 +24,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Fetch pinned Wakaru release into the job workspace
shell: bash
run: |
@@ -29,6 +29,7 @@ jobs:
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Install GDB on the disposable CI runner
shell: bash
run: |
@@ -28,6 +28,7 @@ jobs:
- name: Use pinned package manager
run: npm install --global [email protected]
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Acquire fixed upstream native profile in runner temporary storage
shell: bash
run: |
+2 -1
View File
@@ -17,9 +17,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- run: npm run verify:browser:runtime
env:
REA_BROWSER_EXECUTABLE: /usr/bin/google-chrome
+2 -1
View File
@@ -17,9 +17,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
node-version-file: .nvmrc
cache: npm
- run: npm ci
- uses: ./.github/actions/portable-build-cache
- name: Install the pinned compiler into an isolated fixture directory
run: npm install --prefix "$RUNNER_TEMP/rea-web-source-map-compiler" --no-audit --no-fund --package-lock=false [email protected]
- run: npm run verify:browser:source-maps
+7
View File
@@ -1015,6 +1015,13 @@ summary. Static checks, documentation, build, package verification, and
real-system lanes remain separate jobs so one kind of evidence cannot stand in
for another.
The build job saves portable Turbo outputs across runs. Eight Linux real-system
lanes restore this cache without waiting for the build job. The shared action
derives its key from `test:prepare --dry=json` task hashes, runner OS and
architecture, and `.npmrc`; test-only changes can reuse compiled outputs. Every
build and verification command still runs, so Turbo checks task inputs and
rebuilds misses. There is no prefix fallback to accumulate older build outputs.
Native package jobs reuse the same workflow's Turbo cache for portable compiled
JavaScript, skills, and catalogs. They retain the normal build and prepack
commands, which restore matching outputs or rebuild on a cache miss. Native