Skip to content

ci: add preview smoke test for frontend PRs#7192

Closed
talissoncosta wants to merge 14 commits intomainfrom
ci/frontend-smoke-test-on-vercel-preview
Closed

ci: add preview smoke test for frontend PRs#7192
talissoncosta wants to merge 14 commits intomainfrom
ci/frontend-smoke-test-on-vercel-preview

Conversation

@talissoncosta
Copy link
Copy Markdown
Contributor

@talissoncosta talissoncosta commented Apr 9, 2026

  • I have read the Contributing Guide.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #7262

Vercel Preview Smoke Test

Adds a smoke test job to the frontend PR workflow. On every PR that touches frontend/**, the job waits for Vercel to finish deploying, then verifies the preview is healthy.

How it works

Phase 1 — Wait for Vercel deployments:

  • Polls the commit status API for flagsmith-frontend checks (scoped to frontend only — won't wait for docs)
  • Waits until all leave pending (real builds: waits for completion; skipped builds: immediately done)
  • If a build fails, reports the failure and skips testing

Phase 2 — Smoke test the preview:

  • Parses flagsmith-frontend-* URLs from the Vercel bot PR comment (short poll with 30s buffer for comment update timing)
  • GET /config/project-overrides — Express server is running
  • GET / — static files deployed + response body contains "Flagsmith" (content validation)

Properties

  • No false positives — Phase 1 ensures the current build has landed before testing
  • Non-blockingcontinue-on-error: true, failures warn but don't gate merge
  • Boundedtimeout-minutes: 15 on the job, --max-time 30 on each curl
  • Handles skipped builds — Vercel's "Ignored Build Step" completes immediately; previous preview URL is still live
  • No checkout needed — uses only gh api + curl

Review feedback addressed

  • Job-level timeout
  • Curl timeouts (--max-time 30)
  • Non-blocking (continue-on-error: true)
  • Merged duplicate API calls
  • Dropped /health (behind VPN, returns 404 on public URLs)
  • Body content validation on /

How did you test this code?

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Apr 16, 2026 2:08pm
flagsmith-frontend-preview Ignored Ignored Preview Apr 16, 2026 2:08pm
flagsmith-frontend-staging Ignored Ignored Preview Apr 16, 2026 2:08pm

Request Review

@github-actions github-actions bot added ci-cd Build, test and deployment related front-end Issue related to the React Front End Dashboard and removed ci-cd Build, test and deployment related labels Apr 9, 2026
@github-actions github-actions bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Apr 9, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.29%. Comparing base (9943da9) to head (27cf50f).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7192   +/-   ##
=======================================
  Coverage   98.29%   98.29%           
=======================================
  Files        1351     1351           
  Lines       50752    50752           
=======================================
  Hits        49885    49885           
  Misses        867      867           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread .github/workflows/frontend-deploy-production.yml Fixed
Comment thread .github/workflows/frontend-deploy-production.yml Fixed
@talissoncosta talissoncosta changed the title ci: Add Vercel preview smoke test for frontend PRs ci: Stage Vercel deployment and run E2E before promoting to production Apr 9, 2026
@github-actions github-actions bot removed the ci-cd Build, test and deployment related label Apr 9, 2026
@github-actions github-actions bot added the ci-cd Build, test and deployment related label Apr 16, 2026
talissoncosta and others added 4 commits April 16, 2026 09:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Failures now warn instead of hard-failing individual endpoints.
The job still exits non-zero so the PR check shows a warning, but
continue-on-error prevents it from blocking merge.

Also consolidates the 3 separate curl checks into a single
endpoint loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The state and environment_url were fetched in 2 separate calls to
the same endpoint. Now parsed from a single response — halves the
API calls per poll iteration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@talissoncosta talissoncosta force-pushed the ci/frontend-smoke-test-on-vercel-preview branch from 0c057e9 to 06cd573 Compare April 16, 2026 12:33
@github-actions github-actions bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Apr 16, 2026
/health, /admin, /metrics and /sales-dashboard are now only
reachable via internal.flagsmith.com (VPN). Public preview URLs
return 404 for these paths.

Keep /config/project-overrides (Express server-side route, proves
the server is running) and / (proves static files are deployed).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@talissoncosta talissoncosta force-pushed the ci/frontend-smoke-test-on-vercel-preview branch from 0ab5559 to c7492fd Compare April 16, 2026 12:43
@github-actions github-actions bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Apr 16, 2026
@talissoncosta
Copy link
Copy Markdown
Contributor Author

talissoncosta commented Apr 16, 2026

Update: the previous approach produced false positives — it was testing URLs before Vercel finished deploying, hitting the stale previous build.

Rewrote to a two-phase approach:

  1. Wait for Vercel deployment statuses to complete (polls commit status API for flagsmith-frontend checks)
  2. Parse URLs from the bot comment and test /config/project-overrides + / with content validation

Also dropped /health (behind VPN now). Validating on #7264.

The Deployments API approach failed for "Ignored Build Step" skips
— Vercel creates no deployment for the SHA, and stores SHAs as the
ref field so branch-name queries also returned nothing.

Parse the preview URLs directly from the Vercel bot PR comment,
which is always present and has working URLs regardless of whether
a build ran. Added pull-requests:read permission for comment access.

Dropped /health from the checked endpoints — now behind VPN
(internal.flagsmith.com only) and returns 404 on public URLs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
talissoncosta and others added 3 commits April 16, 2026 10:13
- Grep pattern widened from `flagsmith-frontend[^ )]*` to
  `[^ )]*vercel\.app` — resilient to project renames
- Index page check now validates the response body contains
  'Flagsmith', catching broken deployments that serve error
  pages with 200 status. Single curl call for both status + body.

Closes #7262

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previous approach tested preview URLs immediately, producing false
positives when Vercel was still deploying (the stale previous build
responded 200).

Two-phase approach:
1. Wait for Vercel deployment statuses to leave 'pending' — polls
   the commit status API until all Vercel-related checks complete.
   Handles real builds (waits for success/failure), skipped builds
   (immediately complete), and build failures (reports + exits).
2. Parse frontend preview URLs from the Vercel bot PR comment (now
   guaranteed up-to-date) and curl them with status + content
   validation.

Trade-off: slower (waits for Vercel build, typically 2-8 min) but
correct — no false positives.

Contributes to #7262

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Filter statuses by 'flagsmith-frontend' instead of 'Vercel' so
  docs deployments don't block the wait
- Poll up to 30s for the Vercel bot comment after deployments
  complete (handles timing gap between deploy finish and comment
  update)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

Last blocking point to me is the continue-on-error that defeats the purpose of blocking the deployment if the target is unhealthy.
I'd separate 2 cases:

  1. We couldn't check because of timeout, no statuses or no comment (we don't know but nothing hints in not deploying) => this would be acceptable to skip
  2. We managed to send a request to vercel and it failed, the app is clearly down => here we block deployment

I'm unsure how to achieve this but I think we could leverage on the exit status (0 when we want to continue; 1 => we block)

name: Vercel Preview Smoke Test
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: true
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.

I'm just worried that this would let the deployment happen in case it raised a real error

@talissoncosta
Copy link
Copy Markdown
Contributor Author

Closing — the approach is too brittle. Scraping the Vercel bot's PR comment to extract the preview URL means our CI depends on a third-party comment format we don't control, and silently breaks if Vercel changes it. If we ever want this check, it should pull the preview URL from a reliable source (Vercel API, deployment status, or a job output from Vercel's own check) rather than parsed markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd Build, test and deployment related front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Add Vercel preview smoke test to frontend PR workflow

3 participants