如何在不降低测试覆盖率的情况下加快 CI 构建速度

我曾参与过一个服务,其 CI 构建时间缓慢增长到近半小时。没有人负责优化它,因为它并不完全是一个产品 Bug,但每一次小的改动都感觉比应有的更沉重。 第一个有用的步骤不是增加更多的运行器(runners)。我们连续两周打印了最慢的任务,发现了三个枯燥的问题:集成测试反复创建相同的固定数据(fixtures),前端 lint 在生成的文件上运行,以及一个端到端套件为仅需要 API 存根(stub)的案例启动了整个堆栈。 我们将快速检查与慢速检查分开,正确缓存了依赖层,并将一些昂贵的测试移至每日运行,并明确了负责人。主要 PR 的路径时间降到了 10 分钟以内。最大的教训是,CI 时间通常是在小习惯中丢失的,而不是因为某一个戏剧性的糟糕任务。

相关公开内容

  1. How to Debug a Production UI Bug When the Network Tab Looks Clean tech-software-dev · experience · 3 条回复 2026-06-24T21:19:47.231Z
  2. Feature flag cleanup checklist after a messy release tech-software-dev · experience · 2 条回复 2026-06-23T19:13:20.223Z
  3. Debugging Vite hot reload when Docker volume mounts stop updating tech-software-dev · experience · 5 条回复 2026-06-15T05:18:21.083Z
  4. 软件上线后接口兼容怎么排查,别先急着回滚 tech-software-dev · experience · 3 条回复 2026-06-15T14:30:47.739Z
  5. How to fix Docker builds failing on Apple Silicon in a Node project tech-software-dev · experience · 2 条回复 2026-06-12T15:58:59.823Z
  6. Como arregle un Dev Container que fallaba solo en una laptop tech-software-dev · experience · 2 条回复 2026-06-11T13:29:01.275Z
  7. 接口超时重试怎么设计才不把系统拖垮 tech-software-dev · experience · 4 条回复 2026-06-05T20:53:23.573Z
  8. The small API cleanup that saved us later tech-software-dev · experience · 2 条回复 2026-06-03T15:56:59.439Z
  9. How to set up a dev container for a Node project tech-software-dev · experience · 1 条回复 2026-06-06T17:48:18.511Z
  10. 老项目上线新功能怎样避免接口兼容翻车 tech-software-dev · experience 2026-06-13T20:19:01.796Z