Autolabel bot: optional draft field for path-based labeler.yml rules#8020
Draft
jithunnair-amd wants to merge 4 commits into
Draft
Autolabel bot: optional draft field for path-based labeler.yml rules#8020jithunnair-amd wants to merge 4 commits into
jithunnair-amd wants to merge 4 commits into
Conversation
- Add labelerConfigUtils with legacy glob arrays and extended { globs, draft } rules
- draft: false skips the label while the PR is draft; draft: true limits to drafts only
- Pass pull_request.draft into getLabelsFromLabelerConfig; listen for ready_for_review
- Await context.config when loading labeler and label-to-label configs (fix stale promises)
- Add unit and integration tests
Made-with: Cursor
Labeler config loading fix lives on fix/await-labeler-config-cache; merge that PR before or rebase this branch onto main after it lands. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the auto-label bot’s labeler.yml path-based labeling to optionally gate individual label rules on whether a pull request is a draft, and ensures labels can be applied when a PR transitions from draft to ready-for-review.
Changes:
- Added
torchci/lib/bot/labelerConfigUtils.tsto normalizelabeler.ymlrules and apply optionaldraftconstraints during path matching. - Updated
autoLabelBot.tsto use the new helper, passpull_request.draft, and handlepull_request.ready_for_review. - Added unit + integration tests covering rule normalization and
draft: falsebehavior for draft vs non-draft PRs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| torchci/lib/bot/labelerConfigUtils.ts | New utility module for parsing/normalizing labeler rules and enforcing optional draft constraints during glob matching. |
| torchci/lib/bot/autoLabelBot.ts | Switches labeler logic to the new module, passes draft state, and re-runs labeling on ready_for_review. |
| torchci/test/labelerConfigUtils.test.ts | Unit tests for rule normalization and draft gating behavior. |
| torchci/test/autoLabelBot.test.ts | Integration tests for mixed legacy + draft:false rules on draft vs non-draft PRs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+30
| const r = rule as { globs: string[]; draft?: unknown }; | ||
| const out: { globs: string[]; draft?: boolean } = { globs: r.globs }; | ||
| if (typeof r.draft === "boolean") { | ||
| out.draft = r.draft; | ||
| } | ||
| return out; |
| context: Context, | ||
| labelerConfigTracker: CachedLabelerConfigTracker, | ||
| changed_files: string[], | ||
| isDraft: boolean |
Comment on lines
452
to
+458
| app.on( | ||
| ["pull_request.opened", "pull_request.edited", "pull_request.synchronize"], | ||
| [ | ||
| "pull_request.opened", | ||
| "pull_request.edited", | ||
| "pull_request.synchronize", | ||
| "pull_request.ready_for_review", | ||
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends repo
labeler.ymlso each label rule can opt out of (or limit to) draft pull requests. Path-based labels can stay on the legacy list-of-globs form; new behavior uses a small object with globs and optional draft.Also registers
pull_request.ready_for_reviewso when a draft PR is marked ready, the bot re-runs the same auto-label path (needed for rules with draft: false).Logic lives in a new module
labelerConfigUtils.ts;autoLabelBot.tsimports it and re-exportsgetLabelsFromLabelerConfigso existing imports keep working.Motivation:
torchtitan CI uses
labeler.ymlto apply labels that trigger CI on PRs. However, we would like to avoid adding that label automatically on draft PRs to limit CI workloads.labeler.ymlschemaLegacy (unchanged):
** Extended:**
falsetrueCode changes
torchci/lib/bot/labelerConfigUtils.tstorchci/lib/bot/autoLabelBot.tslabelerConfigUtils; passcontext.payload.pull_request.draft; handlepull_request.ready_for_review;export { getLabelsFromLabelerConfig }.Tests added / updated
torchci/test/labelerConfigUtils.test.ts— unit tests for parsing and draft gating.torchci/test/autoLabelBot.test.ts— integration tests under “labeler.yml config” for mixed legacy rules +draft: falseon draft vs non-draft PRs.Test plan
jest test/labelerConfigUtils.test.tsjest test/autoLabelBot.test.ts -t "labeler.yml config"jest test/autoLabelBot.test.ts