Rebuild around build-time aggregation (was broken by CORS)#1
Merged
Conversation
v0.1 fetched sizes.<plat>.json by URL at runtime. The URLs in
manifest.json[builds[].platforms.<plat>.sizes.url] pointed at GitHub
release assets, which return no Access-Control-Allow-Origin header.
Every browser-side fetch was blocked by CORS. The original test plan
"verified CORS" with `curl -sfL`, which doesn't enforce CORS — the
site looked fine in CI and broke in real browsers.
This rewrite removes the runtime cross-origin fetch entirely. The
explorer is now a build-time aggregator:
scripts/prebuild.mts walks the last 90 nightly tags of
OpenIPC/firmware and OpenIPC/builder via the gh CLI (server-side,
CORS-free), downloads every sizes.*.json asset, and writes:
public/data/<source>/<tag>/sizes.<plat>.json (per-platform shard)
public/data/<source>/index.json (catalogue)
Vite copies public/ into dist/. The deployed site fetches only
relative URLs (./data/...) at runtime — same-origin by construction,
no CORS gate to fail.
Launch byte budget:
- bundle (html+js+css): ~57 KB gzipped
- data/<source>/index.json bootstrap: ~3 KB gzipped
- empty-state landing total: ~60 KB gzipped
- per platform picked: ~5 KB gzipped
- drift comparison: +~5 KB gzipped
dist/ holds many small shard files (~200 platforms × ~90 builds × ~30 KB
each), but those are the explorer's own deliverable, not data piled
into firmware/builder's gh-pages.
Tests (none in v0.1 — that's how this bug shipped):
- tests/prebuild.test.ts (8): runPrebuild with in-memory fs and
canned gh CLI driver; retention, body parsing, simple/compound
platform names, asset filtering.
- tests/lib.test.ts (25): categorise rules, drift diff (added /
removed / changed, abs-delta sort), URL query round-trip.
- tests/bundle.test.ts (5): production dist invariants. Most
importantly, asserts the JS chunks do NOT embed
release-assets.githubusercontent.com, api.github.com/.../assets,
or releases/download/*.json — exactly the regression that would
catch a repeat of the v0.1 bug. Also enforces a 250 KB bundle
perf budget.
- tests/live.test.ts (3, opt-in via RUN_LIVE_TESTS=1): post-deploy
smoke that hits the live Pages URL, asserts index.json is reachable,
a per-platform shard loads, and every URL is same-origin under
/firmware-explorer/.
CI changes (.github/workflows/pages.yml):
- test job (npm ci && npm test) gates build job
- schedule: cron daily 04:30 UTC, after firmware/builder nightlies
- build job runs `npm run build` (which invokes `npm run prebuild`
via npm lifecycle), pulls release assets server-side using the
workflow's GH_TOKEN.
Sources of upstream change (must land first):
- OpenIPC/firmware#2169 (manifest revert)
- OpenIPC/builder#103 (manifest revert)
Both merged.
Out of scope, kept on the roadmap:
- WhatIfPanel stub deleted; the real configurator (Kconfig graph,
dep resolution, defconfig fragment download) lands in v0.2 once
OpenIPC/firmware emits kconfig-graph.<plat>.json next to
sizes.<plat>.json.
- submit-to-builder trigger remains v0.3.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v0.1 fetched `sizes..json` by URL at runtime. Those URLs in
`manifest.json[builds[].platforms..sizes.url]` pointed at GitHub
release assets, which return no `Access-Control-Allow-Origin` header.
Every browser-side fetch was blocked by CORS. The original test plan
"verified CORS" with `curl -sfL`, which doesn't enforce CORS — the
site looked fine in CI and broke in real browsers.
This rewrite removes the runtime cross-origin fetch entirely. The
explorer is now a build-time aggregator: `scripts/prebuild.mts` walks
the last 90 nightly tags of OpenIPC/firmware and OpenIPC/builder via the
`gh` CLI (server-side, CORS-free), downloads every `sizes.*.json`
asset, and writes per-platform shards plus a small catalogue under
`public/data/`. Vite copies `public/` into `dist/`. The deployed
site fetches only relative `./data/...` URLs at runtime — same-origin
by construction.
Launch byte budget
Tests (none existed in v0.1 — that's how this bug shipped)
fs + canned `gh` CLI; retention trim, body parsing, simple+compound
platform names, asset filtering.
(added/removed/changed, abs-delta sort), URL query round-trip.
Most importantly asserts JS chunks do NOT embed
`release-assets.githubusercontent.com`,
`api.github.com/.../assets`, or `releases/download/*.json` —
exactly the regression that would catch a repeat of the v0.1 bug.
Also enforces a 250 KB bundle perf budget.
post-deploy smoke that hits the live Pages URL, asserts
`index.json` is reachable, a per-platform shard loads, and every
URL is same-origin under `/firmware-explorer/`.
All 38 active tests pass locally. 3 live tests skipped (will run after
deploy via the `workflow_dispatch` path).
CI (`.github/workflows/pages.yml`)
and builder (~07:20) nightlies finish.
via npm lifecycle. Pulls release assets server-side using
`${{ github.token }}`.
Upstream coordination
Both predicate reverts merged:
Out of scope / roadmap
resolution, defconfig fragment download) lands in v0.2 once
OpenIPC/firmware emits `kconfig-graph..json` next to
`sizes..json`.
Test plan
🤖 Generated with Claude Code