Fix visual regression and performance server issue
This commit is contained in:
+51
-97
@@ -108,7 +108,7 @@ jobs:
|
|||||||
name: playwright-results-${{ matrix.browser }}
|
name: playwright-results-${{ matrix.browser }}
|
||||||
path: playwright-${{ matrix.browser }}.tgz
|
path: playwright-${{ matrix.browser }}.tgz
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
- name: Stop app
|
- name: Stop app
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
@@ -132,57 +132,27 @@ jobs:
|
|||||||
ls -la .next || true
|
ls -la .next || true
|
||||||
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
||||||
|
|
||||||
# 2) Start the right kind of server and capture logs
|
- name: Start app (background) + healthcheck
|
||||||
- name: Start app (auto-detect start vs export)
|
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
export PORT="${PORT:-3000}"
|
||||||
# prefer production server if Next build exists
|
export HOST="127.0.0.1"
|
||||||
if [ -f .next/BUILD_ID ]; then
|
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
|
||||||
# run Next in the foreground for 3s to flush any crash to logs, then background it
|
mkdir -p .next
|
||||||
(NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 \
|
nohup npm run start -- -p "$PORT" -H "$HOST" > .next/runner.log 2>&1 &
|
||||||
node --trace-uncaught node_modules/next/dist/bin/next start -p 3000 -H 127.0.0.1 \
|
echo $! > .next/runner.pid
|
||||||
) > server.log 2>&1 &
|
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
|
||||||
|
npx wait-on -t 120000 "tcp:$HOST:$PORT"
|
||||||
# fall back to static export (if your project uses output: 'export')
|
curl -fsS "http://$HOST:$PORT" >/dev/null
|
||||||
elif [ -d out ]; then
|
echo "✅ App is responding"
|
||||||
npx --yes http-server out -p 3000 --silent > server.log 2>&1 &
|
env:
|
||||||
else
|
NEXT_TELEMETRY_DISABLED: "1"
|
||||||
echo "Neither .next nor out/ present – nothing to serve"; cat server.log || true; exit 1
|
NODE_ENV: production
|
||||||
fi
|
- name: Show last 200 lines of server log on failure
|
||||||
|
if: failure()
|
||||||
echo $! > server.pid
|
|
||||||
sleep 2
|
|
||||||
echo "----- first server log lines -----"
|
|
||||||
head -n 200 server.log || true
|
|
||||||
echo "----------------------------------"
|
|
||||||
|
|
||||||
# 3) Fail fast if the process died
|
|
||||||
- name: Check server process
|
|
||||||
run: |
|
run: |
|
||||||
set -e
|
echo "––– .next/runner.log (tail) –––"
|
||||||
PID=$(cat server.pid)
|
tail -n 200 .next/runner.log || true
|
||||||
if ! ps -p "$PID" > /dev/null; then
|
|
||||||
echo "Server crashed during startup:"
|
|
||||||
cat server.log || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4) Wait for readiness with helpful diagnostics
|
|
||||||
- name: Wait for http://127.0.0.1:3000
|
|
||||||
run: |
|
|
||||||
set -euxo pipefail
|
|
||||||
for i in $(seq 1 60); do
|
|
||||||
if curl -sf http://127.0.0.1:3000 >/dev/null; then
|
|
||||||
echo "App is up ✅"; exit 0
|
|
||||||
fi
|
|
||||||
if [ $i -eq 1 ] || [ $((i%10)) -eq 0 ]; then
|
|
||||||
echo "Still waiting… attempt $i"
|
|
||||||
tail -n 50 server.log || true
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Timed out waiting for app"; tail -n +1 server.log || true; exit 1
|
|
||||||
# Seed snapshots on main branch only (one-time setup)
|
# Seed snapshots on main branch only (one-time setup)
|
||||||
- name: Seed snapshots (main only)
|
- name: Seed snapshots (main only)
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
@@ -207,6 +177,13 @@ jobs:
|
|||||||
path: visual-regression.tgz
|
path: visual-regression.tgz
|
||||||
retention-days: 30
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Stop app
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f .next/runner.pid ]; then
|
||||||
|
kill $(cat .next/runner.pid) 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
performance:
|
performance:
|
||||||
runs-on: [self-hosted, macos-latest]
|
runs-on: [self-hosted, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
@@ -234,57 +211,27 @@ jobs:
|
|||||||
ls -la .next || true
|
ls -la .next || true
|
||||||
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
||||||
|
|
||||||
# 2) Start the right kind of server and capture logs
|
- name: Start app (background) + healthcheck
|
||||||
- name: Start app (auto-detect start vs export)
|
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
export PORT="${PORT:-3000}"
|
||||||
# prefer production server if Next build exists
|
export HOST="127.0.0.1"
|
||||||
if [ -f .next/BUILD_ID ]; then
|
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
|
||||||
# run Next in the foreground for 3s to flush any crash to logs, then background it
|
mkdir -p .next
|
||||||
(NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 \
|
nohup npm run start -- -p "$PORT" -H "$HOST" > .next/runner.log 2>&1 &
|
||||||
node --trace-uncaught node_modules/next/dist/bin/next start -p 3000 -H 127.0.0.1 \
|
echo $! > .next/runner.pid
|
||||||
) > server.log 2>&1 &
|
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
|
||||||
|
npx wait-on -t 120000 "tcp:$HOST:$PORT"
|
||||||
# fall back to static export (if your project uses output: 'export')
|
curl -fsS "http://$HOST:$PORT" >/dev/null
|
||||||
elif [ -d out ]; then
|
echo "✅ App is responding"
|
||||||
npx --yes http-server out -p 3000 --silent > server.log 2>&1 &
|
env:
|
||||||
else
|
NEXT_TELEMETRY_DISABLED: "1"
|
||||||
echo "Neither .next nor out/ present – nothing to serve"; cat server.log || true; exit 1
|
NODE_ENV: production
|
||||||
fi
|
- name: Show last 200 lines of server log on failure
|
||||||
|
if: failure()
|
||||||
echo $! > server.pid
|
|
||||||
sleep 2
|
|
||||||
echo "----- first server log lines -----"
|
|
||||||
head -n 200 server.log || true
|
|
||||||
echo "----------------------------------"
|
|
||||||
|
|
||||||
# 3) Fail fast if the process died
|
|
||||||
- name: Check server process
|
|
||||||
run: |
|
run: |
|
||||||
set -e
|
echo "––– .next/runner.log (tail) –––"
|
||||||
PID=$(cat server.pid)
|
tail -n 200 .next/runner.log || true
|
||||||
if ! ps -p "$PID" > /dev/null; then
|
|
||||||
echo "Server crashed during startup:"
|
|
||||||
cat server.log || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4) Wait for readiness with helpful diagnostics
|
|
||||||
- name: Wait for http://127.0.0.1:3000
|
|
||||||
run: |
|
|
||||||
set -euxo pipefail
|
|
||||||
for i in $(seq 1 60); do
|
|
||||||
if curl -sf http://127.0.0.1:3000 >/dev/null; then
|
|
||||||
echo "App is up ✅"; exit 0
|
|
||||||
fi
|
|
||||||
if [ $i -eq 1 ] || [ $((i%10)) -eq 0 ]; then
|
|
||||||
echo "Still waiting… attempt $i"
|
|
||||||
tail -n 50 server.log || true
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
echo "Timed out waiting for app"; tail -n +1 server.log || true; exit 1
|
|
||||||
|
|
||||||
- name: Run Lighthouse CI
|
- name: Run Lighthouse CI
|
||||||
run: npx lhci autorun --chrome-path="$CHROME_PATH"
|
run: npx lhci autorun --chrome-path="$CHROME_PATH"
|
||||||
@@ -297,6 +244,13 @@ jobs:
|
|||||||
name: lhci-results
|
name: lhci-results
|
||||||
path: lhci-results
|
path: lhci-results
|
||||||
|
|
||||||
|
- name: Stop app
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f .next/runner.pid ]; then
|
||||||
|
kill $(cat .next/runner.pid) 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
storybook:
|
storybook:
|
||||||
runs-on: [self-hosted, macos-latest]
|
runs-on: [self-hosted, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Reference in New Issue
Block a user