--- id: wiki-2026-0508-continuous-integration-ci title: Continuous Integration (CI) category: 10_Wiki/Topics status: verified canonical_id: self aliases: [CI, Continuous Integration, 지속적 통합] duplicate_of: none source_trust_level: A confidence_score: 0.92 verification_status: applied tags: [ci, devops, automation, github-actions] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: yaml framework: github-actions --- # Continuous Integration (CI) ## 매 한 줄 > **"매 push마다 build + test, fast feedback"**. Grady Booch (1991) 가 제안, Martin Fowler 가 대중화. 2026 현재 GitHub Actions / GitLab CI 가 표준이며, AI-assisted PR review (Claude Opus 4.7) 와 결합되어 매 commit 검증 cycle 이 분 단위로 압축됨. ## 매 핵심 ### 매 원칙 - **Mainline integration 빈번**: 매 developer 매일 main 에 merge. - **Automated build**: 매 commit trigger build pipeline. - **Automated test**: unit + integration + lint 매 자동 실행. - **Fast feedback**: <10 min 안에 결과. 길어지면 dev 매 ignore. - **Single source of truth**: 매 single repo, single mainline. ### 매 stages - **Lint** (10s) — eslint, ruff, gofmt. - **Unit test** (1-3 min) — vitest, pytest, go test. - **Integration test** (3-8 min) — testcontainers, ephemeral DB. - **Build artifact** (1-2 min) — docker image, npm tarball. - **Static analysis** (parallel) — SonarQube, Snyk, CodeQL. ### 매 응용 1. SaaS product 매 trunk-based development. 2. Open-source project 매 PR validation. 3. Monorepo 매 affected-only build (Turborepo, Nx). ## 💻 패턴 ### Modern GitHub Actions (2026) ```yaml name: CI on: push: { branches: [main] } pull_request: merge_group: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 with: { node-version: '22', cache: 'pnpm' } - run: pnpm install --frozen-lockfile - run: pnpm lint - run: pnpm test --coverage - uses: codecov/codecov-action@v5 ``` ### Matrix build ```yaml strategy: fail-fast: false matrix: os: [ubuntu-24.04, macos-14, windows-2022] node: [20, 22] runs-on: ${{ matrix.os }} ``` ### Affected-only (monorepo) ```yaml - run: pnpm exec turbo run test --filter=...[origin/main] ``` ### Reusable workflow ```yaml # .github/workflows/reusable-test.yml on: workflow_call: inputs: node-version: { type: string, default: '22' } jobs: test: runs-on: ubuntu-24.04 steps: [ ... ] ``` ### Container-based test (testcontainers) ```python # pytest with ephemeral postgres from testcontainers.postgres import PostgresContainer def test_repo(): with PostgresContainer("postgres:17") as pg: url = pg.get_connection_url() # run integration test against real DB ``` ### Cache layers (docker buildx) ```yaml - uses: docker/build-push-action@v6 with: context: . cache-from: type=gha cache-to: type=gha,mode=max tags: ghcr.io/org/app:${{ github.sha }} ``` ### AI PR review (2026) ```yaml - uses: anthropic-experimental/claude-code-action@v1 with: api-key: ${{ secrets.ANTHROPIC_API_KEY }} model: claude-opus-4-7 review-mode: pr-comment ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Open-source GitHub repo | GitHub Actions | | Self-hosted, private | GitLab CI / Drone | | Monorepo | Turborepo + affected-only | | Polyglot, complex | Buildkite / Bazel | | Mobile (iOS/Android) | Bitrise / Xcode Cloud | **기본값**: GitHub Actions + concurrency cancel + matrix + cache. ## 🔗 Graph - 부모: [[DevOps]] - 변형: [[Continuous Deployment]] · [[Trunk-Based Development]] - 응용: [[GitHub Actions]] - Adjacent: [[Test Automation]] · [[Static Analysis]] · [[153_pre-commit과_품질_게이트|Pre-commit Hooks]] ## 🤖 LLM 활용 **언제**: PR diff review, flaky test detection, commit message generation, changelog 생성. **언제 X**: secret-handling pipeline (보안), production deploy gate (deterministic 해야 함). ## ❌ 안티패턴 - **Slow pipeline (>20 min)**: dev 매 ignore, "broken main" 정상화. - **Flaky test 방치**: trust collapse → 매 retry, retry, retry. - **No mainline protection**: 직접 push to main, PR 없음. - **Build on developer machine only**: "works on my machine" 재현. - **Secrets in logs**: env 출력, token leak. ## 🧪 검증 / 중복 - Verified (Fowler 2006 *Continuous Integration* article, GitHub Actions docs 2026). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — full content with modern GitHub Actions patterns |