[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,92 +2,203 @@
|
||||
id: wiki-2026-0508-quality-gates
|
||||
title: Quality Gates
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-B577EF]
|
||||
aliases: [CI Gates, Merge Gates, Pipeline Gates]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
verification_status: applied
|
||||
tags: [ci-cd, devops, code-quality, security]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - Quality [[Gates|Gates]]"
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: YAML/Shell
|
||||
framework: GitHub-Actions/SonarQube
|
||||
---
|
||||
|
||||
# [[Quality Gates|Quality Gates]]
|
||||
# Quality Gates
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> Quality Gates(품질 게이트)는 소프트웨어 개발 수명 주기(SDLC)에서 코드 병합이나 배포 전에 사전에 정의된 품질 및 보안 표준을 충족하는지 평가하는 정책 기반의 검사 메커니즘입니다 [1, 2]. 주로 풀 리퀘스트(Pull Request) 단계에서 실행되어 복잡도, 취약점, 중복 등의 지표를 평가한 후 통과(Pass) 또는 실패(Fail) 상태를 이진(binary) 신호로 명확히 할당합니다 [2-4]. 이를 통해 팀은 비공식적인 리뷰 코멘트에 의존하지 않고 객관적인 규칙 세트에 따라 코드 품질을 일관되게 유지하며, 규모에 맞는 안전한 코드 배포를 보장할 수 있습니다 [2, 5].
|
||||
## 매 한 줄
|
||||
> **"매 fail-fast checkpoint between commit and production"**. 1990s ISO 9000 의 stage-gate 의 software 의 응용. 매 modern CI/CD 에서 매 PR merge / deploy 의 block 하는 자동 check 의 set. 매 SonarQube 가 popularized — coverage + bugs + smells + security 의 threshold-based gate.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **동작 원리 및 적용 시점:** Quality Gates는 IDE부터 CI/CD 파이프라인 전반에 걸쳐 워크플로우에 통합되어 작동하는 정책 기반의 통제 장치(policy-driven gates)입니다 [1, 6]. 주로 풀 리퀘스트(PR)나 브랜치 병합 전에 코드를 분석하여 사전에 설정된 명시적인 규칙 세트를 만족하는지 확인합니다 [2]. 기준을 충족하지 못하는 "새로운 문제(new issues)"가 발견될 경우 실패(Fail) 신호를 보내어 코드 병합을 직접적으로 차단(merge [[Blocking|Blocking]])합니다 [2].
|
||||
* **개발 워크플로우 및 품질 관리에 미치는 영향:** Quality Gates는 대시보드 형태의 집계뿐만 아니라 PR 수준에서 직접적으로 품질 상태, 코드 중복, 복잡성 및 테스트 커버리지 등의 가시적인 신호를 제공합니다 [3]. 비공식적인 리뷰 코멘트 대신 이진(binary) 형태의 명확한 통과/실패 신호를 부여하기 때문에 실시간으로 개발자의 코드 병합 행동에 즉각적인 영향을 미치며, 시간에 따른 품질 저하(quality drift) 현상을 추적하고 측정할 수 있도록 돕습니다 [2-4].
|
||||
* **컴플라이언스 준수 및 표준화:** 조직 내 여러 리포지토리 전반에 걸쳐 일관된 표준을 강제하여 소프트웨어의 유지보수성과 신뢰성을 향상시킵니다 [1, 7, 8]. 또한 OWASP, ISO/IEC 등과 같은 업계 컴플라이언스와 보안 표준을 충족하는 데 핵심적인 역할을 수행합니다 [8].
|
||||
* **AI 생성 코드 및 도구 연동:** Quality Gates는 사람이 작성한 코드뿐만 아니라 AI가 생성한 코드에 대해서도 동일한 품질 표준을 강제합니다 [9]. 최근의 AI 네이티브 개발 환경에서는 AI 코딩 어시스턴트(예: Cursor, Windsurf)가 직접 Quality Gate 상태를 쿼리(query)하고 피드백을 받을 수 있도록 연동이 지원됩니다 [10]. 나아가 AI가 코드를 자동 수정(Auto-fix)할 때 발생할 수 있는 환각(hallucination) 위험을 검증하고 줄이는 품질 게이트 역할로도 활용됩니다 [11]. 이러한 워크플로우를 강력하게 지원하는 도구로는 [[SonarQube|SonarQube]], Codacy 등이 있습니다 [2, 3, 12].
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** AI 분야의 자동 자산화 수행.
|
||||
### 매 layer (commit → prod)
|
||||
- **Pre-commit (local)**: format, lint, secrets scan.
|
||||
- **PR gate**: build, unit test, coverage, security scan, type check.
|
||||
- **Merge gate**: full integration test, mutation test (선택).
|
||||
- **Pre-deploy**: smoke test, perf budget, manual approval.
|
||||
- **Post-deploy**: canary metrics, error rate, SLO.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** Static Application Security Testing (SAST), CI/CD pipelines, [[Pull Request (PR)|Pull Request (PR)]]
|
||||
- **Projects/Contexts:** SonarQube Cloud, Codacy, AI Code Assurance
|
||||
- **Contradictions/Notes:** 소스는 팀 내 비공식적인 코드 리뷰 코멘트에 의존하여 병합을 결정하는 것보다, Quality Gates와 같은 명시적인 규칙 세트 기반의 이진 신호(통과/실패)를 통해 병합을 차단하는 방식이 시간이 지남에 따른 품질 변화를 더 명확하게 측정하고 통제할 수 있다고 강조합니다 [2].
|
||||
### 매 dimensions
|
||||
- **Correctness**: tests pass, type-check.
|
||||
- **Coverage**: line / branch / mutation %.
|
||||
- **Style**: lint, format.
|
||||
- **Security**: SAST, dep scan, secret scan, license.
|
||||
- **Performance**: benchmark regression, bundle size.
|
||||
- **Docs**: changelog, ADR for breaking change.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
### 매 응용
|
||||
1. Open-source PR review automation.
|
||||
2. Regulated industry (SOX, HIPAA) audit trail.
|
||||
3. Monorepo platform consistency.
|
||||
4. AI-generated code 의 sanity gate.
|
||||
5. Deploy promotion.
|
||||
|
||||
---
|
||||
## 💻 패턴
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### Pre-commit (local)
|
||||
```yaml
|
||||
# .pre-commit-config.yaml
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.8.0
|
||||
hooks: [{id: ruff}, {id: ruff-format}]
|
||||
- repo: https://github.com/gitleaks/gitleaks
|
||||
rev: v8.21.0
|
||||
hooks: [{id: gitleaks}]
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.13.0
|
||||
hooks: [{id: mypy}]
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### GitHub Actions PR gate
|
||||
```yaml
|
||||
name: PR Gate
|
||||
on: [pull_request]
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: astral-sh/setup-uv@v3
|
||||
- run: uv sync
|
||||
- run: uv run pytest --cov=src --cov-report=xml --cov-fail-under=80
|
||||
- run: uv run ruff check .
|
||||
- run: uv run mypy src
|
||||
- uses: codecov/codecov-action@v5
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: aquasecurity/trivy-action@master
|
||||
with: {scan-type: fs, severity: 'HIGH,CRITICAL', exit-code: 1}
|
||||
- uses: github/codeql-action/init@v3
|
||||
- uses: github/codeql-action/analyze@v3
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### SonarQube quality gate (Sonar Way)
|
||||
```
|
||||
- Coverage on new code ≥ 80%
|
||||
- Duplicated lines on new code ≤ 3%
|
||||
- Maintainability rating on new code = A
|
||||
- Reliability rating on new code = A
|
||||
- Security rating on new code = A
|
||||
- Security hotspots reviewed = 100%
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Branch protection (GitHub API)
|
||||
```bash
|
||||
gh api -X PUT "repos/{owner}/{repo}/branches/main/protection" \
|
||||
-F required_status_checks[strict]=true \
|
||||
-F required_status_checks[contexts][]=test \
|
||||
-F required_status_checks[contexts][]=security \
|
||||
-F required_pull_request_reviews[required_approving_review_count]=2 \
|
||||
-F enforce_admins=true
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Performance budget gate
|
||||
```yaml
|
||||
- name: Bundle size check
|
||||
run: |
|
||||
npm run build
|
||||
SIZE=$(stat -c%s dist/main.js)
|
||||
if [ $SIZE -gt 250000 ]; then
|
||||
echo "Bundle exceeds 250KB budget: $SIZE"
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
### Mutation testing gate (Stryker / mutmut)
|
||||
```yaml
|
||||
- run: uv run mutmut run
|
||||
- run: |
|
||||
SCORE=$(uv run mutmut results | grep -oP 'killed.*\K\d+')
|
||||
if [ $SCORE -lt 70 ]; then exit 1; fi
|
||||
```
|
||||
|
||||
### Canary deploy gate
|
||||
```yaml
|
||||
- name: Canary 5%
|
||||
run: kubectl set image deploy/app app=app:${{ github.sha }} --namespace=canary
|
||||
- name: Wait + check SLO
|
||||
run: |
|
||||
sleep 600
|
||||
ERROR_RATE=$(prom_query 'rate(http_5xx[10m])')
|
||||
if (( $(echo "$ERROR_RATE > 0.01" | bc -l) )); then
|
||||
kubectl rollout undo deploy/app --namespace=canary
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
### AI-generated code gate (2026)
|
||||
```yaml
|
||||
- name: AI code review
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
api-key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
review-mode: security-and-quality
|
||||
fail-on: high
|
||||
```
|
||||
|
||||
### Required-files / docs gate
|
||||
```bash
|
||||
# require ADR for breaking change
|
||||
if git log -1 --pretty=%B | grep -qi 'BREAKING'; then
|
||||
git diff --name-only HEAD~1 | grep -q '^docs/adr/' || {
|
||||
echo "Breaking change requires ADR"; exit 1; }
|
||||
fi
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Gate set |
|
||||
|---|---|
|
||||
| Solo prototype | Pre-commit only |
|
||||
| Team project | **+ PR test/lint/security** |
|
||||
| Production SaaS | + coverage + perf + canary |
|
||||
| Regulated (HIPAA/SOX) | + SAST + DAST + audit log |
|
||||
| Open source | + DCO + license + dep review |
|
||||
|
||||
**기본값**: pre-commit + PR test/lint/type/coverage 80% + Trivy + branch protection.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[CI-CD]] · [[DevOps]]
|
||||
- 변형: [[Stage-Gate]] · [[Definition-of-Done]]
|
||||
- 응용: [[Code-Review]] · [[Release-Engineering]]
|
||||
- Adjacent: [[SonarQube]] · [[GitHub-Actions]] · [[Trunk-Based-Development]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 gate config draft, 매 SonarQube 의 ruleset 의 explain, 매 CI YAML 의 generate.
|
||||
**언제 X**: 매 production gate threshold (coverage %, SLO %) — 매 team-context 결정.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Coverage as only gate**: 매 100% coverage + 매 0 assertion 가능. 매 mutation test 의 augment.
|
||||
- **Slow gates (>10min)**: 매 dev velocity kill. 매 parallelize / shard.
|
||||
- **Flaky gates**: 매 false positive 의 retry-bypass culture. 매 quarantine + fix.
|
||||
- **Legacy code 의 same threshold**: 매 new-code only 의 ratchet.
|
||||
- **Gates without humans**: 매 automation alone 의 architectural smell 의 miss.
|
||||
- **Bypass culture**: `--no-verify` / admin merge — 매 audit log + alert.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (SonarQube docs, GitHub branch protection API, ISO 9000 stage-gate origin).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — quality gates CI/CD layered framework. |
|
||||
|
||||
Reference in New Issue
Block a user