Files
NextEdu/.gitea/workflows/lighthouse.yml
SpecialX 1a34d1f14e ci(perf): 添加 Lighthouse CI 性能预算回归门槛配置
Phase 2 性能预算重构配套 CI:每次 PR 与每日凌晨 3 点对 /login 路由采样 3 次(desktop preset),断言 LCP <= 3000ms、CLS <= 0.1(error 级),FCP/TBT/INP 为 warn 级。失败时阻断合并并触发性能预算审计报告基线复核。
2026-07-06 15:58:49 +08:00

72 lines
2.0 KiB
YAML

name: Lighthouse CI
# 性能预算回归门槛:每次 PR 与每日凌晨 3 点对关键路由采样断言。
# 失败时阻断合并,触发审计报告 docs/architecture/audit/performance-budget-audit-report.md 中基线复核。
on:
pull_request:
branches:
- main
schedule:
- cron: "0 3 * * *" # 每天凌晨 3 点性能采样
workflow_dispatch:
jobs:
lighthouse:
runs-on: CDCD
container: dockerreg.eazygame.cn/node-with-docker:22
env:
SKIP_ENV_VALIDATION: "1"
NEXT_TELEMETRY_DISABLED: "1"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache npm dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Configure npm proxy
run: |
GATEWAY_IP=$(ip route show | grep default | awk '{print $3}')
if [ -z "$GATEWAY_IP" ]; then
GATEWAY_IP="172.17.0.1"
fi
PROXY_URL="http://$GATEWAY_IP:7890"
npm config set proxy "$PROXY_URL"
npm config set https-proxy "$PROXY_URL"
echo "http_proxy=$PROXY_URL" >> $GITHUB_ENV
echo "https_proxy=$PROXY_URL" >> $GITHUB_ENV
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Start production server
run: npm run start &
env:
PORT: "3000"
- name: Wait for server
run: |
for i in {1..30}; do
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000 | grep -q "200\|307\|308" && break
sleep 2
done
- name: Install Lighthouse CI
run: npm install -g @lhci/cli@0.13.x
- name: Run Lighthouse CI
run: lhci autorun --config=./lighthouserc.json --collect.url=http://localhost:3000/login || true
- name: Assert performance budgets
run: lhci assert --config=./lighthouserc.json