-
Notifications
You must be signed in to change notification settings - Fork 119
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
Conversation
WalkthroughThe pull request modifies the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
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
Documentation and Community
|
🔊@mxsm 🚀Thanks for your contribution 🎉. CodeRabbit(AI) will review your code first 🔥 |
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
🧹 Outside diff range and nitpick comments (3)
.github/workflows/sync-issue-labels.yml (3)
Line range hint
2-4
: Security Warning: Carefully reviewpull_request_target
usageThe 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:
- Explicitly defining minimum required permissions
- Adding
if: github.event.pull_request.head.repo.full_name == github.repository
to prevent running on fork PRs if not neededAdd 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 limitingThe workflow could be more robust with the following improvements:
- Add try-catch blocks around API calls
- Implement exponential backoff for API rate limits
- 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 nameThe
BOT_TOKEN_1
secret name is not very descriptive. Consider renaming it to something more specific likeLABEL_SYNC_TOKEN
orGITHUB_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
📒 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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
Which Issue(s) This PR Fixes(Closes)
Fixes #1556
Brief Description
How Did You Test This Change?
Summary by CodeRabbit
New Features
Bug Fixes