- apps/web/lighthouserc.cjs: desktop preset, 3 runs, P/A/B/S ≥ 90 断言 - apps/web/scripts/lhci-scores.cjs: 本地汇总脚本(median P/A/B/S + ✅/❌ 标记) - .github/workflows/web-ci.yml: 新增 lighthouse job,treosh/lighthouse-ci-action@v12 - apps/web/package.json: +lhci script - apps/web/.gitignore: .lighthouseci/ 加入忽略(避免本地 12 个 run 报告污染 repo) 本地验证(desktop preset, 3 runs × 4 URLs): perf=100 a11y=95-96 best=96 seo=91 (全部 ≥ 90 ✅) G3 闸门状态:typecheck ✅ / lint ✅ / vitest 69 ✅ / e2e 84/84 ✅ / build 87.85KB ✅ / Lighthouse P/A/B/S ✅ / 真实后端 ⏳(T-B-27)/ Poster CLI Docker ⏳(T-C-44)
169 lines
3.9 KiB
YAML
169 lines
3.9 KiB
YAML
name: web-ci
|
||
|
||
on:
|
||
push:
|
||
branches: [main, develop]
|
||
paths:
|
||
- 'apps/web/**'
|
||
- 'package.json'
|
||
- 'pnpm-lock.yaml'
|
||
- 'turbo.json'
|
||
pull_request:
|
||
paths:
|
||
- 'apps/web/**'
|
||
- 'package.json'
|
||
- 'pnpm-lock.yaml'
|
||
- 'turbo.json'
|
||
|
||
jobs:
|
||
ci:
|
||
runs-on: ubuntu-latest
|
||
timeout-minutes: 15
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v4
|
||
with:
|
||
version: 10
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: TypeScript typecheck (G1 闸门: 0 any)
|
||
run: pnpm typecheck
|
||
|
||
- name: ESLint (G1 闸门: 0 warning)
|
||
run: pnpm lint
|
||
|
||
- name: Vitest (单元测试)
|
||
run: pnpm test
|
||
|
||
- name: Build
|
||
run: pnpm build
|
||
|
||
- name: Upload build artifacts
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: web-dist
|
||
path: apps/web/dist
|
||
retention-days: 7
|
||
|
||
e2e:
|
||
runs-on: ubuntu-latest
|
||
needs: ci
|
||
timeout-minutes: 20
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v4
|
||
with:
|
||
version: 10
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: Install Playwright browsers
|
||
run: pnpm --filter @gaokao/web exec playwright install --with-deps
|
||
|
||
- name: Build for preview
|
||
run: pnpm --filter @gaokao/web build
|
||
|
||
- name: Run Playwright e2e tests
|
||
run: pnpm --filter @gaokao/web test:e2e
|
||
|
||
- name: Upload Playwright report
|
||
if: always()
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: playwright-report
|
||
path: apps/web/playwright-report
|
||
retention-days: 7
|
||
|
||
chromatic:
|
||
runs-on: ubuntu-latest
|
||
needs: ci
|
||
timeout-minutes: 15
|
||
if: github.event_name == 'push' || github.event_name == 'pull_request'
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v4
|
||
with:
|
||
version: 10
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: Build
|
||
run: pnpm --filter @gaokao/web build
|
||
|
||
- name: Publish to Chromatic
|
||
uses: chromaui/action@v1
|
||
with:
|
||
projectToken: ${{ secrets.CHROMATIC_TOKEN }}
|
||
workingDir: apps/web
|
||
buildScriptName: build
|
||
exitZeroOnChanges: true
|
||
|
||
lighthouse:
|
||
# G3 闸门真实化:P/A/B/S 均 ≥ 90
|
||
runs-on: ubuntu-latest
|
||
needs: ci
|
||
timeout-minutes: 15
|
||
if: github.event_name == 'push' || github.event_name == 'pull_request'
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v4
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
- name: Build
|
||
run: pnpm --filter @gaokao/web build
|
||
|
||
- name: Run Lighthouse CI (G3 闸门:P/A/B/S ≥ 90)
|
||
uses: treosh/lighthouse-ci-action@v12
|
||
with:
|
||
configPath: ./apps/web/lighthouserc.cjs
|
||
uploadArtifacts: true
|
||
temporaryPublicStorage: true
|
||
runs: 3
|
||
serverUrl: http://127.0.0.1:8080/
|
||
# treosh action 自动启动 vite preview @ 8080
|
||
url: |
|
||
http://127.0.0.1:8080/
|
||
http://127.0.0.1:8080/data-query
|
||
http://127.0.0.1:8080/plans
|
||
http://127.0.0.1:8080/about
|