|
242
|
54
|
6
|
5
|
7145a8553a880d8a94356baf7bcb4e2df4631e61
|
0
|
发布测试报告
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
publish-reports:
name: 发布测试报告
runs-on: ubuntu-latest
if: always()
steps:
- name: 下载所有制品
uses: actions/download-artifact@v3
- name: 生成汇总报告
run: |
mkdir -p reports
# 合并所有报告
echo "生成 HTML 汇总报告..."
- if: github.ref == 'refs/heads/main'
name: 部署报告到 GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
destination_dir: test-reports/${{ github.run_number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./reports
- name: 发布报告链接
run: "echo \"\U0001F4CA 测试报告已发布:\"\necho \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/test-reports/${{ github.run_number }}\"\n"
...
|
publish-reports
|
["unit-tests","integration-tests", ["unit-tests","integration-tests","e2e-tests"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862765
|
1771862652
|
1771862765
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
245
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
安装依赖
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
setup:
name: 安装依赖
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 构建共享包
run: pnpm --filter @juhi/shared run build
- name: 缓存 node_modules
uses: actions/cache/save@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
e2e/node_modules
...
|
setup
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
246
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
共享包检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
shared-check:
name: 共享包检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.shared == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: TypeScript 类型检查
run: pnpm --filter @juhi/shared run build
- name: 运行共享层单元测试
run: pnpm --filter @juhi/shared run test:coverage
- name: 上传共享层覆盖率报告
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: "false"
files: shared/coverage/lcov.info
flags: shared
- name: 验证导出
run: |
cd shared
node -e "import('./dist/index.js').then(m => console.log('✅ 共享包导出验证通过'))"
...
|
shared-check
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
247
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
后端代码检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-lint:
name: 后端代码检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.backend == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: ESLint 检查
run: pnpm --filter juhi-api run lint
- name: TypeScript 类型检查
run: pnpm --filter juhi-api run type-check
- name: API 路由契约检查
run: pnpm --filter juhi-api run audit:route-contract
- name: 状态机集成审计
run: pnpm --filter juhi-api run audit:state-machines
- name: 事件发布覆盖审计
run: pnpm --filter juhi-api run audit:events
- name: 审计基线门禁(防回退)
run: pnpm --filter juhi-api run audit:gate
...
|
backend-lint
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
248
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
后端单元测试
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-test:
name: 后端单元测试
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行单元测试
run: pnpm --filter juhi-api run test:ci
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-secret-key
NODE_ENV: test
- name: 上传覆盖率报告
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: "false"
files: backend/coverage/lcov.info
flags: backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
...
|
backend-test
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
249
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
后端构建检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-build:
name: 后端构建检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 构建
run: pnpm --filter juhi-api run build
- name: 验证构建产物
run: |
if [ ! -d "backend/dist" ]; then
echo "❌ 构建产物不存在"
exit 1
fi
echo "✅ 后端构建验证通过"
...
|
backend-build
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
250
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
前端代码检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
frontend-lint:
name: 前端代码检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.frontend == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: ESLint 检查
run: pnpm --filter juhi-frontend run lint
- name: 数组守卫检查
run: pnpm --filter juhi-frontend run check:array-guard
- name: TypeScript 类型检查
run: pnpm --filter juhi-frontend run type-check
...
|
frontend-lint
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
251
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
前端构建检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
frontend-build:
name: 前端构建检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 构建
run: pnpm --filter juhi-frontend run build
- name: 验证构建产物
run: |
if [ ! -d "frontend/dist" ]; then
echo "❌ 构建产物不存在"
exit 1
fi
echo "✅ 前端构建验证通过"
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist
retention-days: "7"
...
|
frontend-build
|
["frontend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
252
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
移动端检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
mobile-check:
name: 移动端检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.mobile == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: ESLint 检查
run: pnpm --filter juhi-mobile run lint || true
- name: TypeScript 类型检查
run: pnpm --filter juhi-mobile run type-check || true
...
|
mobile-check
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
253
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
多租户安全审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
security-audit:
name: 多租户安全审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行多租户安全审计
run: pnpm --filter juhi-api run audit:tenant
continue-on-error: true
...
|
security-audit
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
254
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
Kafka 事件一致性审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
kafka-audit:
name: Kafka 事件一致性审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行 Kafka 事件一致性审计
run: |
cd backend
npx tsx scripts/audit-kafka-events.ts --ci
continue-on-error: true
- if: always()
name: 保存审计报告
run: |
cd backend
npx tsx scripts/audit-kafka-events.ts --json > kafka-audit-report.json || true
- if: always()
name: 上传审计报告
uses: actions/upload-artifact@v4
with:
name: kafka-audit-report
path: backend/kafka-audit-report.json
retention-days: "30"
...
|
kafka-audit
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
255
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
依赖安全审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
dependency-audit:
name: 依赖安全审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: pnpm 依赖审计
run: pnpm audit --audit-level high || true
...
|
dependency-audit
|
["setup"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
256
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
Docker 镜像构建
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
docker-build:
name: Docker 镜像构建
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v4
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 构建后端镜像
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./backend
push: "false"
tags: juhi-api:${{ github.sha }}
- name: 构建前端镜像
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./frontend
push: "false"
tags: juhi-frontend:${{ github.sha }}
...
|
docker-build
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
257
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
e2e-test:
name: E2E 测试
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 初始化测试数据库
run: |
cd backend
npx prisma migrate deploy
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_e2e
- name: 启动后端服务
run: |
cd backend
pnpm run dev &
sleep 15
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_e2e
REDIS_URL: redis://localhost:6379
JWT_SECRET: e2e-test-secret-key
NODE_ENV: test
PORT: 3000
- name: 后端健康检查
run: |
curl -f http://localhost:3000/health || exit 1
- name: 安装 Playwright
run: |
cd e2e
npx playwright install --with-deps chromium
- name: 运行 E2E 测试
run: |
cd e2e
pnpm run test || true
env:
E2E_BASE_URL: http://localhost:5173
E2E_API_URL: http://localhost:3000
E2E_TEST_USER: admin
E2E_TEST_PASSWORD: admin123
- if: always()
name: 上传测试报告
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: e2e/playwright-report
retention-days: "7"
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: juhi_e2e
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
...
|
e2e-test
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
258
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
触发专用测试套件
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
trigger-test-suite:
name: 触发专用测试套件
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- name: "\U0001F4DD 触发测试套件信息"
run: "echo \"## \U0001F9EA 专用测试工作流\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"以下专用测试工作流已自动触发:\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"- **Test Suite** (test.yml): 单元测试、API 测试、状态机测试\" >> $GITHUB_STEP_SUMMARY\necho \"- **E2E Tests** (e2e.yml): 端到端测试、业务流程测试\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"查看 Actions 页面了解详细测试结果。\" >> $GITHUB_STEP_SUMMARY\n"
...
|
trigger-test-suite
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
259
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
代码质量门控
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
quality-gate:
name: 代码质量门控
runs-on: ubuntu-latest
if: always()
steps:
- name: 检查所有任务状态
run: "echo \"## \U0001F4CA CI 验证结果\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"| 检查项 | 状态 |\" >> $GITHUB_STEP_SUMMARY\necho \"|--------|------|\" >> $GITHUB_STEP_SUMMARY\n\n# 后端测试\nif [ \"${{ needs.backend-test.result }}\" == \"success\" ]; then\n echo \"| ✅ 后端测试 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.backend-test.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 后端测试 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 后端测试 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 后端构建\nif [ \"${{ needs.backend-build.result }}\" == \"success\" ]; then\n echo \"| ✅ 后端构建 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.backend-build.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 后端构建 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 后端构建 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 前端构建\nif [ \"${{ needs.frontend-build.result }}\" == \"success\" ]; then\n echo \"| ✅ 前端构建 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.frontend-build.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 前端构建 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 前端构建 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 安全审计\nif [ \"${{ needs.security-audit.result }}\" == \"success\" ]; then\n echo \"| ✅ 安全审计 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.security-audit.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 安全审计 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ⚠️ 安全审计 | 警告 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# Kafka 审计\nif [ \"${{ needs.kafka-audit.result }}\" == \"success\" ]; then\n echo \"| ✅ Kafka 审计 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.kafka-audit.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ Kafka 审计 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ⚠️ Kafka 审计 | 警告 |\" >> $GITHUB_STEP_SUMMARY\nfi\n"
- name: 验证门控
run: |
BACKEND_TEST="${{ needs.backend-test.result }}"
BACKEND_BUILD="${{ needs.backend-build.result }}"
FRONTEND_BUILD="${{ needs.frontend-build.result }}"
# 跳过的任务视为通过
if [ "$BACKEND_BUILD" == "failure" ] || [ "$FRONTEND_BUILD" == "failure" ]; then
echo "❌ 构建失败,代码质量门控未通过"
exit 1
fi
if [ "$BACKEND_TEST" == "failure" ]; then
echo "❌ 测试失败,代码质量门控未通过"
exit 1
fi
echo "✅ 代码质量门控通过"
...
|
quality-gate
|
["backend-test","backend-build", ["backend-test","backend-build","frontend-build","security-audit","kafka-audit"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
260
|
56
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
CI 完成通知
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
ci-complete:
name: CI 完成通知
runs-on: ubuntu-latest
if: always()
steps:
- name: "\U0001F4E2 生成 CI 完成报告"
run: "echo \"## \U0001F389 CI 流程完成\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"**分支**: ${{ github.ref_name }}\" >> $GITHUB_STEP_SUMMARY\necho \"**提交**: ${{ github.sha }}\" >> $GITHUB_STEP_SUMMARY\necho \"**触发者**: ${{ github.actor }}\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\n\necho \"### \U0001F4CB 任务汇总\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\n\n# 质量门控\nif [ \"${{ needs.quality-gate.result }}\" == \"success\" ]; then\n echo \"- ✅ 代码质量门控: 通过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ 代码质量门控: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# E2E 测试\nif [ \"${{ needs.e2e-test.result }}\" == \"success\" ]; then\n echo \"- ✅ E2E 测试: 通过\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.e2e-test.result }}\" == \"skipped\" ]; then\n echo \"- ⏭️ E2E 测试: 跳过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ E2E 测试: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# Docker 构建\nif [ \"${{ needs.docker-build.result }}\" == \"success\" ]; then\n echo \"- ✅ Docker 镜像构建: 通过\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.docker-build.result }}\" == \"skipped\" ]; then\n echo \"- ⏭️ Docker 镜像构建: 跳过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ Docker 镜像构建: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"---\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"### \U0001F517 相关链接\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"- [查看完整测试报告](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\" >> $GITHUB_STEP_SUMMARY\necho \"- [查看覆盖率报告](https://codecov.io/gh/${{ github.repository }})\" >> $GITHUB_STEP_SUMMARY\n"
...
|
ci-complete
|
["quality-gate","e2e-test","do ["quality-gate","e2e-test","docker-build"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862813
|
1771862764
|
1771862813
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
262
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
集成测试(API + DB + Events)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
integration-tests:
name: 集成测试(API + DB + Events)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 设置测试环境变量
run: |
cd backend
cat > .env.test <<EOF
NODE_ENV=test
DATABASE_URL=postgresql://test:test@localhost:5432/juhi_test
REDIS_URL=redis://localhost:6379/1
KAFKA_BROKERS=localhost:9092
JWT_SECRET=test-secret-key
EOF
- name: 执行数据库迁移
run: |
cd backend
DATABASE_URL=$DATABASE_URL_TEST npx prisma migrate deploy
- name: 运行集成测试
run: cd backend && pnpm test:integration:coverage
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_test
REDIS_URL: redis://localhost:6379/1
KAFKA_BROKERS: localhost:9092
- if: always()
name: 上传集成测试结果
uses: actions/upload-artifact@v3
with:
name: integration-test-results
path: backend/test-results/
- name: 上传覆盖率报告
uses: codecov/codecov-action@v3
with:
files: ./backend/coverage/lcov.info
flags: integration
name: integration-coverage
timeout-minutes: "30"
services:
kafka:
image: confluentinc/cp-kafka:7.5.0
env:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_BROKER_ID: "1"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ports:
- 9092:9092
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
env:
ZOOKEEPER_CLIENT_PORT: "2181"
ports:
- 2181:2181
...
|
integration-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
263
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (chromium, approval)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (chromium, approval)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- chromium
flow:
- approval
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
264
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (chromium, lead-to-cash)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (chromium, lead-to-cash)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- chromium
flow:
- lead-to-cash
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
265
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (chromium, renewal)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (chromium, renewal)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- chromium
flow:
- renewal
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
266
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (chromium, service-ticket)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (chromium, service-ticket)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- chromium
flow:
- service-ticket
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
267
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (firefox, approval)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (firefox, approval)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- firefox
flow:
- approval
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
268
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (firefox, lead-to-cash)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (firefox, lead-to-cash)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- firefox
flow:
- lead-to-cash
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
269
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (firefox, renewal)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (firefox, renewal)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- firefox
flow:
- renewal
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
270
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (firefox, service-ticket)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (firefox, service-ticket)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- firefox
flow:
- service-ticket
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
271
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (webkit, approval)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (webkit, approval)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- webkit
flow:
- approval
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
272
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (webkit, lead-to-cash)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (webkit, lead-to-cash)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- webkit
flow:
- lead-to-cash
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
273
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (webkit, renewal)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (webkit, renewal)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- webkit
flow:
- renewal
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
274
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
E2E 测试(Playwright) (webkit, service-ticket)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
e2e-tests:
name: E2E 测试(Playwright) (webkit, service-ticket)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 安装 Playwright 浏览器
run: pnpm exec playwright install --with-deps ${{ matrix.browser }}
- name: 构建前端
run: cd frontend && pnpm build
- name: 启动服务
run: |
cd backend && pnpm start &
cd frontend && pnpm preview &
sleep 10
- name: 运行 E2E 测试
run: pnpm test:e2e --project=${{ matrix.browser }} --grep="${{ matrix.flow }}"
- if: always()
name: 上传 Playwright 报告
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-report
path: e2e/playwright-report/
- if: failure()
name: 上传失败截图
uses: actions/upload-artifact@v3
with:
name: e2e-${{ matrix.browser }}-${{ matrix.flow }}-screenshots
path: e2e/screenshots/
timeout-minutes: "45"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s
strategy:
matrix:
browser:
- webkit
flow:
- service-ticket
...
|
e2e-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
275
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
性能测试(K6)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
performance-tests:
name: 性能测试(K6)
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.event_name == 'schedule'
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 K6
run: |
curl https://github.com/grafana/k6/releases/download/v0.47.0/k6-v0.47.0-linux-amd64.tar.gz -L | tar xvz
sudo mv k6-v0.47.0-linux-amd64/k6 /usr/bin/k6
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖并启动服务
run: |
pnpm install --frozen-lockfile
cd backend && pnpm start &
sleep 10
- name: 运行性能测试
run: pnpm test:performance:ci
env:
API_URL: http://localhost:3000
AUTH_TOKEN: ${{ secrets.TEST_AUTH_TOKEN }}
- name: 分析性能结果
run: |
P95=$(jq '.metrics.http_req_duration.values.["p(95)"]' performance-results.json)
echo "P95 响应时间: ${P95}ms"
if (( $(echo "$P95 > 200" | bc -l) )); then
echo "❌ P95 响应时间超过 200ms"
exit 1
fi
echo "✅ 性能测试通过"
- if: always()
name: 上传性能报告
uses: actions/upload-artifact@v3
with:
name: performance-results
path: performance-results.json
timeout-minutes: "30"
services:
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
redis:
image: redis:7-alpine
ports:
- 6379:6379
...
|
performance-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
276
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
质量门禁检查
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
quality-gate:
name: 质量门禁检查
runs-on: ubuntu-latest
if: always()
steps:
- name: 下载所有测试结果
uses: actions/download-artifact@v3
- name: 汇总测试结果
run: |
echo "## 测试汇总报告" > summary.md
echo "" >> summary.md
echo "### 单元测试" >> summary.md
# 解析单元测试结果
echo "### 集成测试" >> summary.md
# 解析集成测试结果
echo "### E2E 测试" >> summary.md
# 解析 E2E 测试结果
- name: 检查所有测试是否通过
run: |
if [[ "${{ needs.unit-tests.result }}" != "success" ]]; then
echo "❌ 单元测试失败"
exit 1
fi
if [[ "${{ needs.integration-tests.result }}" != "success" ]]; then
echo "❌ 集成测试失败"
exit 1
fi
if [[ "${{ needs.e2e-tests.result }}" != "success" ]]; then
echo "❌ E2E 测试失败"
exit 1
fi
echo "✅ 所有测试通过,质量门禁检查成功"
- if: failure()
name: 发送通知
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: 测试失败!请查看详情。
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
...
|
quality-gate
|
["unit-tests","integration-tests", ["unit-tests","integration-tests","e2e-tests"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
277
|
57
|
6
|
5
|
343b38f6bfbbd7d44a1387e1351700df68013555
|
0
|
发布测试报告
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
publish-reports:
name: 发布测试报告
runs-on: ubuntu-latest
if: always()
steps:
- name: 下载所有制品
uses: actions/download-artifact@v3
- name: 生成汇总报告
run: |
mkdir -p reports
# 合并所有报告
echo "生成 HTML 汇总报告..."
- if: github.ref == 'refs/heads/main'
name: 部署报告到 GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
destination_dir: test-reports/${{ github.run_number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./reports
- name: 发布报告链接
run: "echo \"\U0001F4CA 测试报告已发布:\"\necho \"https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/test-reports/${{ github.run_number }}\"\n"
...
|
publish-reports
|
["unit-tests","integration-tests", ["unit-tests","integration-tests","e2e-tests"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862814
|
1771862765
|
1771862814
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
280
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
共享包检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
shared-check:
name: 共享包检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.shared == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: TypeScript 类型检查
run: pnpm --filter @juhi/shared run build
- name: 运行共享层单元测试
run: pnpm --filter @juhi/shared run test:coverage
- name: 上传共享层覆盖率报告
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: "false"
files: shared/coverage/lcov.info
flags: shared
- name: 验证导出
run: |
cd shared
node -e "import('./dist/index.js').then(m => console.log('✅ 共享包导出验证通过'))"
...
|
shared-check
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
281
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
后端代码检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-lint:
name: 后端代码检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.backend == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: ESLint 检查
run: pnpm --filter juhi-api run lint
- name: TypeScript 类型检查
run: pnpm --filter juhi-api run type-check
- name: API 路由契约检查
run: pnpm --filter juhi-api run audit:route-contract
- name: 状态机集成审计
run: pnpm --filter juhi-api run audit:state-machines
- name: 事件发布覆盖审计
run: pnpm --filter juhi-api run audit:events
- name: 审计基线门禁(防回退)
run: pnpm --filter juhi-api run audit:gate
...
|
backend-lint
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
282
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
后端单元测试
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-test:
name: 后端单元测试
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行单元测试
run: pnpm --filter juhi-api run test:ci
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_test
REDIS_URL: redis://localhost:6379
JWT_SECRET: test-secret-key
NODE_ENV: test
- name: 上传覆盖率报告
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: "false"
files: backend/coverage/lcov.info
flags: backend
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
...
|
backend-test
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
283
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
后端构建检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
backend-build:
name: 后端构建检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 构建
run: pnpm --filter juhi-api run build
- name: 验证构建产物
run: |
if [ ! -d "backend/dist" ]; then
echo "❌ 构建产物不存在"
exit 1
fi
echo "✅ 后端构建验证通过"
...
|
backend-build
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
284
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
前端代码检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
frontend-lint:
name: 前端代码检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.frontend == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: ESLint 检查
run: pnpm --filter juhi-frontend run lint
- name: 数组守卫检查
run: pnpm --filter juhi-frontend run check:array-guard
- name: TypeScript 类型检查
run: pnpm --filter juhi-frontend run type-check
...
|
frontend-lint
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
285
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
前端构建检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
frontend-build:
name: 前端构建检查
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 构建
run: pnpm --filter juhi-frontend run build
- name: 验证构建产物
run: |
if [ ! -d "frontend/dist" ]; then
echo "❌ 构建产物不存在"
exit 1
fi
echo "✅ 前端构建验证通过"
- name: 上传构建产物
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist
retention-days: "7"
...
|
frontend-build
|
["frontend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
286
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
移动端检查
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
mobile-check:
name: 移动端检查
runs-on: ubuntu-latest
if: needs.detect-changes.outputs.mobile == 'true'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: ESLint 检查
run: pnpm --filter juhi-mobile run lint || true
- name: TypeScript 类型检查
run: pnpm --filter juhi-mobile run type-check || true
...
|
mobile-check
|
["setup","detect-changes"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
287
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
多租户安全审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
security-audit:
name: 多租户安全审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行多租户安全审计
run: pnpm --filter juhi-api run audit:tenant
continue-on-error: true
...
|
security-audit
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
288
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
Kafka 事件一致性审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
kafka-audit:
name: Kafka 事件一致性审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 运行 Kafka 事件一致性审计
run: |
cd backend
npx tsx scripts/audit-kafka-events.ts --ci
continue-on-error: true
- if: always()
name: 保存审计报告
run: |
cd backend
npx tsx scripts/audit-kafka-events.ts --json > kafka-audit-report.json || true
- if: always()
name: 上传审计报告
uses: actions/upload-artifact@v4
with:
name: kafka-audit-report
path: backend/kafka-audit-report.json
retention-days: "30"
...
|
kafka-audit
|
["backend-lint"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
289
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
依赖安全审计
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
dependency-audit:
name: 依赖安全审计
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: pnpm 依赖审计
run: pnpm audit --audit-level high || true
...
|
dependency-audit
|
["setup"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
290
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
Docker 镜像构建
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
docker-build:
name: Docker 镜像构建
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- uses: actions/checkout@v4
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 构建后端镜像
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./backend
push: "false"
tags: juhi-api:${{ github.sha }}
- name: 构建前端镜像
uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: ./frontend
push: "false"
tags: juhi-frontend:${{ github.sha }}
...
|
docker-build
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
291
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
E2E 测试
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
e2e-test:
name: E2E 测试
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: 安装 pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 恢复依赖缓存
uses: actions/cache/restore@v4
with:
key: deps-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
backend/node_modules
frontend/node_modules
mobile/node_modules
shared/node_modules
shared/dist
- name: 生成 Prisma Client
run: pnpm --filter juhi-api run db:generate
- name: 初始化测试数据库
run: |
cd backend
npx prisma migrate deploy
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_e2e
- name: 启动后端服务
run: |
cd backend
pnpm run dev &
sleep 15
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_e2e
REDIS_URL: redis://localhost:6379
JWT_SECRET: e2e-test-secret-key
NODE_ENV: test
PORT: 3000
- name: 后端健康检查
run: |
curl -f http://localhost:3000/health || exit 1
- name: 安装 Playwright
run: |
cd e2e
npx playwright install --with-deps chromium
- name: 运行 E2E 测试
run: |
cd e2e
pnpm run test || true
env:
E2E_BASE_URL: http://localhost:5173
E2E_API_URL: http://localhost:3000
E2E_TEST_USER: admin
E2E_TEST_PASSWORD: admin123
- if: always()
name: 上传测试报告
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: e2e/playwright-report
retention-days: "7"
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: juhi_e2e
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
...
|
e2e-test
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
292
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
触发专用测试套件
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
trigger-test-suite:
name: 触发专用测试套件
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- name: "\U0001F4DD 触发测试套件信息"
run: "echo \"## \U0001F9EA 专用测试工作流\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"以下专用测试工作流已自动触发:\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"- **Test Suite** (test.yml): 单元测试、API 测试、状态机测试\" >> $GITHUB_STEP_SUMMARY\necho \"- **E2E Tests** (e2e.yml): 端到端测试、业务流程测试\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"查看 Actions 页面了解详细测试结果。\" >> $GITHUB_STEP_SUMMARY\n"
...
|
trigger-test-suite
|
["backend-build","frontend-build"]
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862906
|
1771862813
|
1771862906
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
293
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
代码质量门控
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
quality-gate:
name: 代码质量门控
runs-on: ubuntu-latest
if: always()
steps:
- name: 检查所有任务状态
run: "echo \"## \U0001F4CA CI 验证结果\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"| 检查项 | 状态 |\" >> $GITHUB_STEP_SUMMARY\necho \"|--------|------|\" >> $GITHUB_STEP_SUMMARY\n\n# 后端测试\nif [ \"${{ needs.backend-test.result }}\" == \"success\" ]; then\n echo \"| ✅ 后端测试 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.backend-test.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 后端测试 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 后端测试 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 后端构建\nif [ \"${{ needs.backend-build.result }}\" == \"success\" ]; then\n echo \"| ✅ 后端构建 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.backend-build.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 后端构建 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 后端构建 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 前端构建\nif [ \"${{ needs.frontend-build.result }}\" == \"success\" ]; then\n echo \"| ✅ 前端构建 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.frontend-build.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 前端构建 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ❌ 前端构建 | 失败 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# 安全审计\nif [ \"${{ needs.security-audit.result }}\" == \"success\" ]; then\n echo \"| ✅ 安全审计 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.security-audit.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ 安全审计 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ⚠️ 安全审计 | 警告 |\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# Kafka 审计\nif [ \"${{ needs.kafka-audit.result }}\" == \"success\" ]; then\n echo \"| ✅ Kafka 审计 | 通过 |\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.kafka-audit.result }}\" == \"skipped\" ]; then\n echo \"| ⏭️ Kafka 审计 | 跳过 |\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"| ⚠️ Kafka 审计 | 警告 |\" >> $GITHUB_STEP_SUMMARY\nfi\n"
- name: 验证门控
run: |
BACKEND_TEST="${{ needs.backend-test.result }}"
BACKEND_BUILD="${{ needs.backend-build.result }}"
FRONTEND_BUILD="${{ needs.frontend-build.result }}"
# 跳过的任务视为通过
if [ "$BACKEND_BUILD" == "failure" ] || [ "$FRONTEND_BUILD" == "failure" ]; then
echo "❌ 构建失败,代码质量门控未通过"
exit 1
fi
if [ "$BACKEND_TEST" == "failure" ]; then
echo "❌ 测试失败,代码质量门控未通过"
exit 1
fi
echo "✅ 代码质量门控通过"
...
|
quality-gate
|
["backend-test","backend-build", ["backend-test","backend-build","frontend-build","security-audit","kafka-audit"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862907
|
1771862813
|
1771862907
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
294
|
58
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
CI 完成通知
|
0
|
name: CI
"on":
push:
branches: name: CI
"on":
push:
branches: [main, develop, 'feature/**', 'claude/**']
pull_request:
branches: [main, develop]
env:
NODE_VERSION: "20"
PNPM_VERSION: "8"
jobs:
ci-complete:
name: CI 完成通知
runs-on: ubuntu-latest
if: always()
steps:
- name: "\U0001F4E2 生成 CI 完成报告"
run: "echo \"## \U0001F389 CI 流程完成\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"**分支**: ${{ github.ref_name }}\" >> $GITHUB_STEP_SUMMARY\necho \"**提交**: ${{ github.sha }}\" >> $GITHUB_STEP_SUMMARY\necho \"**触发者**: ${{ github.actor }}\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\n\necho \"### \U0001F4CB 任务汇总\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\n\n# 质量门控\nif [ \"${{ needs.quality-gate.result }}\" == \"success\" ]; then\n echo \"- ✅ 代码质量门控: 通过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ 代码质量门控: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# E2E 测试\nif [ \"${{ needs.e2e-test.result }}\" == \"success\" ]; then\n echo \"- ✅ E2E 测试: 通过\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.e2e-test.result }}\" == \"skipped\" ]; then\n echo \"- ⏭️ E2E 测试: 跳过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ E2E 测试: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\n# Docker 构建\nif [ \"${{ needs.docker-build.result }}\" == \"success\" ]; then\n echo \"- ✅ Docker 镜像构建: 通过\" >> $GITHUB_STEP_SUMMARY\nelif [ \"${{ needs.docker-build.result }}\" == \"skipped\" ]; then\n echo \"- ⏭️ Docker 镜像构建: 跳过\" >> $GITHUB_STEP_SUMMARY\nelse\n echo \"- ❌ Docker 镜像构建: 失败\" >> $GITHUB_STEP_SUMMARY\nfi\n\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"---\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"### \U0001F517 相关链接\" >> $GITHUB_STEP_SUMMARY\necho \"\" >> $GITHUB_STEP_SUMMARY\necho \"- [查看完整测试报告](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\" >> $GITHUB_STEP_SUMMARY\necho \"- [查看覆盖率报告](https://codecov.io/gh/${{ github.repository }})\" >> $GITHUB_STEP_SUMMARY\n"
...
|
ci-complete
|
["quality-gate","e2e-test","do ["quality-gate","e2e-test","docker-build"]...
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862907
|
1771862813
|
1771862907
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
295
|
59
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
单元测试 & 覆盖率
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
unit-tests:
name: 单元测试 & 覆盖率
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 运行单元测试
run: cd backend && pnpm test:unit:coverage
- name: 生成覆盖率报告
run: cd backend && pnpm test:coverage:json
- name: 上传覆盖率到 Codecov
uses: codecov/codecov-action@v3
with:
files: ./backend/coverage/lcov.info
flags: unittests
name: unit-coverage
- name: 检查覆盖率阈值
run: |
cd backend
COVERAGE=$(jq '.total.lines.pct' coverage/coverage.json)
echo "当前覆盖率: $COVERAGE%"
if (( $(echo "$COVERAGE < 85" | bc -l) )); then
echo "❌ 覆盖率低于 85%"
exit 1
fi
echo "✅ 覆盖率达标"
- if: always()
name: 上传测试结果
uses: actions/upload-artifact@v3
with:
name: unit-test-results
path: backend/test-results/
- if: always()
name: 上传覆盖率报告
uses: actions/upload-artifact@v3
with:
name: unit-coverage-report
path: backend/coverage/
timeout-minutes: "15"
...
|
unit-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862907
|
1771862814
|
1771862907
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|
|
296
|
59
|
6
|
5
|
18a5bb9c67c571fc2cad6ffe61e70633bcec36a8
|
0
|
集成测试(API + DB + Events)
|
0
|
name: 深度完整全面自动化测试
"on":
push:
name: 深度完整全面自动化测试
"on":
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# 每天凌晨 2 点运行完整测试
- cron: '0 2 * * *'
env:
NODE_VERSION: "18"
PNPM_VERSION: "8"
jobs:
integration-tests:
name: 集成测试(API + DB + Events)
runs-on: ubuntu-latest
steps:
- name: Checkout 代码
uses: actions/checkout@v3
- name: 安装 pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: 设置 Node.js
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ env.NODE_VERSION }}
- name: 安装依赖
run: pnpm install --frozen-lockfile
- name: 设置测试环境变量
run: |
cd backend
cat > .env.test <<EOF
NODE_ENV=test
DATABASE_URL=postgresql://test:test@localhost:5432/juhi_test
REDIS_URL=redis://localhost:6379/1
KAFKA_BROKERS=localhost:9092
JWT_SECRET=test-secret-key
EOF
- name: 执行数据库迁移
run: |
cd backend
DATABASE_URL=$DATABASE_URL_TEST npx prisma migrate deploy
- name: 运行集成测试
run: cd backend && pnpm test:integration:coverage
env:
DATABASE_URL: postgresql://test:test@localhost:5432/juhi_test
REDIS_URL: redis://localhost:6379/1
KAFKA_BROKERS: localhost:9092
- if: always()
name: 上传集成测试结果
uses: actions/upload-artifact@v3
with:
name: integration-test-results
path: backend/test-results/
- name: 上传覆盖率报告
uses: codecov/codecov-action@v3
with:
files: ./backend/coverage/lcov.info
flags: integration
name: integration-coverage
timeout-minutes: "30"
services:
kafka:
image: confluentinc/cp-kafka:7.5.0
env:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_BROKER_ID: "1"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ports:
- 9092:9092
postgres:
image: postgres:15
env:
POSTGRES_DB: juhi_test
POSTGRES_PASSWORD: test
POSTGRES_USER: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
env:
ZOOKEEPER_CLIENT_PORT: "2181"
ports:
- 2181:2181
...
|
integration-tests
|
null
|
["ubuntu-latest"]
|
0
|
3
|
0
|
1771862907
|
1771862814
|
1771862907
|
NULL
|
NULL
|
|
0
|
Edit
Delete
|