Skip to content

Harden fork CI fidelity: web build fail-fast + test secret isolation#7

Merged
poterpan merged 2 commits into
mainfrom
fix/fork-ci-fidelity
Jun 8, 2026
Merged

Harden fork CI fidelity: web build fail-fast + test secret isolation#7
poterpan merged 2 commits into
mainfrom
fix/fork-ci-fidelity

Conversation

@poterpan

@poterpan poterpan commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Two independent fixes (one commit each) from the Codex review of fork/clean-checkout fidelity. Same theme as #6: make CI/tests reflect what a fork actually experiences.

#4 — scrub external secrets from the test baseline (ca92f66)

A local .dev.vars (gitignored) injects a real DISCORD_BOT_TOKEN; CI has none. Code gated on the token — notably /admin/billing/initiatesendBillingOpened (billing.ts:187) once discord_billing_channel_id is set earlier in the suite — therefore made a real Discord POST on a dev machine while CI silently took the no-send branch. Tests behaved differently per machine and leaked an outbound call locally.

  • test/apply-migrations.ts: delete env.DISCORD_BOT_TOKEN in setup → identical baseline everywhere. Tests that exercise sending already set their own dummy token + stub fetch.
  • test/smoke.test.ts: assertion that the token doesn't leak — reproduces the divergence (red locally before the scrub, green after).

#3 — fail the web build when VITE_API_BASE is unset (baada7e)

VITE_API_BASE is statically inlined at build time and aims the upload page at the fork's own worker. When unset, vite build still succeeded and emitted a bundle whose top-level throw (web/src/api.ts:2) only fires at load → white screen, invisible to CI's pnpm -r build.

  • web/vite.config.ts: fail the build (not just runtime) when VITE_API_BASE is missing; dev stays exempt.
  • .github/workflows/ci.yml: give the build step a throwaway VITE_API_BASE (CI only checks it compiles) + a regression guard step asserting the web build refuses to build without it.

Verification

  • pnpm -r typecheck ✅ · pnpm -r test ✅ 180 passing · pnpm -r build (with dummy) ✅
  • Web build without VITE_API_BASE → fails (exit 1, helpful message); with → succeeds.
  • feat: 成員/訂閱/方案/渠道 刪除(補齊 CRUD) #4 reproduced locally: the leak assertion is red before the scrub, green after.

Neither touches runtime Worker/SPA code → no production deploy needed.

poterpan added 2 commits June 9, 2026 00:38
A local .dev.vars (gitignored) injects a REAL DISCORD_BOT_TOKEN; CI has none.
Code gated on the token (e.g. billing/initiate -> sendBillingOpened) therefore
hit Discord for real on a dev machine while CI took the silent no-send branch —
tests behaved differently per machine, and the suite made an unintended external
POST locally.

Delete DISCORD_BOT_TOKEN in the test setup so the baseline is identical
everywhere; tests that exercise outbound calls already set their own dummy token
+ stub fetch. Add a smoke assertion that the token does not leak (reproduces the
divergence locally: red before the scrub, green after).
…white-screen bundle)

VITE_API_BASE is statically inlined at build time and points the upload page at
the fork's own worker. When unset, `vite build` still succeeded and emitted a
bundle whose top-level throw fires at load (white screen) — invisible to CI's
`pnpm -r build`. Move the gate to build time in vite.config.ts (dev exempt).

CI: pass a throwaway VITE_API_BASE to the build step (it only checks the build
compiles) and add a regression guard asserting the web build refuses to build
without it.
@poterpan poterpan merged commit ebe9a5f into main Jun 8, 2026
2 checks passed
@poterpan poterpan deleted the fix/fork-ci-fidelity branch June 8, 2026 16:41
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