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 #1556]🔨Update Gtihub sync-issue-labels.yml action #1557

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

mxsm
Copy link
Owner

@mxsm mxsm commented Dec 5, 2024

Which Issue(s) This PR Fixes(Closes)

Fixes #1556

Brief Description

How Did You Test This Change?

Summary by CodeRabbit

  • New Features

    • Improved label synchronization for pull requests by excluding 'good first issue' and 'help wanted' labels.
  • Bug Fixes

    • Enhanced the accuracy of labels added to pull requests, ensuring only relevant labels are synchronized.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The pull request modifies the .github/workflows/sync-issue-labels.yml workflow file to improve the label synchronization process from linked issues to pull requests (PRs). The workflow continues to trigger on pull_request_target events, but now includes a filtering mechanism that excludes the labels 'good first issue' and 'help wanted' from being added to PRs. This change introduces a new logic layer while maintaining the overall control flow of extracting issue numbers, fetching labels, and synchronizing them to the PR.

Changes

File Change Summary
.github/workflows/sync-issue-labels.yml Modified to filter out 'good first issue' and 'help wanted' labels during synchronization to PRs.

Assessment against linked issues

Objective Addressed Explanation
Enhance label synchronization in workflow (#1556)

Possibly related PRs

Suggested labels

enhancement, approved, auto merge, ready to review, AI review first

Suggested reviewers

  • TeslaRustor
  • SpaceXCN

Poem

In the garden of code, where labels bloom,
A rabbit hops lightly, dispelling the gloom.
With a flick of the ear, we filter with care,
'Good first' and 'help'—no need to share!
Synchronize wisely, let only the best,
In our PRs, we strive for the quest! 🐇✨


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

🔊@mxsm 🚀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 enhancement⚡️ New feature or request 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: 0

🧹 Outside diff range and nitpick comments (3)
.github/workflows/sync-issue-labels.yml (3)

Line range hint 2-4: Security Warning: Carefully review pull_request_target usage

The workflow uses pull_request_target which runs with repository secrets and write permissions. This can be dangerous if the workflow checks out and runs untrusted PR code. While this workflow appears safe as it only uses the GitHub API, consider:

  1. Explicitly defining minimum required permissions
  2. Adding if: github.event.pull_request.head.repo.full_name == github.repository to prevent running on fork PRs if not needed

Add permissions at the job level:

jobs:
  sync-labels:
    permissions:
      pull-requests: write
      issues: read
    runs-on: ubuntu-latest
🧰 Tools
🪛 yamllint (1.35.1)

[error] 41-41: trailing spaces

(trailing-spaces)


[error] 45-45: trailing spaces

(trailing-spaces)


Line range hint 1-58: Consider adding error handling and rate limiting

The workflow could be more robust with the following improvements:

  1. Add try-catch blocks around API calls
  2. Implement exponential backoff for API rate limits
  3. Add input validation for the extracted issue numbers

Example implementation:

 script: |
+            async function apiCallWithRetry(fn, maxRetries = 3) {
+              for (let i = 0; i < maxRetries; i++) {
+                try {
+                  return await fn();
+                } catch (error) {
+                  if (error.status === 403 && error.message.includes('rate limit')) {
+                    const waitTime = Math.pow(2, i) * 1000;
+                    console.log(`Rate limited. Waiting ${waitTime}ms before retry ${i + 1}/${maxRetries}`);
+                    await new Promise(resolve => setTimeout(resolve, waitTime));
+                    continue;
+                  }
+                  throw error;
+                }
+              }
+            }
+
             // Extract linked issue numbers from the PR description
             const { owner, repo } = context.repo;
             const issueNumbers = context.payload.pull_request.body
               ?.match(/(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)?(?:\s*)?#(\d+)/gi)
               ?.map(match => parseInt(match.match(/\d+/)[0])) || [];
+
+            // Validate issue numbers
+            const validIssueNumbers = issueNumbers.filter(num => num > 0);
+            if (validIssueNumbers.length !== issueNumbers.length) {
+              console.log("Warning: Some invalid issue numbers were filtered out");
+            }
             
-            for (const issueNumber of issueNumbers) {
+            for (const issueNumber of validIssueNumbers) {
               console.log(`Processing linked issue: #${issueNumber}`);
             
               // Fetch labels from the linked issue
-              const issueResponse = await github.rest.issues.get({
-                owner,
-                repo,
-                issue_number: issueNumber,
-              });
+              const issueResponse = await apiCallWithRetry(() => 
+                github.rest.issues.get({
+                  owner,
+                  repo,
+                  issue_number: issueNumber,
+                })
+              );
🧰 Tools
🪛 yamllint (1.35.1)

[error] 41-41: trailing spaces

(trailing-spaces)


[error] 45-45: trailing spaces

(trailing-spaces)


Line range hint 16-17: Consider using a more descriptive token name

The BOT_TOKEN_1 secret name is not very descriptive. Consider renaming it to something more specific like LABEL_SYNC_TOKEN or GITHUB_AUTOMATION_TOKEN.

🧰 Tools
🪛 yamllint (1.35.1)

[error] 41-41: trailing spaces

(trailing-spaces)


[error] 45-45: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ae8845a and 644f82a.

📒 Files selected for processing (1)
  • .github/workflows/sync-issue-labels.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/sync-issue-labels.yml (1)

42-44: LGTM: Label filtering implementation

The filtering of 'good first issue' and 'help wanted' labels is implemented correctly. These labels are typically used for issue triaging and shouldn't be automatically propagated to PRs.

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.95%. Comparing base (ae8845a) to head (644f82a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1557   +/-   ##
=======================================
  Coverage   24.95%   24.95%           
=======================================
  Files         450      450           
  Lines       59834    59834           
=======================================
  Hits        14934    14934           
  Misses      44900    44900           

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

@rocketmq-rust-bot rocketmq-rust-bot merged commit a429df2 into main Dec 5, 2024
25 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Dec 5, 2024
@mxsm mxsm deleted the op-1556 branch December 6, 2024 01:31
# 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 enhancement⚡️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement⚡️]Update Gtihub sync-issue-labels.yml action
4 participants