SuperAPI AI Directory

ci-test-integration

Deployment & operations

View repository

Updated 10-16 09:30

About this skill

CI Test Integration

Applicable Scenarios

  • Integrating tests into a CI pipeline
  • Test parallelization for speedup
  • Cache optimization (dependencies / build)
  • Blocking merges on failure
  • Test report automation
  • Flaky test isolation

Core Principles

1. 每次 PR 必跑测试
2. 失败必须阻塞合并
3. 测试要快(< 15 分钟)
4. 并行化(多 worker)
5. 缓存依赖(不每次装)
6. 报告可视化(PR 评论)

GitHub Actions Template

name: Test
on: [push, pull_request]

jobs:
  unit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20, cache: 'pnpm' }
      - run: pnpm install --frozen-lockfile
      - run: pnpm test:unit
      - run: pnpm test:coverage
      - uses: codecov/codecov-action@v4

  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: pnpm install
      - run: npx playwright install --with-deps
      - run: pnpm build
      - run: pnpm test:e2e
      - uses: actions/upload-artifact@v4
        if: failure()
        with:
          name: playwright-report
          path: playwright-report/

Parallelization Strategy

方案 A:按类型分 job
  unit → 1 job(快)
  integration → 1 job
  e2e → 1 job(慢)

方案 B:分片(Sharding)
  e2e 拆 4 个 shard 并行
  matrix: { shard: [1, 2, 3, 4] }

方案 C:按变更范围
  只跑受影响模块的测试

Supporting Templates

  • templates/ci-config-template.md — CI test configuration template

Quality Self-Check

□ PR 必跑测试
□ 失败阻塞合并
□ 总时长 < 15 分钟
□ 缓存依赖
□ 并行化
□ 报告可视化
□ Flaky 隔离
□ 覆盖率上报

Common Pitfalls

  1. CI too slow——developers skip it
  2. Not blocking merges——exists in name only
  3. No caching——installing dependencies takes 5 minutes every time
  4. Flaky tests not handled——interferes with real issues
  5. No parallelization——serial runs take 30 minutes

Collaboration with Other Skills

上游:
  unit/integration/e2e/contract → 测试代码

下游:
  devops-engineer ci-cd-pipeline → 流水线配置
  coverage-reporting → 覆盖率