- 将 cache: 'npm' 改为 cache: 'pnpm',正确匹配 pnpm-lock.yaml - 将 npm ci 改为 pnpm install(通过 corepack enable pnpm 安装 pnpm) - 此修复解决 PR #114 的推送检查失败问题
135 lines
3.3 KiB
YAML
135 lines
3.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
permissions:
|
|
actions: read
|
|
contents: read
|
|
|
|
jobs:
|
|
# PR 时运行:lint、test、build 和冒烟测试
|
|
main:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# Cache node_modules
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
|
|
- run: corepack enable pnpm
|
|
- run: pnpm install
|
|
- uses: nrwl/nx-set-shas@v4
|
|
|
|
|
|
# 安装 Playwright 浏览器和依赖
|
|
- name: Install Playwright
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
# lint、test、build
|
|
- run: npx nx affected -t test build --base=origin/develop --verbose
|
|
- run: npx nx affected -t lint --exclude=drawnix --base=origin/develop --verbose
|
|
|
|
# PR 时运行冒烟测试(快速,约2分钟)
|
|
- name: Run Smoke Tests
|
|
run: pnpm run e2e:smoke
|
|
|
|
- name: Upload Smoke Test Results
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: smoke-test-results
|
|
path: apps/web-e2e/test-results/
|
|
|
|
# PR 时运行视觉回归测试
|
|
- name: Run Visual Regression Tests
|
|
run: pnpm run e2e:visual
|
|
|
|
- name: Upload Visual Test Report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: visual-diff-report
|
|
path: apps/web-e2e/playwright-report/
|
|
|
|
- name: Check Bundle Size
|
|
if: always()
|
|
run: pnpm run size
|
|
|
|
- name: Upload Bundle Stats
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: bundle-stats
|
|
path: dist/apps/web/stats.html
|
|
|
|
# 发布前运行:完整 E2E 测试 + 生成用户手册
|
|
release-e2e:
|
|
runs-on: ubuntu-latest
|
|
# 仅在 main 分支 push 或手动触发时运行
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
|
|
- run: corepack enable pnpm
|
|
- run: pnpm install
|
|
|
|
# 安装所有浏览器用于完整测试
|
|
- name: Install Playwright Browsers
|
|
run: npx playwright install --with-deps
|
|
|
|
# 运行完整功能测试
|
|
- name: Run Full E2E Tests
|
|
run: pnpm run e2e:features
|
|
|
|
# 运行视觉回归测试
|
|
- name: Run Visual Tests
|
|
run: pnpm run e2e:visual
|
|
|
|
# 运行手册生成测试
|
|
- name: Run Manual Generation Tests
|
|
run: pnpm run e2e:manual
|
|
|
|
# 生成用户手册
|
|
- name: Generate User Manual
|
|
run: pnpm run generate:manual
|
|
|
|
# 上传测试报告
|
|
- name: Upload E2E Test Report
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: e2e-test-report
|
|
path: apps/web-e2e/playwright-report/
|
|
|
|
# 上传测试结果(包含截图)
|
|
- name: Upload Test Results
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: e2e-test-results
|
|
path: apps/web-e2e/test-results/
|
|
|
|
# 上传用户手册
|
|
- name: Upload User Manual
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: user-manual
|
|
path: docs/user-manual/
|
|
|