-
Notifications
You must be signed in to change notification settings - Fork 143
[ISSUE #1182]🔨Add remove-label-on-approve.yml #1183
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
Caution Review failedThe pull request is closed. WalkthroughA new GitHub Actions workflow named Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Warning Rate limit exceeded@mxsm has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 39 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. 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
Documentation and Community
|
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1183 +/- ##
=======================================
Coverage 16.68% 16.68%
=======================================
Files 427 427
Lines 52832 52832
=======================================
Hits 8815 8815
Misses 44017 44017 ☔ 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: 3
🧹 Outside diff range and nitpick comments (3)
.github/workflows/remove-label-on-approve.yml (3)
3-7
: Consider expanding review event typesThe workflow currently only triggers on 'submitted' reviews. Consider including other relevant review types like 'edited' and 'dismissed' to handle all review-related scenarios consistently.
on: pull_request_review: types: - submitted + - edited + - dismissed
12-16
: Fix formatting issuesRemove trailing spaces to maintain consistent formatting.
- name: Checkout code - uses: actions/checkout@v4 - + uses: actions/checkout@v4🧰 Tools
🪛 yamllint
[error] 16-16: trailing spaces
(trailing-spaces)
1-1
: Add workflow documentationPlease add a README.md file in the
.github/workflows
directory explaining:
- The purpose of this workflow
- Required secrets (BOT_TOKEN) and their permissions
- How to configure and customize the workflow
- Expected behavior and limitations
Would you like me to help create this documentation?
🧰 Tools
🪛 yamllint
[error] 1-1: wrong new line character: expected \n
(new-lines)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
.github/workflows/remove-label-on-approve.yml
(1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/remove-label-on-approve.yml
[error] 1-1: wrong new line character: expected \n
(new-lines)
[error] 16-16: trailing spaces
(trailing-spaces)
[error] 24-24: trailing spaces
(trailing-spaces)
[error] 28-28: trailing spaces
(trailing-spaces)
[error] 35-35: trailing spaces
(trailing-spaces)
🔇 Additional comments (1)
.github/workflows/remove-label-on-approve.yml (1)
8-11
: LGTM! Well-structured job configuration
The conditional execution for approved reviews is properly implemented.
with: | ||
github-token: ${{ secrets.BOT_TOKEN }} | ||
script: | | ||
const labelToRemove = 'waiting-review'; // The name of the label to remove |
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.
🛠️ Refactor suggestion
Make label name configurable
Consider making the label name configurable through workflow inputs rather than hardcoding it.
- const labelToRemove = 'waiting-review'; // The name of the label to remove
+ const labelToRemove = core.getInput('label-name') || 'waiting-review';
Add this to the workflow inputs:
on:
pull_request_review:
types:
- submitted
inputs:
label-name:
description: 'Name of the label to remove'
required: false
default: 'waiting-review'
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ | ||
owner, | ||
repo, | ||
issue_number, | ||
}); |
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.
Add error handling for API calls
The API calls lack proper error handling, which could lead to silent failures.
- const { data: labels } = await github.rest.issues.listLabelsOnIssue({
- owner,
- repo,
- issue_number,
- });
+ try {
+ const { data: labels } = await github.rest.issues.listLabelsOnIssue({
+ owner,
+ repo,
+ issue_number,
+ });
+
+ // Check if the target label exists
+ const labelExists = labels.some(label => label.name === labelToRemove);
+ if (labelExists) {
+ // Remove the label
+ await github.rest.issues.removeLabel({
+ owner,
+ repo,
+ issue_number,
+ name: labelToRemove,
+ });
+ console.log(`Label '${labelToRemove}' has been removed.`);
+ } else {
+ console.log(`Label '${labelToRemove}' does not exist on this PR.`);
+ }
+ } catch (error) {
+ core.setFailed(`Failed to manage labels: ${error.message}`);
+ }
Also applies to: 40-46
- name: Remove label using github-script | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.BOT_TOKEN }} |
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.
Document required token permissions
The workflow uses BOT_TOKEN
but doesn't specify the required permissions. This should be documented to ensure proper setup.
Add a comment explaining the required permissions:
+ # Requires a token with 'issues:write' permissions to manage labels
github-token: ${{ secrets.BOT_TOKEN }}
📝 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.
github-token: ${{ secrets.BOT_TOKEN }} | |
# Requires a token with 'issues:write' permissions to manage labels | |
github-token: ${{ secrets.BOT_TOKEN }} |
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
🚀Thanks for your contribution🎉. CodeRabbit(AI) will review your code first🔥 |
Which Issue(s) This PR Fixes(Closes)
Fixes #1182
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
waiting-review
label from pull requests upon approval, improving workflow efficiency.