Skip to content

ci(pages): add smoke test step to verify build output is servable - #741

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
HuijungYoon:chore/pages-ci-smoke-test
Aug 6, 2026
Merged

ci(pages): add smoke test step to verify build output is servable#741
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
HuijungYoon:chore/pages-ci-smoke-test

Conversation

@HuijungYoon

@HuijungYoon HuijungYoon commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add serve as a pages devDependency so CI can statically serve dist/ without downloading on every run.
  • After the Build step in pages-ci.yml, smoke-test /, /docs/contributing, /docs/quickstart, and /features for HTTP 200 responses that include .bundle.js references (SPA mode via serve -s).
  • Closes ci(pages): add smoke test step to verify build output is servable #725

Test plan

  • Pages CI runs on this PR (pages/** path filter)
  • Smoke test step passes (all four routes OK)
  • Bundle size check still runs after smoke test
  • Locally (Node 24.18.0): cd pages && npm install && npm run build, then run the smoke script from the workflow

Serve dist/ after build and assert key SPA routes return HTML with bundle references so broken templates cannot slip through CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant

CLAassistant commented Aug 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 2 issue(s) in this PR.

  • ✅ Successfully posted inline: 2 comment(s)

npx serve dist -s -l tcp://127.0.0.1:3999 &
SERVER_PID=$!
trap 'kill $SERVER_PID 2>/dev/null || true' EXIT
sleep 2

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.

[maintainability · medium]
Reliability concern: fixed sleep 2 is fragile.

On a busy CI runner, 2 seconds may not be enough for the server to be ready. Consider using a polling loop with retries instead, which is more resilient to variable startup times:

for i in $(seq 1 20); do
  curl -sf http://127.0.0.1:3999/ > /dev/null && break
  sleep 0.5
done

Comment thread .github/workflows/pages-ci.yml Outdated
Comment on lines +58 to +59
BODY=$(curl -sf "http://127.0.0.1:3999${path}")
if [ $? -ne 0 ]; then

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.

[bug · high]
Bug: set -e will kill the script before the $? check is reached.

GitHub Actions run: steps use bash -eo pipefail by default. When curl -sf fails (e.g., the server isn't ready or a path returns an error), the command substitution BODY=$(curl -sf ...) will propagate the non-zero exit code, and set -e will immediately terminate the script — before the if [ $? -ne 0 ] check ever runs. This means the first failing path aborts the entire loop, skipping remaining paths and the exit $FAILED line.

Restructure so that curl's failure is caught within an if condition (which is exempt from set -e):

Suggestion:

Suggested change
BODY=$(curl -sf "http://127.0.0.1:3999${path}")
if [ $? -ne 0 ]; then
if ! BODY=$(curl -sf "http://127.0.0.1:3999${path}"); then

@lizhengfeng101

Copy link
Copy Markdown
Collaborator

@HuijungYoon Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@HuijungYoon

HuijungYoon commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 I've signed the CLA! I'm really looking forward to contributing more to this project. Thank you!

@lizhengfeng101

Copy link
Copy Markdown
Collaborator

@lizhengfeng101 I've signed the CLA! I'm really looking forward to contributing more to this project. Thank you!

ok

@lizhengfeng101

Copy link
Copy Markdown
Collaborator

Hey @HuijungYoon, nice addition — the smoke step is a sensible lightweight alternative to spinning up Playwright. Two things I'd love your take on before this goes in:

1. All four routes resolve to the same index.html under serve -s. Since this is a React Router SPA, serve -s rewrites every unmatched path to index.html, and dist/ only contains index.html / 404.html / the bundles. So /, /docs/contributing, /docs/quickstart, and /features all return the identical HTML, and the .bundle.js assertion is effectively the same check run four times. It'll catch a missing index.html or a broken bundle reference, but it won't catch a broken route component (that only surfaces once React Router renders client-side). Not a blocker, but the four-route list reads like it's testing more than it actually is — might be worth either a comment noting the limitation, or adding one assertion against a real static file (e.g. /404.html) so we're confirming the server is genuinely reading dist/.

2. Minor: the if [ $? -ne 0 ] branch is effectively dead under the Actions default shell. GitHub runs run: steps with bash --noprofile --norc -eo pipefail, so set -e is active. On a BODY=$(curl -sf ...) failure the step aborts before reaching the $? check, so the friendly "not reachable" message never prints. In practice this rarely bites (given point 1, routes won't individually 404 — only a fully-dead server would fail curl, and that still fails CI on the first / request), so I'd call it a cleanup rather than a must-fix. If you want the branch to actually work, moving curl into the tested context does it:

if ! BODY=$(curl -sf "http://127.0.0.1:3999${path}"); then
  echo "FAIL: ${path} — not reachable"; FAILED=1
elif ! echo "$BODY" | grep -q '\.bundle\.js'; then
  ...

Also +1 on the trap ... EXIT for cleanup — nice touch over the original issue snippet.

Clarify the SPA fallback limitation, make the curl failure branch work under set -e, and add a /404.html static-file assertion to confirm dist assets are actually served.
@HuijungYoon

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101

Thanks for the thoughtful review

I pushed a follow-up commit that addresses both items:

  1. Added a comment clarifying the SPA limitation with serve -s (the route checks validate shell reachability and bundle references, not client-side route rendering correctness).
  2. Updated the curl branch to if ! BODY=$(curl -sf ...) so the “not reachable” path works correctly under GitHub Actions’ bash -e behavior.
  3. Added a static asset check for /404.html to confirm we’re actually serving files from dist/, not only exercising SPA fallback.

Really appreciate the careful read and the concrete suggestions.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 48eb444 into alibaba:main Aug 6, 2026
12 checks passed
@HuijungYoon
HuijungYoon deleted the chore/pages-ci-smoke-test branch August 6, 2026 12:25
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.

ci(pages): add smoke test step to verify build output is servable

3 participants