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