chore: AI 서버 구조 및 CI/CD 설정 정비#2
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 Walkthrough개요FastAPI 애플리케이션을 라우터 중심 구조로 재구성하고, Pydantic 스키마 기반 뉴스레터 추출 서비스를 구현했으며, GitHub Actions를 통한 CI/CD 파이프라인과 EC2 자동 배포 워크플로우를 설정하고, 프로젝트 문서 및 설정을 정비했습니다. 변경 사항AI 서버 구조 및 CI/CD 정비
Sequence DiagramssequenceDiagram
participant Client
participant NewsletterRouter
participant NewsletterExtractor
participant NewsletterPrompt
participant Response
Client->>NewsletterRouter: POST /ai/newsletters/extract-items
NewsletterRouter->>NewsletterExtractor: extract_newsletter_items(request)
NewsletterExtractor->>NewsletterExtractor: 날짜 후보 기반 항목 추출
NewsletterExtractor->>NewsletterExtractor: 누락 체크리스트 항목 검출
NewsletterExtractor->>Response: NewsletterExtractionResponse (항목 + 메타데이터)
Response-->>Client: 규칙 기반 baseline 결과 반환
Client->>NewsletterRouter: POST /ai/newsletters/prompt-preview
NewsletterRouter->>NewsletterPrompt: build_prompt_messages(request)
NewsletterPrompt->>NewsletterPrompt: 시스템 프롬프트 생성
NewsletterPrompt->>NewsletterPrompt: 사용자 프롬프트 + 날짜 후보 포맷
Response-->>Client: PromptPreviewResponse (메시지 + 응답 스키마)
sequenceDiagram
participant GitHub as GitHub<br/>Actions
participant Push as Push Event<br/>(develop/main)
participant PullRequest as Pull Request<br/>Event
participant QualityJob as Quality Job
participant DockerJob as Docker Job
participant DeployJob as Deploy Job<br/>(main only)
Push->>QualityJob: 트리거 (develop/main)
QualityJob->>QualityJob: ruff check, format, compileall, pytest
QualityJob-->>GitHub: 품질 검사 결과
PullRequest->>DockerJob: PR 생성 시 트리거
DockerJob->>DockerJob: Docker 이미지 빌드 (푸시 안함)
DockerJob-->>GitHub: 빌드 검증 완료
Push->>DockerJob: main push 시 트리거
DockerJob->>DockerJob: Docker 이미지 빌드 & 푸시
DockerJob-->>GitHub: latest/develop 태그 푸시 완료
GitHub->>DeployJob: upstream docker-ai 성공<br/>또는 workflow_dispatch
DeployJob->>DeployJob: AWS 인증 (OIDC/Access Key)
DeployJob->>DeployJob: EC2 SSM 커맨드 전송
DeployJob->>DeployJob: .env AI_IMAGE 갱신
DeployJob->>DeployJob: docker compose pull/up
DeployJob->>DeployJob: 헬스 체크 & nginx 재시작
DeployJob-->>GitHub: 배포 완료
예상 코드 리뷰 비용🎯 3 (Moderate) | ⏱️ ~25 분 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/PULL_REQUEST_TEMPLATE/release.md:
- Line 21: Update the workflow identifier text on line 21 to match the actual
deployment workflow for this PR: replace the current `deploy-ec2` reference with
the real workflow id/name used in the repo (`deploy-ai-ec2` or the workflow
display name `Deploy AI to EC2`) so the template accurately points to the
correct GitHub Actions workflow when verifying `workflow_dispatch` on `main`;
adjust the string in .github/PULL_REQUEST_TEMPLATE/release.md to exactly match
the workflow file name `deploy-ai-ec2.yml` or its canonical identifier.
- Line 1: 현재 템플릿의 최상위 제목이 '## 📌 작업 요약'으로 되어 있어 markdownlint MD041 경고를 발생시키므로 상단
헤더 토큰을 '##'에서 H1인 '#'로 변경하세요; 즉 파일의 최상위 제목 문자열 '## 📌 작업 요약'을 '# 📌 작업 요약'으로 바꾸고
변경 후 markdownlint/CI에서 MD041 경고가 사라지는지 확인하세요.
In @.github/workflows/docker-ai.yml:
- Around line 49-53: 현재 GITHUB_REF_NAME 검사 로직은 main이 아닌 모든 ref에 대해 :develop 태그를
붙여 workflow_dispatch로 feature 브랜치에서 실행하면 develop 이미지가 덮어써질 수 있으므로,
GITHUB_REF_NAME을 기준으로 분기해 main일 때는
tags="${IMAGE}:latest,${IMAGE}:sha-${SHORT_SHA}", develop일 때는
tags="${IMAGE}:develop,${IMAGE}:sha-${SHORT_SHA}"로 별도 처리하고, 그 외 브랜치(예:
feature/*)는
tags="${IMAGE}:branch-${GITHUB_REF_NAME},${IMAGE}:sha-${SHORT_SHA}"처럼 브랜치명 기반
태그만 생성하도록 수정하세요; 또한 푸시 단계(docker push 사용하는 곳)는 main 또는 develop에 대해서만
:latest/:develop 를 푸시하도록 제한하거나 푸시할 태그 목록을 위에서 생성한 tags 변수에 따라 결정하도록 변경하여 feature
브랜치가 develop 태그를 덮어쓰지 않게 하세요.
In `@app/schemas.py`:
- Around line 21-27: The DateCandidate model lacks offset validation causing bad
evidence slicing; add Pydantic validation (e.g., `@root_validator` or field
validators) in DateCandidate to enforce that start_offset and end_offset are
non-negative, that end_offset >= start_offset, and that end_offset does not
exceed len(original_text) (and start_offset <= len(original_text)) and raise a
ValueError with a clear message when invalid; reference the DateCandidate class
and the start_offset, end_offset and original_text fields when implementing the
checks.
- Around line 29-31: Replace the Pydantic v1-style class Config block (the class
named Config that sets allow_population_by_field_name and populate_by_name) with
the v2 configuration pattern by adding a module or model attribute named
model_config that uses ConfigDict(populate_by_name=True); remove
allow_population_by_field_name and populate_by_name from the class Config and
ensure any models using class Config now define model_config = ConfigDict(...)
so the models use Pydantic v2 config API.
In `@README.md`:
- Line 36: Update the branch example to match the repository's branch naming
convention by replacing the inconsistent example
`chore-issue-1-ai-server-ci-cd-setup` with the slash-separated pattern
`chore/issue-1-ai-server-ci-cd-setup` so it aligns with the existing `feat/...`
example and the checklist conventions in README (update the example text where
`feat/issue-1-feature-name` and the chore example appear).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d0c44c86-f18d-4b21-8979-fb8b7a34c720
📒 Files selected for processing (18)
.coderabbit.yaml.github/PULL_REQUEST_TEMPLATE/release.md.github/pull_request_template.md.github/workflows/deploy-ai-ec2.yml.github/workflows/docker-ai.yml.github/workflows/quality-ai.ymlREADME.mdapp/main.pyapp/routers/health.pyapp/routers/newsletters.pyapp/schemas.pyapp/services/newsletter_extractor.pyapp/services/newsletter_prompt.pydocs/deploy.mddocs/env.mddocs/newsletter-extraction.mddocs/newsletter-labeling-guide.mdrequirements.txt
| @@ -0,0 +1,31 @@ | |||
| ## 📌 작업 요약 | |||
There was a problem hiding this comment.
최상위 제목 레벨을 H1으로 맞춰 주세요.
Line 1은 ##로 시작해서 markdownlint MD041 경고를 유발합니다. #로 올리는 게 맞습니다.
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 1-1: First line in a file should be a top-level heading
(MD041, first-line-heading, first-line-h1)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/PULL_REQUEST_TEMPLATE/release.md at line 1, 현재 템플릿의 최상위 제목이 '## 📌
작업 요약'으로 되어 있어 markdownlint MD041 경고를 발생시키므로 상단 헤더 토큰을 '##'에서 H1인 '#'로 변경하세요; 즉
파일의 최상위 제목 문자열 '## 📌 작업 요약'을 '# 📌 작업 요약'으로 바꾸고 변경 후 markdownlint/CI에서 MD041
경고가 사라지는지 확인하세요.
Hminkyung
left a comment
There was a problem hiding this comment.
확인 완료했습니당!!! 고생하셨습니다ㅏㅏㅏㅏ
📌 작업 요약
🌿 브랜치 정보
chore/#1-ci-cd-setupdevelop(기본)✅ 체크리스트
feat/refac/hotfix/chore/design/bugfix)feat/fix/refactor/docs/style/chore)🧪 테스트 결과
ruff check .ruff format --check .python -m compileall apppytestgit diff --checkSummary by CodeRabbit
릴리스 노트
새로운 기능
문서
Chores