ci: add PR size labeling workflow#2042
Conversation
Apply a "size: XS/S/M/L/XL" label to pull requests based on a weighted diff score (code + 50% docs + 50% tests), excluding poetry.lock and recorded test data so generated fixtures do not dominate the size. Runs on pull_request_target with no checkout of PR head code; the job reads the PR file list and calls the labels API only. Signed-off-by: Pouyanpi <13303554+Pouyanpi@users.noreply.github.com>
📝 WalkthroughWalkthroughA new GitHub Actions workflow ( ChangesPR Size Label Workflow
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/pr-size-label.yml:
- Around line 72-80: The removeLabel API call can fail with a 404 error if
another workflow or actor has already removed the label, which causes the entire
workflow to fail. Wrap the github.rest.issues.removeLabel call in a try-catch
block to handle this benign race condition. In the catch block, check if the
error is a 404 status code (which indicates the label was already removed), and
if so, silently ignore it by continuing to the next iteration. For any other
errors, you may choose to log or handle them differently, but the 404 should be
treated as a non-fatal condition that allows the labeling workflow to succeed.
- Around line 26-27: The workflow permissions block currently only includes
`pull-requests: write`, but the workflow uses `github.rest.issues.removeLabel()`
and `github.rest.issues.addLabels()` which require the `issues: write`
permission scope. Add `issues: write` to the permissions section in the workflow
file alongside the existing `pull-requests: write` permission to ensure these
label operations have the necessary access permissions and will not fail with a
403 error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 402786ba-daa2-4415-982a-bf8a3a9afe66
📒 Files selected for processing (1)
.github/workflows/pr-size-label.yml
Description
Apply a "size: XS/S/M/L/XL" label to pull requests based on a weighted diff score (code + 50% docs + 50% tests), excluding poetry.lock and recorded test data so generated fixtures do not dominate the size.
Runs on pull_request_target with no checkout of PR head code; the job reads the PR file list and calls the labels API only.
Related Issue(s)
Verification
AI Assistance
Checklist
Summary by CodeRabbit