Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/pages-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ 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

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


FAILED=0
for path in "/" "/docs/contributing" "/docs/quickstart" "/features"; do
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

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

exit $FAILED

- name: Check bundle size
working-directory: pages
run: npm run size
1 change: 1 addition & 0 deletions pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading