Conversation
|
Note
|
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | PR 제목이 실제 변경사항과 일치합니다. GitHub Actions 라벨 자동 할당 기능 추가 및 검수자 요청 로직 개선이 정확히 반영되어 있습니다. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Description check | ✅ Passed | PR 설명이 제시된 템플릿 구조를 충실히 따르고 있으며, 모든 필수 섹션이 완성되어 있습니다. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
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 and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.github/workflows/pr-label-init.yml:
- Around line 59-69: Wrap the labels add flow in a try-catch, first retrieve the
current PR labels using github.rest.issues.listLabelsOnIssue (or issues.get) and
compute toAdd = labelsToAdd.filter(l => !existingLabels.includes(l)), then only
call github.rest.issues.addLabels with toAdd when toAdd.length > 0 and log the
actual added labels via core.info; in the catch log the error with core.error
including the caught error and context (prNumber, repo), and do not attempt
removal of existing labels here.
🧹 Nitpick comments (2)
.github/workflows/pr-assign-init.yml (1)
56-61: Assignee 할당에도 에러 핸들링을 추가하는 것을 권장합니다.리뷰어 요청(lines 42-47)에는 try-catch 블록을 추가했지만, assignee 할당 로직에는 에러 핸들링이 없습니다.
addAssigneesAPI 호출도 실패할 수 있는 상황이 있습니다:실패 가능한 경우:
- PR 작성자가 이미 assignee로 지정된 경우
- API rate limit 초과
- 권한 문제 (예: 외부 기여자)
- 네트워크 일시적 오류
권장하는 개선 방향:
리뷰어 할당과 동일한 패턴으로 에러 핸들링을 추가하여 일관성을 유지하고, 한 API 호출의 실패가 워크플로우 전체를 중단시키지 않도록 하는 것이 좋습니다.🛡️ Assignee 할당에 에러 핸들링 추가 제안
+ try { await github.rest.issues.addAssignees({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.pull_request.number, assignees: [author] }); + core.info(`Assignee added: ${author}`); + } catch (error) { + core.warning(`Failed to add assignee: ${error.message}`); + }이렇게 하면:
- 리뷰어 할당과 동일한 에러 핸들링 패턴 유지
- assignee 할당 실패 시에도 워크플로우 계속 진행
- 로그를 통해 문제 발생 여부 추적 가능
.github/workflows/pr-label-init.yml (1)
27-27: 라벨 목록이 하드코딩되어 있어 유지보수성이 떨어질 수 있습니다.
validLabels배열이 스크립트 내부에 직접 정의되어 있습니다.현재 방식의 문제점:
- 라벨을 추가/제거할 때마다 워크플로우 파일을 직접 수정해야 함
- pr-assign-init.yml의 팀 라벨(AN, BE)과 이 파일의 라벨이 분리되어 관리됨
- 실수로 잘못된 라벨을 추가할 위험이 있음
개선 대안들:
대안 1: GitHub API로 저장소의 실제 라벨 목록 조회 (권장)
- 장점: 라벨이 저장소에 실제로 존재하는지 자동 검증, 중앙 집중식 관리
- 단점: API 호출 추가로 약간의 실행 시간 증가
대안 2: 별도의 설정 파일로 분리
- 장점: 라벨 관리가 한 곳에서 가능, 다른 워크플로우와 공유 가능
- 단점: 파일 읽기 단계가 추가됨
대안 3: 현재 방식 유지 + 주석으로 문서화
- 장점: 가장 간단하고 빠름
- 단점: 여전히 수동 관리 필요
현재 프로젝트 규모와 라벨 변경 빈도를 고려하여 선택하시면 됩니다. 라벨이 자주 변경되지 않는다면 현재 방식도 충분히 실용적입니다.
💡 대안 1: GitHub API로 저장소 라벨 조회 예시
- const validLabels = ['AN', 'BE', 'chore', 'docs', 'feat', 'fix', 'refactor', 'style', 'test']; + // Fetch repository labels to ensure they exist + const { data: repoLabels } = await github.rest.issues.listLabelsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + const validLabels = repoLabels.map(label => label.name);이렇게 하면 저장소에 실제로 존재하는 라벨만 자동으로 사용하게 됩니다.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/pr-assign-init.yml.github/workflows/pr-label-init.yml
🔇 Additional comments (4)
.github/workflows/pr-assign-init.yml (1)
38-54: Draft PR 체크와 에러 핸들링 추가가 좋습니다!Draft PR에 대한 리뷰어 요청을 건너뛰는 로직과 try-catch를 통한 에러 핸들링이 잘 추가되었습니다. 이를 통해:
- Draft 상태의 PR에서 불필요한 리뷰어 알림을 방지
- API 호출 실패 시 워크플로우 전체가 중단되지 않고 경고만 남김
- 로깅을 통해 디버깅 가능성 향상
이러한 개선은 워크플로우의 안정성과 사용자 경험을 모두 향상시킵니다.
.github/workflows/pr-label-init.yml (3)
31-51: 두 가지 이벤트 소스를 잘 처리하고 있습니다.
workflow_run과pull_request이벤트를 모두 지원하는 로직이 명확하게 분기되어 있고, workflow_run에서 PR이 없는 경우도 적절히 처리하고 있습니다.특히 좋은 점:
- Line 37-42: workflow_run에서 최신 PR 데이터를 다시 fetch하여 업데이트된 제목을 가져오는 부분이 정확합니다
- Line 44-45: PR이 연관되지 않은 경우 early return으로 불필요한 처리를 방지
이 구조는 두 가지 트리거 시나리오를 모두 안전하게 처리할 수 있습니다.
53-57: 정규식 패턴과 라벨 추출 로직이 명확합니다.대괄호 안의 텍스트를 추출하는 정규식
/\[([^\]]+)\]/g와 필터링 로직이 잘 구현되어 있습니다.동작 확인:
[feat] Add feature→['feat']추출 ✓[AN][fix] Fix bug→['AN', 'fix']추출 ✓[invalid] No match→ 필터링되어 제외됨 ✓로직이 의도대로 동작하며 엣지 케이스도 잘 처리됩니다.
4-6: "PR Title Sync" 워크플로우 존재 확인됨 - 문제 없음
.github/workflows/pr-title-init.yml파일이 존재하며,name필드가 정확히 "PR Title Sync"로 설정되어 있습니다. 따라서workflow_run트리거(라인 4-6)가 정상적으로 작동할 것으로 확인됩니다.이 부분의 검증이 필요했던 이유는 GitHub Actions에서
workflow_run트리거는 참조하는 워크플로우의 이름이 정확히 일치해야만 동작하기 때문입니다. 이름에 오타가 있거나 워크플로우가 존재하지 않으면 해당 트리거가 작동하지 않아 예상치 못한 버그의 원인이 될 수 있습니다. 다행히 이 경우 워크플로우가 존재하고 이름이 정확하므로 의도대로 PR 제목 동기화 완료 후 라벨 자동 할당이 실행될 것입니다.
.github/workflows/pr-label-init.yml
Outdated
| if (labelsToAdd.length > 0) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| labels: labelsToAdd | ||
| }); | ||
| core.info(`Labels added: ${labelsToAdd.join(', ')}`); | ||
| } else { | ||
| core.info('No matching labels found in PR title'); | ||
| } |
There was a problem hiding this comment.
라벨 추가 로직에 에러 핸들링과 중복 방지 개선이 필요합니다.
현재 구현에는 두 가지 개선 가능한 부분이 있습니다:
문제점 1: 에러 핸들링 부재
addLabels API 호출(lines 60-65)에 try-catch가 없어서 실패 시 워크플로우 전체가 중단됩니다. 가능한 실패 상황:
- 권한 부족 (특히 외부 기여자의 PR)
- API rate limit 초과
- 네트워크 일시적 오류
- 존재하지 않는 라벨 추가 시도
pr-assign-init.yml에서는 에러 핸들링을 추가했는데, 이 파일에는 없어서 일관성이 떨어집니다.
문제점 2: 중복 라벨 추가 가능성
PR 제목을 수정할 때마다 이 워크플로우가 실행되는데, addLabels API는 이미 존재하는 라벨을 다시 추가하려고 시도합니다. GitHub API는 중복을 무시하지만, 불필요한 API 호출이 발생하고 로그가 부정확해질 수 있습니다.
문제점 3: 라벨 제거 로직 없음
PR 제목에서 라벨을 제거해도 PR에 이미 붙은 라벨은 그대로 남습니다. 예를 들어:
- 초기 제목:
[feat] Add feature→feat라벨 추가 - 수정 제목:
[fix] Fix feature→fix라벨 추가,feat라벨은 그대로 유지됨
🔧 에러 핸들링 추가 및 중복 방지 개선안
const labelsToAdd = extractedLabels.filter(label => validLabels.includes(label));
if (labelsToAdd.length > 0) {
+ try {
+ // Get current labels to avoid duplicates
+ const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: prNumber
+ });
+ const currentLabelNames = currentLabels.map(label => label.name);
+ const newLabels = labelsToAdd.filter(label => !currentLabelNames.includes(label));
+
+ if (newLabels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
- labels: labelsToAdd
+ labels: newLabels
});
- core.info(`Labels added: ${labelsToAdd.join(', ')}`);
+ core.info(`Labels added: ${newLabels.join(', ')}`);
+ } else {
+ core.info('All labels already exist on PR');
+ }
+ } catch (error) {
+ core.warning(`Failed to add labels: ${error.message}`);
+ }
} else {
core.info('No matching labels found in PR title');
}이 개선안의 장점:
- try-catch로 API 실패 시에도 워크플로우가 계속 진행됨
- 기존 라벨을 확인하여 중복 추가를 방지
- 로그가 더 정확해짐 (실제로 추가된 라벨만 표시)
- pr-assign-init.yml과 에러 핸들링 패턴이 일관됨
참고: 라벨 제거 로직은 더 복잡한 요구사항이므로, 필요하다면 별도의 이슈로 추적하는 것을 권장합니다. 제거 로직을 추가하려면:
- 제목에서 제거된 라벨을 감지
- 다른 워크플로우나 수동으로 추가한 라벨과 구분
- 안전하게 제거할 수 있는 라벨만 제거
이는 현재 범위를 넘어서는 작업이므로 선택적으로 고려하시면 됩니다.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (labelsToAdd.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| labels: labelsToAdd | |
| }); | |
| core.info(`Labels added: ${labelsToAdd.join(', ')}`); | |
| } else { | |
| core.info('No matching labels found in PR title'); | |
| } | |
| const labelsToAdd = extractedLabels.filter(label => validLabels.includes(label)); | |
| if (labelsToAdd.length > 0) { | |
| try { | |
| // Get current labels to avoid duplicates | |
| const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber | |
| }); | |
| const currentLabelNames = currentLabels.map(label => label.name); | |
| const newLabels = labelsToAdd.filter(label => !currentLabelNames.includes(label)); | |
| if (newLabels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| labels: newLabels | |
| }); | |
| core.info(`Labels added: ${newLabels.join(', ')}`); | |
| } else { | |
| core.info('All labels already exist on PR'); | |
| } | |
| } catch (error) { | |
| core.warning(`Failed to add labels: ${error.message}`); | |
| } | |
| } else { | |
| core.info('No matching labels found in PR title'); | |
| } |
🤖 Prompt for AI Agents
In @.github/workflows/pr-label-init.yml around lines 59 - 69, Wrap the labels
add flow in a try-catch, first retrieve the current PR labels using
github.rest.issues.listLabelsOnIssue (or issues.get) and compute toAdd =
labelsToAdd.filter(l => !existingLabels.includes(l)), then only call
github.rest.issues.addLabels with toAdd when toAdd.length > 0 and log the actual
added labels via core.info; in the catch log the error with core.error including
the caught error and context (prNumber, repo), and do not attempt removal of
existing labels here.
🔗 관련 이슈
📝 작업 내용
GitHub Actions 워크플로우를 통한 PR 자동 처리 시스템을 개선했습니다. 기존에는 PR 리뷰어 할당 시 Draft 상태를 고려하지 않아 불필요한 Draft PR에도 리뷰어 요청이 발생했고, PR 제목 기반의 라벨 자동 할당 기능이 없어 수동으로 라벨을 관리해야 했습니다.
주요 변경사항
PR 제목 기반 자동 라벨 할당 기능 추가 (
pr-label-init.yml신규 생성)[feat],[fix],[AN]등)AN,BE,chore,docs,feat,fix,refactor,style,test)과 검증하여 일치하는 라벨만 자동 할당workflow_run이벤트에서는 API로 최신 PR 정보를 조회하여 제목이 반영된 상태에서 라벨 할당Draft PR 리뷰어 할당 개선 (
pr-assign-init.yml수정)Assignee 할당의 에러 처리 구조 개선
📊 변경 효과 요약
pr-label-init.yml, +69줄), 1개 수정 (pr-assign-init.yml, +16/-8줄)📸 스크린샷 (Optional)
(해당 없음)