Skip to content

fix(ci): smoke tests the head commit's preview, not the previous build - #295

Merged
sydevs-bot merged 9 commits into
mainfrom
claude/fix-ci-smoke-preview-sha
Nov 19, 2026
Merged

sydevs-bot merged 9 commits into
mainfrom
claude/fix-ci-smoke-preview-sha

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Developers: the Smoke (web) and Smoke (ladle) lanes now test only a preview built from the commit under test. Before, while Cloudflare was rebuilding, discovery took the address in the bot comment for the previous build. The lane then reported failures on routes the commit adds, and missed what the commit broke.
  • Developers: a push that changes only server/sahajcloud-types.ts now counts as a Ladle change in CI. Before, WATCH still named cms-types, the name that module had before refactor: use SahajCloud, not CMS, as the backend's name in code #131.
  • Visitors: the deployed error page links to the status page again. The URL was only in wrangler.toml [vars], which the build never reads, so production compiled it as undefined.
  • Developers: scripts/chrome-debug.sh no longer kills every Chrome on the machine before it launches. When the port is taken, it reuses a real DevTools endpoint or refuses to start.
  • Developers: a non-development build with no PUBLIC__SAHAJCLOUD_URL now fails on its first SahajCloud read, with a message that names the variable. Before, it quietly read from http://localhost:3000.

Merge prerequisite (outside this repo): both Workers Builds triggers on the wemeditate-design Worker (the main one and the preview-branch one) still include server/cms-types*. Change that to server/sahajcloud-types* in the Cloudflare dashboard before or with this merge. Until then, CI's WATCH list is wider than the trigger. A push that touches only server/sahajcloud-types.ts gets no Ladle build, so Smoke (ladle) waits 12 minutes and then tests the branch alias. That alias serves the previous Ladle build, so the lane goes green without testing the change. On a branch that never had a Ladle build, it goes red. The ⚠ note in docs/cloudflare-previews-ci.md describes this. Delete the note once the triggers are fixed.

Findings addressed

  • F1: smoke measured a stale preview. Real data: job 135332006782 selected 37de6e0a while the head was 01947eb6. The Workers Builds check run on d3499ab5 shows that 37de6e0a was that earlier commit's build. Cloudflare's bot posts one comment per Worker and edits it in place, so between a push and the end of the build the comment still names the old commit.
    • Fix: commit c8c853a is 91fa2f4 from feat(seo): share metadata and JSON-LD at parity with the old site #282, cherry-picked unchanged with its authorship kept. namesCommit (scripts/get-cloudflare-preview-url.mjs:115) refuses any bot row whose commit cell names a different commit than PR_HEAD_SHA, and discovery keeps polling within its existing window. The only other script change is four names added to the export block.

    • Tests: tests/guards/preview-discovery.test.ts, "discovery against a pull request whose preview is mid-rebuild" (7 flow tests). The fixtures are built from the real Cloudflare comment on feat(components): skip link, nav names, page titles and an axe gate #284 (wemeditate-web | 01947eb6 | …fbf316a0-wemeditate-web…) and the real check-run summary. They cover:

      • the row naming the head is taken;
      • a d3499ab5 row is never taken;
      • discovery falls through to the check run;
      • main keeps polling until the row changes;
      • discovery reports none and probes nothing when the row never changes;
      • waitReachable;
      • exit 1 when the head's own preview never answers.

      With namesCommit disabled, 4 of them fail.

  • F4a: stale ladle watch path. .github/workflows/ci.yml:109 WATCH now says server/(sahajcloud-types|error-utils), and the Include list in docs/cloudflare-previews-ci.md:77 matches it.
    • Test: tests/guards/ladle-watch-paths.test.ts follows every value import from components, hooks, lib, layouts and .ladle into server/, and requires the WATCH regex read from ci.yml to match each module it reaches. On main's ci.yml it fails, naming server/sahajcloud-types.ts.
  • F4b: status page URL missing from the build. Before this change, curl https://wemeditate-web.contact-c66.workers.dev/this-page-does-not-exist-ci-check returns 404 with no uptimerobot link on the page. pages/_error/+Page.tsx:16 reads import.meta.env.PUBLIC__STATUS_PAGE_URL, which Vite inlines at build time from .env.production and never from [vars].
    • Fix: the URL is now at .env.production:14, with its own comment. The dead copy in wrangler.toml [vars] is gone, since no code reads a PUBLIC__ binding from the running Worker. .env.example now says where production's value comes from. A local pnpm build inlines the URL into both the server and client error bundles.
    • Tests: tests/guards/production-env.test.ts. The URL must pass isSafeHttpUrl, and every PUBLIC__ entry in [vars] must appear in .env.production with the same value. An empty [vars] is accepted, and a PUBLIC__ line the guard cannot parse makes it throw. Both tests fail on main's files.
  • F4c: pkill on Chrome. scripts/chrome-debug.sh kills nothing now.
    • If the port is held by a real DevTools endpoint (its /json/version names webSocketDebuggerUrl, line 23), the script reuses it.
    • If anything else holds the port, the script refuses to launch.
    • If a Chrome is already using the debug profile without the port open, the script also refuses (line 34).
    • Checked with a stubbed copy of the script: a plain python3 -m http.server on the port is refused with exit 1, and a server that answers like DevTools is reused with exit 0.
    • Test: tests/guards/script-process-kills.test.ts fails on any pkill, killall or kill command in scripts/**/*.sh. On main it fails, naming the pkill line.
  • F4d: silent localhost fallback. server/sahajcloud-context.ts:80 falls back to http://localhost:3000 only when import.meta.env.DEV is true. Otherwise the schema field at line 43 throws PUBLIC__SAHAJCLOUD_URL is not set in this build, and that error reaches the error page.
    • Tests: server/sahajcloud-context.test.ts holds the module's first 6 tests. "refuses a production build that names no SahajCloud" fails on main's code.
  • Review follow-ups:
    • docs/cloudflare-previews-ci.md:32-39 and the checks: read comment at ci.yml:18 said the check run never carries a preview URL. That is wrong: the check-run summary on 01947eb6 contains Preview URL: https://fbf316a0-wemeditate-web.contact-c66.workers.dev and …6240d24f-wemeditate-design…. This check run is now the fallback F1 relies on, so both texts now say it carries the commit's own preview.

