Revert "Apply robust server startup pattern to all jobs (visual-regression, performance) with proper cleanup"
CI Pipeline / canary (pull_request) Successful in 1s
CI Pipeline / test (20) (pull_request) Successful in 2m0s
CI Pipeline / test (18) (pull_request) Successful in 2m10s
CI Pipeline / e2e (chromium) (pull_request) Failing after 54m36s
CI Pipeline / e2e (firefox) (pull_request) Failing after 1h2m46s
CI Pipeline / visual-regression (pull_request) Failing after 3m9s
CI Pipeline / performance (pull_request) Failing after 1m55s
CI Pipeline / e2e (webkit) (pull_request) Failing after 15m47s
CI Pipeline / lint (pull_request) Failing after 1m23s
CI Pipeline / build (pull_request) Successful in 2m24s
CI Pipeline / storybook (pull_request) Failing after 6m16s
CI Pipeline / canary (pull_request) Successful in 1s
CI Pipeline / test (20) (pull_request) Successful in 2m0s
CI Pipeline / test (18) (pull_request) Successful in 2m10s
CI Pipeline / e2e (chromium) (pull_request) Failing after 54m36s
CI Pipeline / e2e (firefox) (pull_request) Failing after 1h2m46s
CI Pipeline / visual-regression (pull_request) Failing after 3m9s
CI Pipeline / performance (pull_request) Failing after 1m55s
CI Pipeline / e2e (webkit) (pull_request) Failing after 15m47s
CI Pipeline / lint (pull_request) Failing after 1m23s
CI Pipeline / build (pull_request) Successful in 2m24s
CI Pipeline / storybook (pull_request) Failing after 6m16s
This reverts commit 8efe237018.
This commit is contained in:
+112
-80
@@ -125,51 +125,74 @@ jobs:
|
|||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npx playwright install --with-deps
|
- run: npx playwright install --with-deps
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
# 1) Sanity check that the build exists
|
||||||
- name: Start app (background) + healthcheck
|
- name: Verify Next build output
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
# pick a port that's unlikely to be busy
|
ls -la .next || true
|
||||||
export PORT="${PORT:-3011}"
|
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
||||||
export HOST="127.0.0.1"
|
|
||||||
|
|
||||||
# ensure build exists
|
# 2) Start the right kind of server and capture logs
|
||||||
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
|
- name: Start app (auto-detect start vs export)
|
||||||
|
|
||||||
# start and detach with logs
|
|
||||||
mkdir -p .next
|
|
||||||
nohup npm run start -- -p "$PORT" -H "$HOST" > .next/runner.log 2>&1 &
|
|
||||||
echo $! > .next/runner.pid
|
|
||||||
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
|
|
||||||
|
|
||||||
# wait for TCP, then HTTP
|
|
||||||
npx wait-on -t 120000 "tcp:$HOST:$PORT"
|
|
||||||
curl -fsS "http://$HOST:$PORT" >/dev/null
|
|
||||||
|
|
||||||
echo "✅ App is responding"
|
|
||||||
env:
|
|
||||||
NEXT_TELEMETRY_DISABLED: "1"
|
|
||||||
NODE_ENV: production
|
|
||||||
- name: Show last 200 lines of server log on failure
|
|
||||||
if: failure()
|
|
||||||
run: |
|
run: |
|
||||||
echo "––– .next/runner.log (tail) –––"
|
set -euxo pipefail
|
||||||
tail -n 200 .next/runner.log || true
|
|
||||||
|
|
||||||
|
# prefer production server if Next build exists
|
||||||
|
if [ -f .next/BUILD_ID ]; then
|
||||||
|
# run Next in the foreground for 3s to flush any crash to logs, then background it
|
||||||
|
(NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 \
|
||||||
|
node --trace-uncaught node_modules/next/dist/bin/next start -p 3000 -H 127.0.0.1 \
|
||||||
|
) > server.log 2>&1 &
|
||||||
|
|
||||||
|
# fall back to static export (if your project uses output: 'export')
|
||||||
|
elif [ -d out ]; then
|
||||||
|
npx --yes http-server out -p 3000 --silent > server.log 2>&1 &
|
||||||
|
else
|
||||||
|
echo "Neither .next nor out/ present – nothing to serve"; cat server.log || true; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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: |
|
||||||
|
set -e
|
||||||
|
PID=$(cat server.pid)
|
||||||
|
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: gitea.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
run: PLAYWRIGHT_UPDATE_SNAPSHOTS=1 npx playwright test tests/e2e/visual-regression.spec.ts --project=chromium
|
run: PLAYWRIGHT_UPDATE_SNAPSHOTS=1 npx playwright test tests/e2e/visual-regression.spec.ts --project=chromium
|
||||||
env:
|
env: { CI: true }
|
||||||
CI: true
|
|
||||||
BASE_URL: http://127.0.0.1:3011
|
|
||||||
|
|
||||||
# Run visual regression tests
|
# Run visual regression tests
|
||||||
- name: Run visual regression tests
|
- name: Run visual regression tests
|
||||||
run: npx playwright test tests/e2e/visual-regression.spec.ts
|
run: npx playwright test tests/e2e/visual-regression.spec.ts
|
||||||
env:
|
env: { CI: true }
|
||||||
CI: true
|
|
||||||
BASE_URL: http://127.0.0.1:3011
|
|
||||||
|
|
||||||
- name: Package visual artifacts
|
- name: Package visual artifacts
|
||||||
if: always()
|
if: always()
|
||||||
@@ -183,13 +206,6 @@ jobs:
|
|||||||
name: visual-regression-results
|
name: visual-regression-results
|
||||||
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]
|
||||||
@@ -211,59 +227,75 @@ jobs:
|
|||||||
- name: Build application
|
- name: Build application
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Start app (background) + healthcheck
|
# 1) Sanity check that the build exists
|
||||||
|
- name: Verify Next build output
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
# pick a port that's unlikely to be busy
|
ls -la .next || true
|
||||||
export PORT="${PORT:-3012}"
|
test -f .next/BUILD_ID || (echo "No Next build output (.next) – did build fail?" && exit 1)
|
||||||
export HOST="127.0.0.1"
|
|
||||||
|
|
||||||
# ensure build exists
|
# 2) Start the right kind of server and capture logs
|
||||||
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
|
- name: Start app (auto-detect start vs export)
|
||||||
|
|
||||||
# start and detach with logs
|
|
||||||
mkdir -p .next
|
|
||||||
nohup npm run start -- -p "$PORT" -H "$HOST" > .next/runner.log 2>&1 &
|
|
||||||
echo $! > .next/runner.pid
|
|
||||||
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
|
|
||||||
|
|
||||||
# wait for TCP, then HTTP
|
|
||||||
npx wait-on -t 120000 "tcp:$HOST:$PORT"
|
|
||||||
curl -fsS "http://$HOST:$PORT" >/dev/null
|
|
||||||
|
|
||||||
echo "✅ App is responding"
|
|
||||||
env:
|
|
||||||
NEXT_TELEMETRY_DISABLED: "1"
|
|
||||||
NODE_ENV: production
|
|
||||||
- name: Show last 200 lines of server log on failure
|
|
||||||
if: failure()
|
|
||||||
run: |
|
run: |
|
||||||
echo "––– .next/runner.log (tail) –––"
|
set -euxo pipefail
|
||||||
tail -n 200 .next/runner.log || true
|
|
||||||
|
# prefer production server if Next build exists
|
||||||
|
if [ -f .next/BUILD_ID ]; then
|
||||||
|
# run Next in the foreground for 3s to flush any crash to logs, then background it
|
||||||
|
(NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 \
|
||||||
|
node --trace-uncaught node_modules/next/dist/bin/next start -p 3000 -H 127.0.0.1 \
|
||||||
|
) > server.log 2>&1 &
|
||||||
|
|
||||||
|
# fall back to static export (if your project uses output: 'export')
|
||||||
|
elif [ -d out ]; then
|
||||||
|
npx --yes http-server out -p 3000 --silent > server.log 2>&1 &
|
||||||
|
else
|
||||||
|
echo "Neither .next nor out/ present – nothing to serve"; cat server.log || true; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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: |
|
||||||
|
set -e
|
||||||
|
PID=$(cat server.pid)
|
||||||
|
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"
|
||||||
env:
|
env: { CI: true }
|
||||||
LHCI_BUILD_CONTEXT__CURRENT_HASH: ${{ gitea.sha }}
|
|
||||||
LHCI_BUILD_CONTEXT__COMMIT_TIME: ${{ gitea.event.head_commit.timestamp }}
|
|
||||||
LHCI_BUILD_CONTEXT__CURRENT_BRANCH: ${{ gitea.ref_name }}
|
|
||||||
LHCI_BUILD_CONTEXT__COMMIT_MESSAGE: ${{ gitea.event.head_commit.message }}
|
|
||||||
CI: true
|
|
||||||
|
|
||||||
- name: Upload LHCI results
|
- name: Upload LHCI results
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: lhci-results
|
name: lhci-results
|
||||||
path: .lighthouseci/
|
path: lhci-results
|
||||||
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
|
|
||||||
|
|
||||||
storybook:
|
storybook:
|
||||||
runs-on: [self-hosted, macos-latest]
|
runs-on: [self-hosted, macos-latest]
|
||||||
|
|||||||
Reference in New Issue
Block a user