iterate-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIterate on PR Until CI Passes
持续迭代PR直至CI检查通过
Continuously iterate on the current branch until all CI checks pass and review feedback is addressed.
Requires: GitHub CLI () authenticated and available.
gh持续迭代当前分支,直至所有CI检查通过且评审反馈得到处理。
前置要求:已完成GitHub CLI()的认证且可正常使用。
ghProcess
流程
Step 1: Identify the PR
步骤1:识别PR
bash
gh pr view --json number,url,headRefName,baseRefNameIf no PR exists for the current branch, stop and inform the user.
bash
gh pr view --json number,url,headRefName,baseRefName如果当前分支不存在对应的PR,请停止操作并通知用户。
Step 2: Check CI Status First
步骤2:先检查CI状态
Always check CI/GitHub Actions status before looking at review feedback:
bash
gh pr checks --json name,state,bucket,link,workflowThe field categorizes state into: , , , , or .
bucketpassfailpendingskippingcancelImportant: If any of these checks are still , wait before proceeding:
pending- /
sentrysentry-io codecov- /
cursor/bugbotseer - Any linter or code analysis checks
These bots may post additional feedback comments once their checks complete. Waiting avoids duplicate work.
在查看评审反馈前,务必先检查CI/GitHub Actions的状态:
bash
gh pr checks --json name,state,bucket,link,workflowbucketpassfailpendingskippingcancel重要提示:如果以下任意检查仍处于状态,请等待其完成后再继续:
pending- /
sentrysentry-io codecov- /
cursor/bugbotseer - 任何代码检查或代码分析类检查
这些机器人完成检查后可能会发布额外的反馈评论。等待可避免重复工作。
Step 3: Gather Review Feedback
步骤3:收集评审反馈
Once CI checks have completed (or at least the bot-related checks), gather human and bot feedback:
Review Comments and Status:
bash
gh pr view --json reviews,comments,reviewDecisionInline Code Review Comments:
bash
gh api repos/{owner}/{repo}/pulls/{pr_number}/commentsPR Conversation Comments (includes bot comments):
bash
gh api repos/{owner}/{repo}/issues/{pr_number}/commentsLook for bot comments from: Sentry, Codecov, Cursor, Bugbot, Seer, and other automated tools.
当CI检查完成(至少是机器人相关的检查完成)后,收集人工和机器人的反馈:
评审评论与状态:
bash
gh pr view --json reviews,comments,reviewDecision行内代码评审评论:
bash
gh api repos/{owner}/{repo}/pulls/{pr_number}/commentsPR对话评论(包含机器人评论):
bash
gh api repos/{owner}/{repo}/issues/{pr_number}/comments留意来自以下机器人的评论:Sentry、Codecov、Cursor、Bugbot、Seer以及其他自动化工具。
Step 4: Investigate Failures
步骤4:排查失败原因
For each CI failure, get the actual logs:
bash
undefined针对每一项CI失败,获取实际日志:
bash
undefinedList recent runs for this branch
列出当前分支的最近运行记录
gh run list --branch $(git branch --show-current) --limit 5 --json databaseId,name,status,conclusion
gh run list --branch $(git branch --show-current) --limit 5 --json databaseId,name,status,conclusion
View failed logs for a specific run
查看特定运行记录的失败日志
gh run view <run-id> --log-failed
Do NOT assume what failed based on the check name alone. Always read the actual logs.gh run view <run-id> --log-failed
**请勿**仅根据检查名称假设失败原因。务必查看实际日志。Step 5: Validate Feedback
步骤5:验证反馈
For each piece of feedback (CI failure or review comment):
- Read the relevant code - Understand the context before making changes
- Verify the issue is real - Not all feedback is correct; reviewers and bots can be wrong
- Check if already addressed - The issue may have been fixed in a subsequent commit
- Skip invalid feedback - If the concern is not legitimate, move on
针对每一条反馈(CI失败或评审评论):
- 阅读相关代码 - 在进行修改前先理解上下文
- 验证问题是否真实存在 - 并非所有反馈都是正确的;评审人员和机器人也可能出错
- 检查问题是否已被处理 - 该问题可能已在后续提交中修复
- 跳过无效反馈 - 如果问题不合理,请直接跳过
Step 6: Address Valid Issues
步骤6:处理有效问题
Make minimal, targeted code changes. Only fix what is actually broken.
进行最小化、针对性的代码修改。仅修复实际存在的问题。
Step 7: Commit and Push
步骤7:提交并推送
bash
git add -A
git commit -m "fix: <descriptive message of what was fixed>"
git pushbash
git add -A
git commit -m "fix: <描述修复内容的信息>"
git pushStep 8: Wait for CI
步骤8:等待CI完成
Use the built-in watch functionality:
bash
gh pr checks --watch --interval 30This waits until all checks complete. Exit code 0 means all passed, exit code 1 means failures.
Alternatively, poll manually if you need more control:
bash
gh pr checks --json name,state,bucket | jq '.[] | select(.bucket != "pass")'使用内置的监控功能:
bash
gh pr checks --watch --interval 30该命令会等待所有检查完成。退出码0表示所有检查通过,退出码1表示存在失败。
如果需要更多控制权,也可以手动轮询:
bash
gh pr checks --json name,state,bucket | jq '.[] | select(.bucket != "pass")'Step 9: Repeat
步骤9:重复操作
Return to Step 2 if:
- Any CI checks failed
- New review feedback appeared
Continue until all checks pass and no unaddressed feedback remains.
如果出现以下情况,请返回步骤2:
- 任何CI检查失败
- 出现新的评审反馈
持续重复操作,直至所有检查通过且无未处理的反馈。
Exit Conditions
退出条件
Success:
- All CI checks are green ()
bucket: pass - No unaddressed human review feedback
Ask for Help:
- Same failure persists after 3 attempts (likely a flaky test or deeper issue)
- Review feedback requires clarification or decision from the user
- CI failure is unrelated to branch changes (infrastructure issue)
Stop Immediately:
- No PR exists for the current branch
- Branch is out of sync and needs rebase (inform user)
成功退出:
- 所有CI检查均通过()
bucket: pass - 无未处理的人工评审反馈
请求帮助:
- 同一失败问题在3次尝试后仍存在(可能是不稳定测试或更深层次的问题)
- 评审反馈需要用户澄清或做出决策
- CI失败与分支修改无关(基础设施问题)
立即停止:
- 当前分支不存在对应的PR
- 分支与上游不同步,需要重新合并(通知用户)
Tips
提示
- Use to focus only on required checks
gh pr checks --required - Use to see all job steps, not just failures
gh run view <run-id> --verbose - If a check is from an external service, the field in checks JSON provides the URL to investigate
link
- 使用仅关注必填检查项
gh pr checks --required - 使用查看所有作业步骤,而非仅失败步骤
gh run view <run-id> --verbose - 如果检查来自外部服务,检查结果JSON中的字段提供了用于排查的URL
link