Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ISSUE #1590]Add Label approved pull requests action #1591

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

rocketmq-rust-bot
Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot commented Dec 5, 2024

Which Issue(s) This PR Fixes(Closes)

Fixes #1590

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features
    • Introduced a new workflow that automatically labels pull requests as "approved" upon receiving a single approval during the review process.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

This pull request introduces a new GitHub Actions workflow file named label_approved_pull_requests.yml. The workflow is triggered by the pull_request_review event and includes a job that uses the pullreminders/label-when-approved-action to automatically label pull requests as "approved" when they receive at least one approval.

Changes

File Path Change Summary
.github/workflows/label_approved_pull_requests.yml New workflow added to label pull requests upon approval.

Assessment against linked issues

Objective Addressed Explanation
Implement labeling for approved pull requests (#[1590])

Possibly related PRs

Suggested labels

feature, approved, auto merge, ready to review

Suggested reviewers

  • TeslaRustor
  • SpaceXCN
  • mxsm

🐰 In the meadow, hops a little sprite,
With a label of "approved," shining bright.
When reviews come in, oh what a cheer,
For every hop brings the deadline near!
So let’s celebrate with a joyful dance,
For every pull request deserves a chance! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rocketmq-rust-bot
Copy link
Collaborator Author

🔊@rocketmq-rust-bot 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥

@rocketmq-rust-robot rocketmq-rust-robot added this to the v0.4.0 milestone Dec 5, 2024
@rocketmq-rust-robot rocketmq-rust-robot added the feature🚀 Suggest an idea for this project. label Dec 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0117b9e and b99c800.

📒 Files selected for processing (1)
  • .github/workflows/label_approved_pull_requests.yml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/label_approved_pull_requests.yml

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 17-17: trailing spaces

(trailing-spaces)

🔇 Additional comments (2)
.github/workflows/label_approved_pull_requests.yml (2)

7-11: LGTM!

The job configuration is appropriate for this use case.


14-19: ⚠️ Potential issue

Security and maintainability concerns in action configuration

Several issues need attention:

  1. Using @master tag is risky as it can break without warning
  2. Single approval might not align with project's security requirements
  3. The action appears to be unmaintained (last updated 3 years ago)

Recommended changes:

-        uses: pullreminders/label-when-approved-action@master
+        uses: pullreminders/label-when-approved-action@v1.0.7
         env:
-          APPROVALS: "1"
+          APPROVALS: "2"
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          #REMOVE_LABEL: ""

Let's verify the project's review requirements:

✅ Verification successful

Action configuration needs version pinning and cleanup

Based on the verification results:

  1. The repository has some protected branches but no strict review requirements
  2. Historical PRs show a consistent pattern of single approvals
  3. The repository uses auto-request-review workflow with custom configuration

Recommended changes:

-        uses: pullreminders/label-when-approved-action@master
+        uses: pullreminders/label-when-approved-action@v1.0.7
         env:
           APPROVALS: "1"  # Current repository practice
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          #REMOVE_LABEL: ""
  • Pin the action version for stability
  • Keep single approval as it aligns with current repository practices
  • Remove commented out code
  • Fix trailing whitespace
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check repository settings for required reviewers
gh api repos/:owner/:repo/branches/main/protection \
  --jq '.required_pull_request_reviews.required_approving_review_count'

# Check recent merged PRs for typical approval count
gh pr list --state merged --limit 10 --json reviews \
  --jq 'map({number: .number, approvals: [.reviews[].state] | map(select(. == "APPROVED")) | length})'

Length of output: 798


Script:

#!/bin/bash
# Check if there are any branch protection rules defined in the repository
gh api repos/:owner/:repo/branches --jq '.[].protected'

# Check if there are any CODEOWNERS files that might define review requirements
fd -g 'CODEOWNERS' -x cat {}

# Check if there are any other workflow files that might define review requirements
fd -g '*.yml' -g '*.yaml' -t f .github/workflows -x cat {} | grep -i "review"

Length of output: 1201

🧰 Tools
🪛 yamllint (1.35.1)

[error] 17-17: trailing spaces

(trailing-spaces)

Comment on lines +1 to +19
name: Label approved pull requests

on:
pull_request_review:
types: [submitted]

jobs:
labelWhenApproved:
name: Label when approved
runs-on: ubuntu-latest

steps:
- name: Label when approved
uses: pullreminders/label-when-approved-action@master
env:
APPROVALS: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADD_LABEL: "approved"
#REMOVE_LABEL: ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix line endings

The file uses incorrect line ending characters. This can cause issues when the workflow runs on different operating systems.

Please ensure all line endings are normalized to LF (\n). You can fix this by:

  1. Adding a .gitattributes file:
+ *.yml text eol=lf
  1. Or running these git commands:
git config --global core.autocrlf input
git rm --cached -r .
git reset --hard
🧰 Tools
🪛 yamllint (1.35.1)

[error] 1-1: wrong new line character: expected \n

(new-lines)


[error] 17-17: trailing spaces

(trailing-spaces)

Comment on lines +3 to +5
on:
pull_request_review:
types: [submitted]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider additional trigger events for label consistency

The current trigger configuration might lead to stale labels in certain scenarios:

  1. When approvals are dismissed
  2. When PRs are updated after approval

Add these events to maintain label consistency:

 on:
   pull_request_review:
     types: [submitted]
+  pull_request:
+    types: [synchronize]

Also consider using a more comprehensive action that handles these cases automatically, such as actions/label-approved-pulls@v1 which maintains label consistency across PR updates and approval dismissals.

Committable suggestion skipped: line range outside the PR's diff.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 25.46%. Comparing base (0117b9e) to head (b99c800).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1591   +/-   ##
=======================================
  Coverage   25.46%   25.46%           
=======================================
  Files         459      459           
  Lines       60352    60352           
=======================================
  Hits        15371    15371           
  Misses      44981    44981           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mxsm mxsm added the approved PR has approved label Dec 5, 2024
@rocketmq-rust-bot rocketmq-rust-bot merged commit 5b739fd into mxsm:main Dec 5, 2024
26 of 28 checks passed
nakul-py added a commit to nakul-py/rocketmq-rust that referenced this pull request Jan 27, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
AI review first Ai review pr first approved PR has approved auto merge feature🚀 Suggest an idea for this project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature🚀]Add Label approved pull requests action
3 participants