Not in this PR

  • Cloudflare triggers: the wemeditate-design Builds trigger path still has to change from server/cms-types* to server/sahajcloud-types* on both triggers. See the merge prerequisite above. It is dashboard configuration, and this run had no Cloudflare credentials.
  • .claude/workflow.json:31 still tells readers to use server/cms-types.ts, which should read server/sahajcloud-types.ts. That path is protected, so an unattended run could not edit it.
  • Comments with no commit cell: a bot comment that names no commit at all is still accepted, as 91fa2f4 intends. Changing that block would conflict with feat(seo): share metadata and JSON-LD at parity with the old site #282. The risk: if Cloudflare ever renders the SHA as a link, the comment source would start accepting stale rows again. The check run, which is keyed on the SHA, is the safer fallback in that case.
  • Branch alias after a stale window: because stale comments are now skipped, the last-resort branch alias gets no account-subdomain evidence from them. If every comment stays stale for the whole window and no other source has an address, discovery reports none. A test pins this behaviour.
  • Translation keys: none needed.

Reconciled with open PRs

Test results

.claude/skills/pr-prep/check.sh on the pushed head:

  • Lint: 0 errors, 1085 warnings. Main has 1084. The one extra is the no-console on the skipping … names another commit line from the cherry-picked 91fa2f4, kept verbatim. Lines written for this PR add no warnings.
  • tsc: passed.
  • vitest: 133 files, 1240/1240 tests passed.

This bundle is not marked BUILD. An earlier pnpm build on this branch, run because server and env files changed, passed. Nothing on the build path changed after that.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw

Cloudflare rewrites one comment per Worker in place, so between a push
and that build finishing it still names the previous commit, and the
address beside it is that build's. Discovery read the first workers.dev
host in the comment and took it. The `Smoke (web)` lane on c221df7
therefore tested b60f0ac's deployment: five specs failed on routes the
commit adds, and a head that commit emitted three times went unseen.

Discovery now reads the comment's `Latest Commit` cell and skips a
comment naming any other commit, so the 12-minute window is spent
waiting for this commit's build rather than measuring the last one. A
comment that names no commit is still accepted: the column is
Cloudflare's to rename, and no address at all stops the lane.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWDpubJYs3RkxjCw1u
The unit lane covered discovery's helpers and none of its flow:
`fromPrComments`, `discoverUrl`, `main` and `waitReachable` ran only
inside a CI job, which is how a smoke lane measuring the previous
build went unnoticed.

The fixture is the web Worker's comment on #284, as Cloudflare wrote
it. Job 135332006782 ran on 01947eb while that comment still named
d3499ab and selected d3499ab's 37de6e0a address. The flow tests pin
that such a row is never taken: discovery falls through to the check
run GitHub serves for the head commit, keeps polling while the row is
stale, takes the row once it names the head, and reports none rather
than probing the stale address when the window closes. Four of them
fail with the commit check removed.

The script exports the four functions; nothing else in it changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`Smoke (ladle)` decides whether a push owes it a `wemeditate-design`
preview by matching the changed files against WATCH. WATCH still named
`server/cms-types`, which #131 renamed `server/sahajcloud-types.ts`, so
the one server module components, hooks and lib import at runtime was
outside it, and the docs' copy of the list said the same.

A guard now resolves every value import from the trees Ladle builds,
follows it through `server/`, and requires WATCH to match each module
it reaches. It fails on the old pattern.

