ci: PR 생성 시 codex/claude 자동 코드리뷰 워크플로우 추가 - #19
Conversation
pull_request opened 이벤트에서 claude-review, codex-review 잡을 병렬로 실행해 pulls/reviews API로 정식 GitHub 리뷰를 남긴다. undefined-lab의 슬래시 커맨드 리뷰 잡 패턴을 재사용하되 수동 트리거 대신 PR 생성 시 자동으로 동작하도록 구성했다. Closes #457
📝 Walkthrough고수준 검토 요약워크플로는 자동 리뷰 실행 경로를 추가하지만, 현재 구현은 외부 PR에서 self-hosted runner와 저장소 쓰기 권한을 함께 사용합니다. PR 브랜치의 변경 내용이 리뷰 실행 환경에 영향을 줄 수 있으므로 보안 위험이 큽니다. 또한 Claude와 Codex CLI의 로그인 상태, JSON 출력, API 게시 실패를 충분히 검증하지 않으면 리뷰가 조용히 누락될 수 있습니다. 인라인 리뷰
|
| Layer / File(s) | Summary |
|---|---|
리뷰 실행 스크립트 .github/scripts/claude-review-run.sh, .github/scripts/codex-review-run.sh |
Claude와 Codex가 프로젝트 지침, 변경 파일, 전체 diff를 확인하도록 프롬프트를 구성합니다. 리뷰 결과를 지정된 JSON 형식으로 작성하고 GitHub Pull Request 리뷰 API에 게시하도록 CLI를 실행합니다. |
워크플로 트리거와 Claude 인증 .github/workflows/pr-auto-review.yml |
비초안 Pull Request 이벤트를 처리하고 PR별 동시 실행 그룹과 실행 제한을 설정합니다. Claude CLI 인증이 없으면 Pull Request에 재로그인 안내를 게시합니다. |
리뷰 작업 실행과 출력 처리 .github/workflows/pr-auto-review.yml |
인증된 경우 Claude 리뷰를 실행하고 JSON 스트림을 텍스트, 도구 호출, 결과 형식으로 출력합니다. 별도 Codex 작업은 Pull Request 브랜치를 원격 기준으로 동기화한 뒤 Codex 리뷰 스크립트를 실행합니다. |
Estimated code review effort: 4 (Complex) | ~45분
Sequence Diagram(s)
sequenceDiagram
participant PullRequest
participant GitHubActions
participant ClaudeCLI
participant CodexCLI
participant GitHubReviewAPI
PullRequest->>GitHubActions: 열림 또는 리뷰 준비 이벤트
GitHubActions->>ClaudeCLI: Claude 리뷰 작업 실행
ClaudeCLI->>GitHubReviewAPI: JSON 리뷰 게시
GitHubActions->>CodexCLI: Codex 리뷰 작업 실행
CodexCLI->>GitHubReviewAPI: JSON 리뷰 게시
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | 제목이 PR의 주요 변경 사항인 Codex 및 Claude 자동 코드리뷰 워크플로 추가를 정확하고 간결하게 설명합니다. |
| Description check | ✅ Passed | 작업 내용, 관련 이슈, 사전 작업, 테스트 계획을 포함하며 PR 목적과 구현 범위를 구체적으로 설명합니다. |
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
feature/pr-auto-review
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 @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5c257814-b0cc-4fb2-8baa-056033c4a8b3
📒 Files selected for processing (3)
.github/scripts/claude-review-run.sh.github/scripts/codex-review-run.sh.github/workflows/pr-auto-review.yml
📜 Review details
🧰 Additional context used
🪛 actionlint (1.7.12)
.github/workflows/pr-auto-review.yml
[error] 29-29: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
[error] 90-90: "github.event.pull_request.head.ref" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable. see https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks for more details
(expression)
🪛 zizmor (1.29.0)
.github/workflows/pr-auto-review.yml
[error] 9-9: overly broad permissions (excessive-permissions): pull-requests: write is overly broad at the workflow level
(excessive-permissions)
[warning] 30-30: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 32-32: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 32-32: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 32-32: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 33-33: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[warning] 91-91: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 93-93: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 93-93: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 93-93: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[error] 94-94: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
[warning] 9-9: permissions without explanatory comments (undocumented-permissions): needs an explanatory comment
(undocumented-permissions)
[info] 12-12: workflow or action definition without a name (anonymous-definition): this job
(anonymous-definition)
[info] 73-73: workflow or action definition without a name (anonymous-definition): this job
(anonymous-definition)
- 러너 작업 디렉터리/HOME을 vars.RUNNER_WORKDIR, vars.RUNNER_HOME으로 분리해 public 저장소 워크플로우 파일에 로컬 사용자 경로가 노출되지 않게 한다. - 별도 봇 계정 PAT 없이 기본 GITHUB_TOKEN으로 리뷰 코멘트를 남기도록 단순화. - PR 코멘트에 @eottabom-review-bot을 멘션하면 claude/codex 리뷰를 다시 실행하는 pr-mention-review.yml 추가.
- git checkout에 PR head.ref를 직접 셸 확장하던 부분을 제거하고 refs/pull/<n>/head fetch + head_sha 검증으로 대체해 브랜치명을 통한 템플릿/셸 인젝션 가능성을 없앤다. - origin remote에 남아있던 토큰을 fetch 직후 제거해 영구 작업 디렉터리에 자격증명이 남지 않게 한다. - claude-review 잡의 파이프라인 `|| true`가 claude 실행 자체의 실패까지 삼키던 문제를 set +e/PIPESTATUS로 교체해 claude 스크립트의 실제 종료 코드만 잡의 성패로 반영한다. - codex-review에도 claude-review와 동일한 CLI 로그인 상태 사전 점검과 만료 알림 코멘트를 추가한다. - PR 작성자/코멘트 작성자가 OWNER/MEMBER/COLLABORATOR가 아니면 자동/멘션 리뷰가 실행되지 않도록 제한해, 외부 PR이 self-hosted 러너에서 신뢰되지 않은 스크립트를 실행하는 범위를 줄인다.
Summary
pull_request: [opened, ready_for_review]시claude-review/codex-review잡을 병렬로 실행@eottabom-review-bot을 멘션하면 같은 두 잡을 다시 실행 (pr-mention-review.yml)pulls/{pr}/reviewsAPI로 정식 GitHub 리뷰(종합 평가 표 + 인라인 코멘트)를 남김GITHUB_TOKEN으로 동작 (코멘트 작성자는github-actions[bot], 본문 헤더에eottabom-review-bot브랜딩)vars.RUNNER_WORKDIR,vars.RUNNER_HOME)로 분리 — public 저장소에 로컬 경로가 노출되지 않도록 함 (이미gh variable set으로 등록 완료)undefined-lab의/codex review,/claude review슬래시 커맨드 잡 로직을 재사용하되, 수동 트리거 대신 PR 생성/멘션 시 자동 실행되도록 변경필요 사전 작업 (이 PR만으로는 동작 안 함)
sandbox-load-test에 self-hosted mac 러너([self-hosted, macOS, X64]) 등록 필요 — 현재 이 저장소엔 러너가 없음claude/codexCLI 로그인 세션 필요Closes #https://github.com/eottabom/engineering-log/issues/457
Test plan
@eottabom-review-bot멘션 시 재리뷰가 도는지 확인claude로그인 만료 시 경고 코멘트가 정상적으로 달리는지 확인