Skip to content

Continuous Integration (CI)

一句话解释

CI automatically 构建 and 测试 code on 每个推送, preventing broken code 从合并到 主要分支.

用大白话说

Continuous Integration (CI) 是练习的 automatically 构建 and 测试 code 每个时间某人 pushes 更改. 相反的 integrating 更改 manually at 端 (哪个 leads 到合并 hell), CI integrates continuously — 每个推送触发 automated 流水线.

A typical CI 流水线:

  1. Trigger: 某人 pushes code or 打开拉取请求.
  2. Checkout: CI 系统获取 code.
  3. Install: 安装 dependencies.
  4. Build: 编译/构建 code.
  5. Test: 运行测试 suite.
  6. Report: Report 成功 or 失败.

If 任何步骤失败, 流水线停止 and team 是 notified. code cannot 是合并直到流水线通过. 这个 catches bugs, broken 构建, and failing 测试 immediately — 不 days or weeks later.

Popular CI tools: GitHub 操作, GitLab CI, Jenkins, CircleCI.

示例

yaml
# .github/workflows/ci.yml — GitHub Actions CI
name: CI
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test
      - run: npm run build

# Every push triggers: checkout → install → test → build
# If any step fails, the PR is blocked from merging.

CI 流水线(这里是 GitHub Actions)在每次推送时自动运行:检出代码、安装依赖、运行测试、构建。任何步骤失败都会阻止拉取请求合并。

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表