-
Notifications
You must be signed in to change notification settings - Fork 280
fix: adjust pr-label strategy #2984
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
Conversation
Walkthrough该改动在 GitHub Actions 工作流文件中更新了管理拉取请求标签的定时触发器(每 3 小时执行),调整了 Changes
Sequence Diagram(s)sequenceDiagram
participant Cron as 定时触发器 (Cron)
participant Runner as GitHub Actions Runner
participant PR as 开放的 PR 列表
participant Review as 评论获取器
participant Label as 标签管理器
Cron->>Runner: 每3小时触发工作流
Runner->>PR: 获取所有开放的 PR
loop 针对每个 PR
PR->>Review: 获取该 PR 的所有评论
Review-->>Runner: 传回评论数据
Runner->>Label: 计算各用户最新评论及批准数
Label-->>Runner: 返回标签更新信息
Runner->>PR: 用setLabels更新标签,保留非操作标签
end
Runner->>Runner: 记录并处理错误
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🪛 actionlint (1.7.4).github/workflows/pr-labels.yml22-22: 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) ⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (2)
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 #2984 +/- ##
=============================================
+ Coverage 85.74% 85.75% +0.01%
=============================================
Files 277 277
Lines 18105 18110 +5
Branches 2745 2735 -10
=============================================
+ Hits 15524 15531 +7
+ Misses 2576 2574 -2
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: 2
🧹 Nitpick comments (1)
.github/workflows/pr-labels.yml (1)
4-5
: 建议降低定时任务的执行频率每15分钟执行一次定时任务可能过于频繁,建议根据团队的 PR review 节奏调整为更合理的间隔(如每小时或每2小时)。这样可以减少 GitHub Actions 的资源消耗。
schedule: - - cron: '*/15 * * * *' + - cron: '0 */2 * * *'
📜 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
21-21: 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)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (1)
.github/workflows/pr-labels.yml (1)
21-21
: 更新 github-script action 版本当前使用的
actions/github-script@v6
版本过旧,建议更新到最新版本以确保兼容性和安全性。✅ Verification successful
🌐 Web query:
What is the latest version of actions/github-script?
💡 Result:
The latest version of
actions/github-script
is v7, as shown in multiple examples and recent workflow updates[1][7]. This is confirmed by GitHub Actions documentation references and pull request updates explicitly usingactions/github-script@v7
for API interactions[1][4][7].For context:
- The action provides pre-authenticated Octokit client access to GitHub's API
- It supports JavaScript/TypeScript scripting within workflows
- Recent updates (as of February 2025) show active maintenance with dependency bumps and security patches[8]
Citations:
- 1: https://cicube.io/workflow-hub/github-actions-script/
- 2: https://github.com/features/actions
- 3: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/adding-scripts-to-your-workflow
- 4: https://learn.microsoft.com/en-us/training/modules/automate-github-using-github-script/
- 5: https://github.com/actions?language=makefile
- 6: https://sourceforge.net/projects/actions-github-script.mirror/files/v6.4.1/
- 7: https://github.com/canonical/repo-policy-compliance/actions/runs/6950268554/workflow
- 8: https://github.com/actions/github-script/actions
更新 github-script action 版本
- 当前工作流文件
.github/workflows/pr-labels.yml
中使用的actions/github-script@v6
版本已过时。- 根据最新查询结果,最新版本为 v7,建议升级以确保工作流兼容性和安全性。
- 请将对应行更新为
uses: actions/github-script@v7
。🧰 Tools
🪛 actionlint (1.7.4)
21-21: 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)
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: 3
♻️ Duplicate comments (1)
.github/workflows/pr-labels.yml (1)
29-33
:⚠️ Potential issue添加分页处理逻辑
当前获取 PR 列表的实现没有处理分页,可能会遗漏部分 PR。建议添加分页处理逻辑以确保获取所有开放的 PR。
const { data: prs } = await github.rest.pulls.list({ owner, repo, - state: 'open' + state: 'open', + per_page: 100, + page: 1 }); + + let allPRs = prs; + while (prs.length === 100) { + const { data: morePRs } = await github.rest.pulls.list({ + owner, + repo, + state: 'open', + per_page: 100, + page: page + 1 + }); + allPRs = allPRs.concat(morePRs); + }
🧹 Nitpick comments (1)
.github/workflows/pr-labels.yml (1)
76-79
: 优化错误处理机制建议增加更详细的错误信息和重试机制:
- 区分不同类型的错误(API 限流、网络问题等)
- 添加重试逻辑
- 记录更多调试信息
} catch (error) { - console.error('Error:', error); + const errorMessage = error.response?.data?.message || error.message; + console.error('Error type:', error.name); + console.error('Error message:', errorMessage); + console.error('Status code:', error.response?.status); + if (error.response?.status === 403 && error.response?.data?.message.includes('API rate limit exceeded')) { + console.log('等待 API 限流重置...'); + await new Promise(resolve => setTimeout(resolve, 60000)); + // 重试逻辑 + } throw error; }
📜 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
21-21: 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)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test
- GitHub Check: build
关注api权限,20分钟有些频繁,可修订2-5小时。 |
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: 2
📜 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
21-21: 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)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: test
🔇 Additional comments (3)
.github/workflows/pr-labels.yml (3)
12-14
: 添加 rate-limit 权限配置需要添加 rate-limit 权限以支持 API 限流检查。
21-21
: 更新 GitHub Script Action 版本当前版本过旧,建议更新到最新版本。
🧰 Tools
🪛 actionlint (1.7.4)
21-21: 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)
29-33
: 添加分页处理逻辑当前获取 PR 列表的实现可能会遗漏部分 PR。
* fix: adjust pr-label strategy * fix: adjust time interval * fix: adjust interval time * fix: adjust interval time
Summary by CodeRabbit
Chores
Refactor