[sglang] CI 버그 수정: /rerun-ut 동시 실행 시 중복 워크플로우 URL 문제 해결
PR 링크: sgl-project/sglang#21495 상태: Merged | 변경: +25 / -15
들어가며
SGLang의 CI에서는 PR 코멘트로 /rerun-ut <test_command>를 입력하면 특정 테스트를 재실행할 수 있습니다. 워크플로우가 트리거된 후, find_workflow_run_url() 함수가 방금 시작된 워크플로우의 URL을 찾아 PR에 댓글로 게시합니다. 문제는 동시에 여러 /rerun-ut가 실행되면 display_title이 동일하여 잘못된 워크플로우 URL이 매칭되는 것이었습니다.
핵심 코드 분석
1. run-name에 test_command 포함
Before (rerun-ut.yml):
run-name: ${{ inputs.pr_head_sha && format('[rerun-ut] {0}', inputs.pr_head_sha) || '[rerun-ut]' }}
After:
run-name: ${{ inputs.pr_head_sha && format('[rerun-ut] {0} {1}', inputs.test_command, inputs.pr_head_sha) || format('[rerun-ut] {0}', inputs.test_command) }}
기존에는 [rerun-ut] abc123 형태였지만, 이제 [rerun-ut] test_foo.py abc123처럼 test_command가 포함되어 각 실행을 고유하게 식별합니다.
2. URL 매칭 로직에 test_command 전달
Before:
if pr_head_sha:
expected_title = f"[{target_stage}] {pr_head_sha}"
else:
expected_title = f"[{target_stage}]"
After:
suffix = f" {test_command}" if test_command else ""
if pr_head_sha:
expected_title = f"[{target_stage}]{suffix} {pr_head_sha}"
else:
expected_title = f"[{target_stage}]{suffix}"
3. 댓글 통합
Before:
comment.create_reaction("+1")
pr.create_issue_comment(f"✅ Triggered `/rerun-ut` on ...")
# 별도 댓글
run_url = find_workflow_run_url(...)
pr.create_issue_comment(f"🔗 [View workflow run]({run_url})")
After:
comment.create_reaction("+1")
run_url = find_workflow_run_url(..., test_command=test_command)
if run_url:
pr.create_issue_comment(
f"✅ Triggered `/rerun-ut` on `{runner_label}` runner:"
f" [View workflow run]({run_url})\n"
f"```\ncd test/ && python3 {test_command}\n```")
두 개의 댓글을 하나로 합쳐 PR의 가독성도 개선되었습니다.
왜 이게 좋은가
- 정확한 URL 매칭: 동시에 여러
/rerun-ut가 실행되어도 각각의 워크플로우를 정확히 구분합니다. - PR 댓글 정리: 2개 댓글 대신 1개로 합쳐 알림 피로를 줄입니다.
- 디버깅 용이성: run-name에 test_command가 포함되어, Actions 탭에서 어떤 테스트인지 바로 확인됩니다.
정리
Race condition 성격의 CI 버그를 워크플로우 식별자를 더 구체적으로 만들어 해결한 PR입니다. 동시성 문제는 유니크 식별자가 핵심이라는 교훈을 줍니다.
참고 자료
⚠️ 알림: 이 분석은 AI가 실제 코드 diff를 기반으로 작성했습니다.
관련 포스트
PR Analysis 의 다른글
- 이전글 [SGLang] flush_cache API에 timeout 파라미터 추가
- 현재글 : [sglang] CI 버그 수정: /rerun-ut 동시 실행 시 중복 워크플로우 URL 문제 해결
- 다음글 [sglang] flush_cache 단순화: 동시 요청 거부와 클라이언트 재시도 제거
댓글