Skip to content

ci: cache build:all with the remote task cache - #492

Draft
wan9chi wants to merge 1 commit into
mainfrom
feat/remote-cache-build-all
Draft

wan9chi wants to merge 1 commit into
mainfrom
feat/remote-cache-build-all

Conversation

@wan9chi

@wan9chi wan9chi commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Why

CI's build job runs vp run build:all, 41 package and playground builds, from scratch on every run. This caches them with vp run and its remote task cache, so PRs reuse what main has built.

Changes

  • build:all is cached in CI. The build job runs vp run --cache build:all. vp run tracks the files each build reads, so the builds need no input config.
  • Packages build in dependency order. The root build script no longer uses --parallel, so no build reads a dependency's output while it's being restored. @void/md builds last, since it and void depend on each other. @void/platform now depends on @void/isr, whose build output it bundles.
  • The platform runtime build is split into build and stamp. The runtime build wrote the current commit into its manifest, so its output changed on every commit and it could never hit. It now leaves the commit out and is cached. An uncached build:stamp task then writes the commit. The stamp can't be cached, because its output is the commit itself, which is new on every commit.

Numbers

From 448 CI runs of void's commits from Oct 19 to Nov 7:

Event Hit rate build:all Without the cache
PR, Ubuntu 61% ~18 s 38 s
Main push, Ubuntu 65% ~16 s 38 s
Main push, Windows 55% 58 s 109 s

4.4 h saved in total.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-remote-cache-build-all-void-cloud.voidzero-docs.workers.dev (commit 8d6ec91)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://9adef7eb-void-cloud.voidzero-docs.workers.dev 8d6ec91 2026-11-11T11:21:49.200Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://8f1a2bf2-void-cloud.voidzero-docs.workers.dev d9e4832 2026-10-19T07:46:29.139Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://35a2cdcc-void-cloud.voidzero-docs.workers.dev f48ca6a 2026-10-19T07:26:30.305Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://77cf7817-void-cloud.voidzero-docs.workers.dev 9a4e504 2026-10-19T07:16:41.851Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://fe212a3b-void-cloud.voidzero-docs.workers.dev 252c3e6 2026-10-19T07:14:26.089Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://a6a9737d-void-cloud.voidzero-docs.workers.dev e9206e0 2026-10-19T06:53:38.590Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://f0787d7a-void-cloud.voidzero-docs.workers.dev a2fc5b4 2026-10-19T06:48:25.879Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://0717f50b-void-cloud.voidzero-docs.workers.dev 57dcba9 2026-10-19T05:29:54.998Z Visit the dashboard ↗

@wan9chi
wan9chi force-pushed the feat/remote-cache-build-all branch from 57dcba9 to a2fc5b4 Compare October 19, 2026 06:47
wan9chi added a commit to voidzero-dev/vite-plus-remote-cache-cloudflare that referenced this pull request Oct 19, 2026
…ith void (#17)

## Motivation

[voidzero-dev/void#492](voidzero-dev/void#492)
caches every task `build:all` runs, and its PR CI should show remote
cache reuse before it merges. void#492 already makes same-repository PR
runs read-write, but the production cache only accepts uploads from
default-branch `push` jobs, so those PR uploads get `403 write_policy`.
The decision is to let void's same-repository PR CI upload to its
namespace
(`https://voidzero-remote-cache.voidzero-docs.workers.dev/projects/void`)
for now. Every other namespace keeps the main-branch-push-only policy.

## Design

- **Opt-in per namespace, off by default.** Migration
`0002_pull_requests.sql` adds `scopes.pull_requests` (0/1, default 0)
and recreates the `changed_policy` trigger with that column, so turning
the opt-in on or off bumps `policy_version` and stops uploads admitted
under the old policy.
- **Write policy (`src/auth.ts`).** `push` tokens work as before. For an
opted-in namespace, a `pull_request` token passes the same audience,
`repository_id`, `repository_owner_id`, and `repository_visibility:
public` checks, and also needs:
  - `ref` matching `refs/pull/<number>/merge`
  - `ref_type` `branch`
- `base_ref` equal to the registered default branch's short name
(`main`, not `refs/heads/main`)

These are the values GitHub signs for a PR's merge-branch run: see the
[`ref`
description](https://docs.github.com/en/actions/reference/workflows-and-actions/variables)
("for pull request events except `pull_request_target` that were not
merged, it is `refs/pull/<pr_number>/merge`"), `GITHUB_BASE_REF` ("for
example, `main`"), the [OIDC claim
reference](https://docs.github.com/en/actions/reference/security/oidc),
and the decoded `pull_request` token in
[github/actions-oidc-debugger](https://github.com/github/actions-oidc-debugger)
(`"ref": "refs/pull/27/merge"`, `"ref_type": "branch"`, `"base_ref":
"main"`). `pull_request_target`, `workflow_run`, tags, PRs to other
branches, the `closed` run of a merged PR (whose `ref` is the base
branch), and workflows in fork repositories are still denied.
- **Configuration.** A `.github/production-repositories.jsonc` entry can
now be `{ "repository": "owner/repo", "pullRequests": true }` as well as
`"owner/repo"`, which means `pullRequests: false`. Only `void` uses the
object form. `pnpm ci:deploy production` sets every namespace's opt-in
from the list on each run, the same way it already handles
`enabled`/`writes_enabled`. Self-hosters use `pnpm operator policy
--pull-requests on|off`, or `setup --pull-requests on` when creating a
namespace. `status` already prints the full row.
- **Staging** keeps `pull_requests = 0`, so PR staging runs still check
that PR tokens are rejected.
- **Logging.** Verified writes now also log `event_name` and `head_ref`.
`base_ref` always equals the default branch, and the PR number is
already in `workflow_ref`.

## Risk

PR entries share the namespace with default-branch entries. Code from
any same-repository PR, including Renovate dependency branches, runs
before review and can publish an entry that a later default-branch build
restores. That's why the opt-in is off by default and only on for void.
The README, self-hosting guide, e2e plan, and RFC describe it as interim
and link the long-term fix, #16 (scope pull request uploads to the pull
request).

The server can't tell fork PRs from same-repository PRs: fork PR runs
carry the base repository's IDs. It relies on GitHub not granting
`id-token: write` to fork PR workflows. GitHub only does that when "Send
write tokens to workflows from pull requests" is enabled, a setting it
offers for private repositories only. The docs state this dependency.

## After merge

Production changes only after a maintainer runs **Actions → Remote cache
production** on `main`. That run applies migration 0002 and enables PR
uploads for `void`. Its log should print `Enabled pull request uploads
for namespace void`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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>
@wan9chi
wan9chi force-pushed the feat/remote-cache-build-all branch from d9e4832 to 8d6ec91 Compare November 11, 2026 11:20
@wan9chi wan9chi changed the title build: cache every task that build:all runs ci: cache build:all with the remote task cache Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant