-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add PR review labels automation #2972
base: feat_v3.x
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@Alex-huxiyang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 33 seconds before requesting another review. ⌛ 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. 📒 Files selected for processing (1)
Walkthrough本次提交新增了一个 GitHub Actions 工作流文件 (.github/workflows/pr-labels.yml),用于根据拉取请求(PR)中的评论状态自动管理标签。该工作流在 PR 评论相关事件触发时运行,通过脚本统计批准评论的数量,并根据审批数目删除旧标签后添加新的标签(当批准数达到两个或以上时添加 "action:merge",否则添加 "action:review")。 Changes
Sequence Diagram(s)sequenceDiagram
participant PR as 拉取请求
participant GA as GitHub Actions
participant Script as 脚本
participant API as GitHub API
PR->>GA: 触发 PR 评论事件(提交/编辑/撤销审核)
GA->>Script: 执行 update-labels 任务
Script->>API: 获取 PR 审查数据
API-->>Script: 返回审核统计结果
Script->>API: 移除旧标签(action:merge 和 action:review)
alt 审核数 ≥ 2
Script->>API: 添加 "action:merge" 标签
else
Script->>API: 添加 "action:review" 标签
end
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat_v3.x #2972 +/- ##
==========================================
Coverage 85.74% 85.74%
==========================================
Files 277 277
Lines 18110 18105 -5
Branches 2745 2745
==========================================
- Hits 15528 15524 -4
+ Misses 2577 2576 -1
Partials 5 5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
.github/workflows/pr-labels.yml (4)
13-14
: 建议更新 Checkout Action 版本
当前使用的 actions/checkout@v3 可能存在已知问题或安全隐患,建议检查最新稳定版本并升级。例如:- uses: actions/checkout@v3 + uses: actions/[email protected] # 请根据最新版本做相应更新🧰 Tools
🪛 actionlint (1.7.4)
14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
16-18
: 建议更新 GitHub Script Action 版本
actions/github-script@v6 可能也略显过时,建议更新至最新版本以确保良好的兼容性和安全性。例如:- uses: actions/github-script@v6 + uses: actions/[email protected] # 请核对最新稳定版后更新🧰 Tools
🪛 actionlint (1.7.4)
17-17: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
19-63
: 脚本逻辑清晰,但可考虑添加错误处理
脚本能够正确获取 PR 评论、计算批准数量并更新标签。为了提高稳定性,建议在关键 API 调用处增加异常捕获或错误日志记录,以便在请求失败时能及时反映问题。🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 63-63: no new line character at the end of file
(new-line-at-end-of-file)
63-63
: 遵循 YAMLlint 规范
文件末尾缺少换行符,请在末尾添加一个新行以符合 YAMLlint 要求。🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 63-63: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pr-labels.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pr-labels.yml
14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
17-17: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🪛 YAMLlint (1.35.1)
.github/workflows/pr-labels.yml
[error] 63-63: no new line character at the end of file
(new-line-at-end-of-file)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (2)
.github/workflows/pr-labels.yml (2)
1-2
: 工作流程名称设置正确
名称 "PR Review Labels" 清晰表明了此工作流程的用途。
3-8
: 触发器配置合理
本部分配置了 pull_request_review 以及 pull_request 的 review 相关触发类型,能够满足自动管理 PR 标签的需求。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
.github/workflows/pr-labels.yml (4)
15-17
: 更新 actions/checkout 版本建议
静态分析工具提示 actions/checkout@v3 版本可能较旧,建议参考 GitHub 官方文档升级到最新稳定版本以提高兼容性和安全性。🧰 Tools
🪛 actionlint (1.7.4)
16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
18-20
: 更新 actions/github-script 版本建议
静态分析工具提示 actions/github-script@v6 可能已不再是最新版本,建议检查最新的发布情况并升级到最新版本以利用新功能和改进。🧰 Tools
🪛 actionlint (1.7.4)
19-19: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
49-56
: 删除旧 Action 标签的实现
使用 for-of 循环逐个调用 API 删除对应标签是可行的方案。若未来标签数目增加,考虑并行执行可能会进一步提高效率,但目前规模下这种实现是合理的。
58-65
: 添加新标签及文件结尾换行问题
根据 approved 数量选择新标签(approvedCount >= 2 时为 "action:merge",否则为 "action:review")的逻辑符合预期。另外,静态分析工具指出文件末尾缺少换行符,请在文件末尾添加换行符以符合 YAML 格式要求。🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 65-65: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/pr-labels.yml
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pr-labels.yml
16-16: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
19-19: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🪛 YAMLlint (1.35.1)
.github/workflows/pr-labels.yml
[error] 65-65: no new line character at the end of file
(new-line-at-end-of-file)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (5)
.github/workflows/pr-labels.yml (5)
1-10
: 工作流名称与触发条件设置
该部分代码定义了工作流名称 “PR Review Labels” 以及监听的多个 pull_request 及 pull_request_review 事件,满足自动化标签管理的基本需求。
21-30
: 提取仓库信息与获取 PR 评论
代码正确地从 context 中提取 owner、repo 和 pull request 编号,并利用 GitHub API 调用了 listReviews 方法获取了所有 PR 评论,逻辑清晰且实现合理。
32-36
: 统计“APPROVED”评论数量
通过过滤 reviews.data 中 state 为 "APPROVED" 的评论来计算数量,这种方式简洁有效,如有需要可增加更严格的状态验证。
37-42
: 获取当前 PR 标签
使用 listLabelsOnIssue 方法获取当前 PR 标签的实现正确,逻辑清楚,有助于后续对标签进行管理。
44-48
: 准备删除旧的 Action 标签
代码通过过滤当前标签集合中的 “action:merge” 和 “action:review” 来确定需要移除的标签,逻辑清晰,无冗余。
🤔 这个变动的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
☑️ 请求合并前的自查清单
Summary by CodeRabbit