Skip to content

ci: run e2e suite against Vercel preview deployments - #641

Open
karrui wants to merge 2 commits into
mainfrom
feat/e2e-vercel-preview
Open

ci: run e2e suite against Vercel preview deployments#641
karrui wants to merge 2 commits into
mainfrom
feat/e2e-vercel-preview

Conversation

@karrui

@karrui karrui commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an e2e workflow that runs the Playwright smoke suite against every successful Vercel preview deployment, modeled on confetti's e2e-preview.yml but adapted for a generic starter kit.

Workflow (.github/workflows/e2e-preview.yml)

  • Triggers on deployment_status - fired automatically by Vercel's GitHub integration, so it works out of the box for any repo connected to Vercel (no webhook bridge needed, unlike confetti's repository_dispatch). Filtered to successful Preview deployments. Also supports manual workflow_dispatch with a preview URL.
  • No secrets required to run. Degrades gracefully instead of gating the whole workflow:
    • Datadog Test Optimization step skips itself when DD_API_KEY / DD_SERVICE_NAME are absent (same pattern as ci.yml)
    • VERCEL_AUTOMATION_BYPASS_SECRET is passed through; empty is fine for unprotected previews, and gated previews work once the secret is set
  • Posts an explicit E2E against Vercel preview commit status (pending → success/failure) that branch protection can require, since deployment_status runs don't surface reliably as PR checks.
  • Uploads the Playwright HTML report + traces as an artifact; resolve-branch job pins DD_GIT_BRANCH for Datadog PR attribution on detached-HEAD checkouts.

Playwright dual-mode

  • playwright.config.ts: when PLAYWRIGHT_TEST_BASE_URL is set (preview mode), skip the local webServer, attach the x-vercel-protection-bypass header, and skip t3-env validation for the runner. Local mode is unchanged.
  • smoke.test.ts: drops the incidental container-fixture and ~/env imports so it runs against deployed previews.
  • app-fixture.ts: fixture-based tests (testcontainers Postgres/Redis) self-skip in preview mode - they need local stack control, so the preview run is a deployment-verification gate, not a full functional suite.
  • Ports confetti's tooling/github/playwright-cache composite action (Chromium cache keyed on Playwright version).

Drive-by fix

Local e2e was broken on main: error-card.tsx used dynamic(..., { ssr: false }) from a Server Component, which Next.js rejects, so the dev server never compiled. GoBackButton now reads window.history in an effect (SSR-safe) and is imported statically.

Test plan

  • Local e2e suite passes end-to-end (pnpm e2e: 2 passed, boots dev server + testcontainers)
  • Preview mode verified without docker: playwright test --list loads, and a fixture-based test correctly reports skipped
  • Lint, format, typecheck clean
  • First real preview run happens once this merges (or trigger via workflow_dispatch against any preview URL)

🤖 Generated with Claude Code

karrui and others added 2 commits July 10, 2026 15:54
Next.js rejects `dynamic(..., { ssr: false })` inside Server
Components, so the dev server failed to compile not-found.tsx and the
local e2e suite could not boot. Read window.history in an effect
instead and import the button statically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds .github/workflows/e2e-preview.yml, triggered by the
deployment_status event Vercel's GitHub integration fires
automatically, filtered to successful Preview deployments, plus a
manual workflow_dispatch with a preview-url input.

The workflow needs no secrets to run: the Datadog Test Optimization
step skips itself when DD_API_KEY / DD_SERVICE_NAME are absent (same
gating as ci.yml), and VERCEL_AUTOMATION_BYPASS_SECRET is passed
through so gated previews work when configured, while unprotected
previews run with no secrets at all. Posts an explicit commit status
(E2E against Vercel preview) that branch protection can require, and
uploads the Playwright HTML report as an artifact.

Playwright side: the config is now dual-mode. When
PLAYWRIGHT_TEST_BASE_URL is set (preview mode) it skips the local
webServer, attaches the x-vercel-protection-bypass header, and skips
t3-env validation for the runner. The smoke tests drop the incidental
container fixture import so they run against deployed previews;
fixture-based tests (testcontainers Postgres/Redis) self-skip in
preview mode since they need local stack control.

Also ports a playwright-cache composite action that caches the
Chromium binary keyed on the installed Playwright version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 07:55
@datadog-opengovsg

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 53.45% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 567b372 | Docs | Give us feedback!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CI support for running the Playwright smoke E2E suite against Vercel preview deployments, while keeping local E2E behavior intact and fixing a Next.js Server Component compatibility issue in the error UI.

Changes:

  • Add a new deployment_status-driven GitHub Actions workflow to run E2E against successful Vercel preview deployments and publish an explicit commit status + artifacts.
  • Update Playwright config/tests to support “local mode” (spawn webServer) vs “preview mode” (use deployed base URL, bypass Vercel protection header, skip fixture-based tests).
  • Fix local E2E breakage by making GoBackButton SSR-safe and statically importing it in the error card.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/e2e-preview.yml New workflow to run Playwright smoke tests on successful Vercel preview deployments (and via manual dispatch), upload reports, and post commit statuses.
tooling/github/playwright-cache/action.yml New composite action to cache/install Playwright Chromium binaries keyed by Playwright version.
apps/web/playwright.config.ts Add preview-vs-local mode behavior, optional Vercel protection bypass header, and CI reporters/artifacts.
apps/web/tests/e2e/smoke.test.ts Remove dependency on ~/env so smoke tests can run against deployed previews.
apps/web/tests/e2e/app-fixture.ts Skip fixture-based (testcontainers) tests in preview mode; make DB/Redis fixtures nullable.
apps/web/src/app/_components/errors/go-back-button.tsx Make history access SSR-safe via useEffect to allow import from Server Components.
apps/web/src/app/_components/errors/error-card.tsx Replace dynamic no-SSR import with static import of GoBackButton.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +13
// The Playwright runner may import test files that transitively pull in
// `~/env` (t3-env). The runner itself only needs a couple of vars - the
// *server* it talks to validates its own env - so skip the t3-env validation
// here, decoupling the suite from the full server env schema.
process.env.SKIP_ENV_VALIDATION = '1'
@adriangohjw

Copy link
Copy Markdown
Contributor

question: technically once apps get productionized and move to ECS, testing against vercel might make much sense since there might be AWS-specific issues? also, i was thinking about it and im not sure how much upside there is by testing against a built app v.s. testing against a vercel preview?

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.

3 participants