mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-10-19 10:14:00 +00:00
ci(pages): add smoke test step to verify build output is servable (#741)
* ci(pages): add smoke test step to verify build output is servable 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> * ci(pages): harden smoke test route checks 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. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
e33d09e750
commit
48eb444a25
2 changed files with 34 additions and 0 deletions
33
.github/workflows/pages-ci.yml
vendored
33
.github/workflows/pages-ci.yml
vendored
|
|
@ -45,6 +45,39 @@ jobs:
|
|||
working-directory: pages
|
||||
run: npm run build
|
||||
|
||||
- name: Smoke test
|
||||
working-directory: pages
|
||||
run: |
|
||||
npx serve dist -s -l tcp://127.0.0.1:3999 &
|
||||
SERVER_PID=$!
|
||||
trap 'kill $SERVER_PID 2>/dev/null || true' EXIT
|
||||
sleep 2
|
||||
|
||||
FAILED=0
|
||||
# `serve -s` rewrites SPA routes to index.html, so this verifies
|
||||
# the built shell is reachable and includes bundle references.
|
||||
for path in "/" "/docs/contributing" "/docs/quickstart" "/features"; do
|
||||
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
|
||||
echo "FAIL: ${path} — missing bundle reference"
|
||||
FAILED=1
|
||||
else
|
||||
echo "OK: ${path}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Also check a real static file to ensure dist assets are served.
|
||||
if ! curl -sf "http://127.0.0.1:3999/404.html" >/dev/null; then
|
||||
echo "FAIL: /404.html — static file not reachable"
|
||||
FAILED=1
|
||||
else
|
||||
echo "OK: /404.html"
|
||||
fi
|
||||
|
||||
exit $FAILED
|
||||
|
||||
- name: Check bundle size
|
||||
working-directory: pages
|
||||
run: npm run size
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
"jsdom": "^30.0.0",
|
||||
"postcss": "^8.5.15",
|
||||
"postcss-loader": "^7.3.3",
|
||||
"serve": "^14.2.6",
|
||||
"size-limit": "^13.0.1",
|
||||
"style-loader": "^3.3.3",
|
||||
"tailwindcss": "^3.3.5",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue