Repository navigation
ci: GitHub Actions CI with smoke tests against the Cloudflare preview - #28
Merged
Merged
Conversation
…view The repo had no CI — the only automated PR check was the Cloudflare git-integration preview deploy, so a PR could break page rendering and nothing caught it before merge. This app has no database: every page is rendered server-side from the production PayloadCMS, so the highest-value check is a smoke test against the deployed preview confirming the Worker loads real content and hasn't regressed. Adds one pull_request workflow with two jobs: - gate: lint + typecheck + unit tests (closes the no-CI gap; no prod build, Cloudflare builds the preview). - smoke: discover the per-PR Cloudflare preview URL from the GitHub API, wait until healthy, then run fetch-based Vitest specs against it. Skips gracefully when no preview is posted. Smoke specs are content-discovering (crawl the preview homepage for real featuredPages links; optionally query the CMS for sample ids when SAHAJCLOUD_API_KEY is set) and cover the always-present surfaces: homepage, linked content pages, a non-English locale, the /en/ canonical redirect, the 404 page, and meditation full/embed routes. - scripts/get-cloudflare-preview-url.mjs: GitHub-API preview URL discovery (deployment environment_url -> commit statuses -> check runs), plain ESM. - vitest.smoke.config.ts + tests/smoke/: fetch-based suite + helpers. - package.json: add typecheck + test:smoke scripts. - vitest.config.ts: exclude tests/smoke from the unit run. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying wemeditate-design with
|
| Latest commit: |
ab55a78
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://925523ab.wm-design.pages.dev |
| Branch Preview URL: | https://ci-github-actions-smoke-prev.wm-design.pages.dev |
…pp, not Ladle)
The repo's Cloudflare git integration deploys the Ladle design system
(wm-design.pages.dev), not the Vike web app — and it's the only preview posted
on PRs today. The first CI run proved the discovery mechanism works (it found
the URL via the cloudflare bot PR comment and the "Cloudflare Pages" check-run
output.summary — there are no GitHub deployments or commit statuses), but it
grabbed the Ladle deployment and smoke-tested a static component playground.
Make discovery project-aware:
- Primary source is now the bot PR comment, the only surface that names the
project ("Deploying <project> with Cloudflare Pages"); deployments, commit
statuses, and check-run output remain fallbacks.
- Select the candidate matching CF_PROJECT_MATCH (set the CF_PREVIEW_PROJECT
repo variable to the web-app preview project once it exists); always exclude
the known Ladle project (wm-design / wemeditate-design).
- Until a target is configured, check quickly and skip (30s) instead of polling
the full 12-minute build window, so the smoke job stays green and fast.
Workflow: pass PR_NUMBER + CF_PROJECT_MATCH, add pull-requests/issues read perms.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | ab55a78 | Commit Preview URL Branch Preview URL |
Jun 15 2026, 07:09 AM |
Both previews are now enabled and are distinguishable by URL host: - web → Workers Builds, …-wemeditate-web.<acct>.workers.dev - ladle → Pages, …wm-design.pages.dev - Workflow: replace the single smoke job with a 2-target matrix (web, ladle), each discovering its own preview via CF_PROJECT_MATCH (wemeditate-web / wm-design). - Discovery: accept ANY HTTP response as "reachable" (renamed waitHealthy → waitReachable) so a 500 page is caught by the smoke specs instead of failing discovery before they run. - Ladle: new fetch-based spec (tests/smoke/ladle) — asserts the app shell and a non-empty /meta.json story manifest. No Playwright needed for the static SPA. - Web: move specs to tests/smoke/web; fix conventions verified against the live Worker (locale roots have no trailing slash: /es not /es/; default locale is stripped: /en → 301 → /index); discover a real CMS page via the API instead of crawling homepage anchors (which may be hydrated client-side). - Scripts: test:smoke → web specs; add test:smoke:ladle. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The homepage (and every renderable page) returned a 500 on the deployed preview. Root cause: LayoutDefault.assertSettingsConfigured() threw when the WebConfig was incomplete (e.g. empty/missing featuredPages — which getWebConfig does not normalize, unlike classPages/knowledgePages/infoPages). That throw ran OUTSIDE the Sentry error boundary, so it surfaced as an unhandled SSR error → 500 on any page that successfully fetched settings. (A thrown 404 bypasses this path, which is why /about 404'd cleanly while / and /es 500'd.) Note /es ≡ / here: getWebConfig() takes no locale, so this was never about missing localized content. Fix: drop the hard assert and null-guard every settings access (featuredPages/knowledge/info/classPages ?? []). Incomplete config now renders gracefully with whatever nav is available instead of crashing; genuinely-missing pages are still 404s via the data hooks; true CMS/service errors still 500. Add LayoutDefault.test.tsx covering the incomplete-config regression. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
discoverFromCms now logs the CMS response (HTTP status / "0 docs") so a skipped content-page or meditation spec is diagnosable in CI — distinguishing an unauthorized key (403) from genuinely-missing published content. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The CMS query-validation hook (PR #23) rejects collection reads without select/populate with HTTP 400 — which is why discoverFromCms found nothing and the content-page/meditation specs skipped (the key itself is valid, not 403). Add a qs serializer and mirror cms-client's select/populate shapes so the discovery queries are accepted and the specs run against the preview. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
getWebConfig was the only API-client read missing select/populate — and it reads at depth 2, which the backend requires populate for (see the note in cms-client). The global itself returned 200, but its page relationships (homePage, featuredPages, classPages, knowledgePages, infoPages) came back without title/slug, so the deployed homepage rendered an empty <h1> and ~9 dead `/undefined` nav links. It also passed no locale, so localized slug/title couldn't resolve. - Add WEB_CONFIG_SELECT + WEB_CONFIG_POPULATE (pages → PAGE_SELECT, images) and pass them plus `locale` to findGlobal; key the cache by locale. - Thread `locale` through all five getWebConfig callers. Smoke: add expectNoBrokenLinks() and assert the homepage has no /undefined|/null nav hrefs, so an under-populated read fails loudly instead of false-passing. Note: verified via CI/deploy — the production CMS rejects the API key from a local machine (403), so this can't be reproduced against cloud.sydevelopers.com locally. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A published page populates in the WebConfig relationships; an unpublished/trashed one comes back as a bare id (and renders a dead `/undefined` nav link). Add a graceful fallback: partitionPublishedPages() keeps only populated pages with a slug and drops the rest, so the layout never renders broken nav. When anything is dropped, log a Sentry warning (level: warning) listing the unresolved refs by group, so the underlying CMS data gap stays visible instead of silently hidden. Also covers homePage returned as a bare id. Unit-tested in cms-client.test.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Ardnived
added a commit
that referenced
this pull request
Nov 2, 2026
* test: drop leftovers from the KV cache removal and an unused smoke helper - `kv: undefined` in two sahajcloud-context mocks: the context lost its kv field in #107, so the mocks described a shape that no longer exists. - Three retry tests titled "…since the KV layer used to supply that": the KV layer is gone, so the titles now state only the behaviour. - `headTags()` in the smoke preview helper: exported in #28 and never called. The audit found no migration-era test files left; #87, #99 and #107 already removed them with their code. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(server): drop the stale KV binding claim `getSahajCloudContext()` returns `{ apiKey, baseURL }`, and `SahajCloudEnv.Bindings` carries no KV namespace — the binding went with `server/kv-cache.ts` in #98. The docblock still promised a reader that the helper resolves one, which is the same leftover this PR deletes from the file's own test mock. Wording now matches `sitemap-routes.ts`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXde9tn99Z82seiuKd * fix(components): call the related fetch edge-cached Nothing in this Worker holds persistent state (server/CACHING.md). The related endpoints are cached by the Cloudflare zone in front of SahajCloud, which sets `s-maxage` and `Cache-Tag` through `publicReadCacheHeaders`. The KV namespace these docblocks named went away in #98, so "KV-cached" pointed a reader at a cache they could neither inspect nor purge. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXde9tn99Z82seiuKd --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
Adds the project's first CI. Until now the only automated PR check was the Cloudflare git-integration preview deploy, so a PR could break page rendering with nothing to catch it. Since this app has no database — every page is server-rendered from the production PayloadCMS — the highest-value check is a smoke test against the deployed preview confirming the Worker loads real content and hasn't regressed. Modeled on the
sy-devs-cmsCI (discovery script + preview smoke suite, skipping gracefully when no preview exists).What it does
One
pull_requestworkflow (.github/workflows/ci.yml) with two jobs:gate—lint+typecheck+ unit tests (pnpm test:run). Closes the prior no-CI gap. No production build — Cloudflare builds the preview.smoke— discovers the per-PR Cloudflare preview URL from the GitHub API, waits until it's healthy, then runs fetch-based Vitest specs against it. Skips gracefully (no failure) when no preview URL is posted.Key pieces
scripts/get-cloudflare-preview-url.mjs— plain ESM (no newtsxdep). Reads the GitHub API for the PR head SHA across three surfaces — deploymentenvironment_url→ commit statuses → check runs — and extracts a*.pages.dev/*.workers.devURL. Skips (exit 0) when none is found; fails (exit 1) only when a found URL never becomes healthy.vitest.smoke.config.ts+tests/smoke/— fetch-based smoke suite (retries: 2), excluded from the unit run. Specs are content-discovering: they crawl the preview homepage for realfeaturedPageslinks and optionally query the CMS for sample ids whenSAHAJCLOUD_API_KEYis present./es/), the/en/→canonical 301 redirect, the 404 page, and meditation full/embed routes (/meditations/{id},/m/{id}).ErrorFallbacktitles (Content Not Found,Service Temporarily Unavailable, …) so a page rendering the error boundary fails the smoke test.package.json— addstypecheckandtest:smokescripts.vitest.config.ts— excludestests/smoke/**sopnpm test:runnever hits the network.Verified locally
pnpm typecheckcleanpnpm lint0 errors (pre-existing warnings only)pnpm test:runran only the existing unit files (87 tests) — smoke excludedPREVIEW_URLguard fires with a clear messageNotes / follow-ups
SAHAJCLOUD_API_KEYas a GitHub Actions secret to enable deterministic meditation/page discovery. Without it, smoke still runs off homepage-crawled links and skips id-specific specs.smoke-job logs.🤖 Generated with Claude Code