Skip to content

Commit 8d6ec91

Browse files
wan9chiclaude
andcommitted
ci: cache build:all with the remote task cache
The CI build job runs `vp run --cache build:all` against the remote task cache when the VP_REMOTE_CACHE_URL repository variable is set: pushes to main upload, pull requests and release runs only download. - The root `build` runs packages in dependency order, @void/md last. - @void/platform's runtime build writes `sourceRevision: null`; an uncached `build:stamp` step records the revision afterwards. @void/isr becomes a dev dependency, since the dispatch Worker bundles its build output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cd9de09 commit 8d6ec91

9 files changed

Lines changed: 51 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || matrix.os }}
2222
permissions:
2323
contents: read
24+
# Remote cache uploads authenticate with a GitHub Actions OIDC token.
25+
id-token: write
26+
env:
27+
# Remote task cache, on when the repository variable is set. Only pushes to main upload
28+
# results; pull requests and release runs only download, so unreviewed code can't publish
29+
# entries that main restores.
30+
VP_REMOTE_CACHE_URL: ${{ vars.VP_REMOTE_CACHE_URL }}
31+
VP_REMOTE_CACHE: ${{ !vars.VP_REMOTE_CACHE_URL && 'off' || (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'read-write' || 'read' }}
2432
strategy:
2533
fail-fast: false
2634
matrix:
@@ -32,7 +40,7 @@ jobs:
3240
- uses: ./.github/actions/test-setup
3341
# Build every playground once per OS for complete build/type coverage.
3442
# Integration tests build their own selected fixtures in separate checkouts.
35-
- run: vp run build:all
43+
- run: vp run --cache build:all
3644
- run: vp run build:docs
3745
- run: node test/check-playground-build-artifacts.mjs
3846
- run: vp run check

‎.github/workflows/publish.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
uses: ./.github/workflows/ci.yml
3131
permissions:
3232
contents: read
33+
# ci.yml's build job requests an OIDC token for remote cache uploads, so its caller must
34+
# grant it, though release runs only download.
35+
id-token: write
3336

3437
platform-ci:
3538
needs: validate-release

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"type": "module",
44
"scripts": {
5-
"build": "vp run --filter './packages/**' --parallel build",
5+
"build": "vp run --filter './packages/**' --filter '!./packages/md' build && vp run --filter ./packages/md build",
66
"build:core": "vp run --filter ./packages/deploy-core --filter ./packages/deploy-cloudflare --filter ./packages/edge --filter ./packages/isr --filter ./packages/platform --filter ./packages/void build",
77
"build:docs": "vp run --filter ./docs build",
88
"build:platform": "vp run --filter './platform/packages/**' build",

‎packages/platform/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"access": "public"
4343
},
4444
"scripts": {
45-
"build": "vp pack && node scripts/build-runtime.mjs",
45+
"build": "vp pack && node scripts/build-runtime.mjs && vp run build:stamp",
4646
"dev": "vp pack --watch",
4747
"typecheck": "tsc --noEmit"
4848
},
@@ -51,6 +51,7 @@
5151
},
5252
"devDependencies": {
5353
"@types/node": "catalog:",
54+
"@void/isr": "workspace:*",
5455
"typescript": "catalog:",
5556
"vite-plus": "catalog:",
5657
"wrangler": "catalog:"

‎packages/platform/scripts/build-runtime.mjs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { tmpdir } from 'node:os';
55
import { fileURLToPath, pathToFileURL } from 'node:url';
66
import { basename, dirname, join } from 'pathslash';
77
import { buildSandboxController } from '../../../platform/packages/api/scripts/build-sandbox-controller.mjs';
8-
import { resolvePlatformSourceRevision } from './source-revision.mjs';
98

109
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
1110
const repositoryRoot = join(packageRoot, '..', '..');
@@ -139,7 +138,6 @@ try {
139138
});
140139
const packageJson = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
141140
const database = buildDatabaseManifest();
142-
const sourceRevision = resolvePlatformSourceRevision({ repositoryRoot });
143141
const manifest = parsePlatformRuntimeManifest({
144142
artifacts,
145143
assets: {
@@ -165,7 +163,8 @@ try {
165163
platformVersion: packageJson.version,
166164
safetyProtocols: { sandboxDrain: 3 },
167165
schemaVersion: 2,
168-
sourceRevision,
166+
// scripts/stamp-source-revision.mjs records the revision after this cached build.
167+
sourceRevision: null,
169168
usageProtocolVersion: PLATFORM_USAGE_PROTOCOL_VERSION,
170169
});
171170
writeFileSync(join(runtimeRoot, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { readFileSync, writeFileSync } from 'node:fs';
2+
import { fileURLToPath, pathToFileURL } from 'node:url';
3+
import { dirname, join } from 'pathslash';
4+
import { resolvePlatformSourceRevision } from './source-revision.mjs';
5+
6+
// Records the source revision in the manifest that scripts/build-runtime.mjs wrote, so a new
7+
// revision reruns only this step and not the cached runtime build.
8+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
9+
const repositoryRoot = join(packageRoot, '..', '..');
10+
const manifestPath = join(packageRoot, 'dist', 'runtime', 'manifest.json');
11+
const { parsePlatformRuntimeManifest } = await import(
12+
pathToFileURL(join(packageRoot, 'dist', 'installer.mjs')).href
13+
);
14+
15+
const manifest = parsePlatformRuntimeManifest({
16+
...JSON.parse(readFileSync(manifestPath, 'utf8')),
17+
sourceRevision: resolvePlatformSourceRevision({ repositoryRoot }),
18+
});
19+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);

‎packages/platform/vite.config.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import { defineConfig } from 'vite-plus';
22

33
export default defineConfig({
4+
run: {
5+
tasks: {
6+
// The last step of the `build` script: records the source revision in the runtime manifest.
7+
// It isn't cached, so a new revision reruns only this step, and it gets the full
8+
// environment, including VOID_PLATFORM_SOURCE_REVISION.
9+
'build:stamp': {
10+
command: 'node scripts/stamp-source-revision.mjs',
11+
cache: false,
12+
},
13+
},
14+
},
415
pack: {
516
entry: [
617
'src/index.ts',

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vite.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default defineConfig({
8484
},
8585
'test:all': {
8686
command:
87-
'vp fmt --check && vp lint && vp run build:all && node test/check-playground-build-artifacts.mjs && vp run lint:platform && vp run check && vp test run',
87+
'vp fmt --check && vp lint && vp run --cache build:all && node test/check-playground-build-artifacts.mjs && vp run lint:platform && vp run check && vp test run',
8888
// `vp run` passes ONLY the env vars a task declares to that task — not the full environment.
8989
// Without this, the gated live Cloudflare e2e's credentials never reach `vp test run`, so it
9090
// skips even when the CI job injects them. `untrackedEnv` forwards them without folding them

0 commit comments

Comments
 (0)