The Cloudflare build triggers hold the same stale path and are not in
this repo; the docs say so beside the list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`pages/_error/+Page.tsx` reads `PUBLIC__STATUS_PAGE_URL` through
`import.meta.env`, which Vite inlines at build time from
`.env.production`. The URL was only in `wrangler.toml`'s `[vars]`,
which bind to the running Worker and are read by nothing, so the
deployed error page compiled `statusPageUrl` as `undefined` and never
offered the status page.

The URL moves to `.env.production`, and the dead `[vars]` copy goes:
nothing reads a `PUBLIC__` binding at runtime, and a second copy is what
made this look configured. `.env.example` now says where production's
value comes from, as it does for the SahajCloud URL.

A guard requires the status URL in `.env.production` and every
`PUBLIC__` entry in `[vars]` to be there with the same value. Both
cases fail on the previous files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`scripts/chrome-debug.sh` ran `pkill -f "Google Chrome"` before each
launch, which closed every Chrome on the machine: the user's own
browser, and any debug Chrome another session was driving. AGENTS.md
forbids stopping either.

The script now never stops anything. When the port is taken it reuses
it only if Chrome's debugger answers there, and otherwise refuses with
a hint to pass another port. When a Chrome already holds the debug
profile without that port open, it refuses too, since the launch would
hand over to that process and the port would never open; the pkill
existed to clear exactly that case.

A guard fails on any `pkill`, `killall` or `kill` command in a script
under `scripts/`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`getSahajCloudContext` filled a missing `PUBLIC__SAHAJCLOUD_URL` with
`http://localhost:3000` in every build. A production Worker cannot
reach that, so a deploy built without the URL would have sent every
read there and reported a network outage on each page, never the
missing variable.

The fallback now applies in development only. Elsewhere the context
schema refuses the read on first use with
`baseURL: PUBLIC__SAHAJCLOUD_URL is not set in this build`, which the
config read propagates to the error page. It is a first-request error
rather than a build failure because the schema already owns every
other configuration refusal, and `.env.production` carries the value
for every Cloudflare build.

These are the module's first tests: the embedded URL, the development
fallback, the production refusal (which fails on the old code), a
malformed URL, a missing key, and the Worker secret winning inside a
request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The comment above `PUBLIC__SAHAJCLOUD_URL` says its value is also in
wrangler.toml [vars], which is no longer true of the status page URL now
that [vars] dropped it. Give that value its own group.

The production-env guard also required wrangler.toml to keep at least
one PUBLIC__ entry in [vars], though those entries are read by nothing,
so removing the last dead one would have failed it. It now accepts an
empty table and instead throws on a PUBLIC__ line it cannot parse, which
is what the length check was standing in for.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
`curl -s` exits 0 on any HTTP answer, a 404 included, so a web server
on the requested port was reported as a running Chrome and the script
exited 0 without launching. Only a DevTools endpoint's /json/version
names a webSocketDebuggerUrl, so require that instead.

Checked with a stubbed copy of the script: a plain `python3 -m
http.server` on the port now refuses with exit 1, and a server returning
a DevTools-shaped /json/version is still reused with exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…dflare

Two corrections to what the CI doc and ci.yml say.

The `Workers Builds: <worker>` check run does name a preview: its
output.summary carries `Preview URL: https://<version>-<worker>...`
for that commit's own build (01947eb shows fbf316a0-wemeditate-web
and 6240d24f-wemeditate-design). Since discovery now refuses a comment
that names an earlier commit, that check run is the fallback it
reaches, so the claim that it carries no address, and the ci.yml
comment that `checks: read` serves only a dashboard link, invited
someone to drop the permission as dead.

The ladle WATCH list now names server/sahajcloud-types while both
Cloudflare triggers still name server/cms-types. Until the dashboard is
edited, a push touching only that file passes WATCH but gets no Ladle
build, and Smoke (ladle) ends on the derived branch host: the previous
Ladle build, so green without testing the change, or red if the branch
never had one. The note now says that rather than only "waits".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 19, 2026
@sydevs-bot

sydevs-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 19, 2026
Merged via the queue into main with commit 73b7553 Nov 19, 2026
17 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-ci-smoke-preview-sha branch November 19, 2026 23:05
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 19, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 20, 2026
Fixes the red `Smoke (web)`: `/zz/map should 404: expected 200 to be 404`,
and the same for `/zz/meditations/<id>`.

The smoke job runs the spec from the merge ref but fetches the preview
Cloudflare built from this branch's head (#295). `main` carries both halves
of #315 — the matchers that stop an unknown prefix minting a second address,
and the smoke spec that pins it — while this head carried only the spec's
absence. Bringing the base in puts the matchers on the head the preview is
built from, so there is nothing else to fix here.

Base merged clean. Lean gate green: lint, `tsc --noEmit`, 1482 tests in 150
files, `pages/onBeforeRoute.test.ts` among them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXMjw8p5ZyKppLjncT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants