AI CI 설계 문서 - 100-hours-a-week/20-real-wiki GitHub Wiki
개요
- 레포지토리: 100-hours-a-week/20-real-ai
- CI 도구: GitHub Actions
- 트리거: Pull Request (main, develop 브랜치)
- 파이프라인 구성: Lint → Unit Test → Integration Test → Coverage Report 저장 → Discord 알림
CI 설정 파일 (.github/workflows/ci.yml
)
name: AI Server CI Pipeline
on:
pull_request:
branches: [main, develop]
jobs:
ai:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.10
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 pytest requests
- name: Lint (flake8)
run: flake8 app
- name: Unit Test (pytest)
id: unit_test
run: pytest tests/unit --cov=app --cov-report=html
- name: Integration Test (FastAPI requests)
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: pytest tests/integration
- name: Upload Coverage Report
if: steps.unit_test.outcome == 'success'
uses: actions/upload-artifact@v3
with:
name: ai-coverage
path: htmlcov/
- name: Discord Notify
if: always()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
STATUS=${{ job.status }}
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
MESSAGE="🔔 CI 결과: **${STATUS}**\n📦 Repo: \`${{ github.repository }}\`\n🔁 Branch: \`${{ github.ref_name }}\`"
if [ "$STATUS" != "success" ]; then
MESSAGE="${MESSAGE}\n❌ [실패 로그 보러 가기](${RUN_URL})"
fi
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"${MESSAGE}\"}" \
$DISCORD_WEBHOOK
파이프라인 단계 요약
단계 |
역할 |
성공/실패 기준 |
산출물 위치 |
Lint |
flake8로 Python 코드 스타일 검사 |
스타일 위반 시 실패 |
- |
Unit Test |
pytest로 단위 테스트 수행 |
테스트 실패 시 실패 |
htmlcov/ (커버리지 리포트 포함) |
Integration Test |
FastAPI 서버에 대한 통합 시나리오 테스트 |
실패 시 실패 |
- |
Coverage 저장 |
HTML 커버리지 리포트 저장 |
단위 테스트 성공시 저장 |
GitHub Artifacts: ai-coverage |
Discord 알림 |
CI 결과를 Discord로 전송 |
항상 실행 |
- |
Secrets 설정
이름 |
용도 |
DISCORD_WEBHOOK |
Discord 알림 전송용 Webhook URL |
실행 결과 확인 방법
- GitHub의 Actions 탭에서 워크플로우 실행 이력을 확인할 수 있음
- 실패한 경우에는 ❌ 아이콘이 표시되며, 해당 Step에서 로그 확인 가능
산출물 (Artifacts) 다운로드 방법
main
브랜치에서 CI 성공 시, htmlcov/
디렉토리의 커버리지 리포트가 GitHub Artifacts로 업로드됨
- GitHub Actions 실행 내역 하단의 Artifacts 섹션에서
ai-coverage
다운로드가능
테스트 커버리지 (pytest + coverage)
- 명령어:
pytest
실행 시 --cov=app --cov-report=html
옵션을 통해 htmlcov/
경로에 HTML 리포트 생성
- 결과 위치: Artifacts 섹션의 ai-coverage