feat: add revision guard draft conversion flow#2279
Conversation
|
Hi @NssGourav Can you link the issue this is solving? |
Thanks, this PR is intended to solve part of #2264. More specifically, it implements the event driven I’ll update the PR description to link it clearly to 2264. |
d55b230 to
a65d089
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a revision-guard GitHub Action: helpers for managed-label parsing, draft/bot detection and conversion, label filtering/removal, a handler that converts PRs to draft on "changes_requested" reviews and removes managed labels, accompanying tests, and a workflow that triggers the handler. ChangesRevision Guard Automation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e411f76b-0725-4f2b-9c8d-78c3834a5b64
📒 Files selected for processing (7)
.github/scripts/revision-guard/helpers/constants.js.github/scripts/revision-guard/helpers/draft.js.github/scripts/revision-guard/helpers/index.js.github/scripts/revision-guard/helpers/labels.js.github/scripts/revision-guard/index.js.github/scripts/revision-guard/index.test.js.github/workflows/revision-guard.yml
darshit2308
left a comment
There was a problem hiding this comment.
All the 3 coderabbit suggestions are blockers i think, and must be resolved before merging.
I have left another bug in the inline comments, please go through them.
Rest looks good to me.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: cb898582-3029-4601-9b4a-81d2090aea96
📒 Files selected for processing (4)
.github/scripts/revision-guard/helpers/constants.js.github/scripts/revision-guard/index.js.github/scripts/revision-guard/index.test.js.github/workflows/revision-guard.yml
Community Workflow OverviewHey everyone 👋 Just wanted to leave a quick explanation of how this PR behaves end-to-end since the workflow + script interaction can be a little difficult to follow at first glance. This change is mainly focused on improving the contributor review flow when a reviewer requests changes on a PR. What Happens When "Request Changes" Is SubmittedWhen a reviewer clicks Request Changes, GitHub triggers the The workflow then goes through the following steps:
Cases That Are Intentionally Skipped
ConfigurabilityAdditional labels can be managed through the ValidationAll the above cases are covered by unit tests and validated locally: node --test .github/scripts/revision-guard/index.test.jsHappy to answer any questions on the design! |
c22f18f to
aa47223
Compare
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
- fix: add defensive guard on context.payload and context.repo before dereferencing (CodeRabbit major) - fix: parseManagedLabels now merges custom labels with DEFAULT_MANAGED_LABELS instead of silently discarding defaults (darshit2308 blocking) - test: add graphqlCalls assertion in configurable-labels test to catch draft-conversion regressions (CodeRabbit trivial) - fix: checkout uses trusted base SHA instead of PR head/merge ref to prevent fork PRs from running untrusted code with write-scoped token (CodeRabbit critical) Signed-off-by: Gourav NSS <gourav341111@gmail.com>
- convertToDraft re-throws on failure so the workflow fails loudly - removeManagedLabels does not re-throw since draft conversion is the primary goal; a label-cleanup failure is logged via core.error but does not fail the run Signed-off-by: Gourav NSS <gourav341111@gmail.com>
aa47223 to
c3537b0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 270a356c-e3cb-4a12-a24c-6afd9e56857e
📒 Files selected for processing (7)
.github/scripts/revision-guard/helpers/constants.js.github/scripts/revision-guard/helpers/draft.js.github/scripts/revision-guard/helpers/index.js.github/scripts/revision-guard/helpers/labels.js.github/scripts/revision-guard/index.js.github/scripts/revision-guard/index.test.js.github/workflows/revision-guard.yml
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Gourav N S S <gourav341111@gmail.com>
This comment has been minimized.
This comment has been minimized.
| return pr?.draft === true; | ||
| } | ||
|
|
||
| async function convertToDraft(github, pullRequestId) { |
There was a problem hiding this comment.
Hi, have you tested this call works given your permissions?
I took a look at the documentation
https://docs.github.com/en/graphql/reference/input-objects#convertpullrequesttodraftinput
and couldn't find clear permission info, but then saw https://github.com/orgs/community/discussions/24686
Quite possibly this entire PR cannot work without write permissions on the contents, which for obvious reasons we would have to reject and go back to the drawing board
There was a problem hiding this comment.
@exploreriii your concern is valid. I found actions/toolkit#1165 which is specifically about convertPullRequestToDraft failing from GitHub Actions with Resource not accessible by integration, and the confirmed fix is adding contents: write. I missed this one while reviewing, @NssGourav could you also please test it with given permissions ?
exploreriii
left a comment
There was a problem hiding this comment.
Requesting more testing
|
@NssGourav For assistance with testing on your fork, pleasure use this link Fork-Testing |
|
Hello, this is the OfficeHourBot. This is a reminder that the Hiero Python SDK Office Hours will begin in approximately 3 hours (14:00 UTC). This session provides an opportunity to ask questions regarding this Pull Request. Details:
Disclaimer: This is an automated reminder. Please verify the schedule here for any changes. From, |
Description:
Implement the first event-driven Revision Guard slice for the Python SDK review flow.
This PR handles the
CHANGES_REQUESTEDpath by converting a ready PR back to draft and cleaning up managed review/queue labels, while keeping the implementation lightweight and flexible around evolving label logic.revision-guardreview-event workflow forpull_request_review.submittedchanges_requestedRelated issue(s):
Part of #2264
Notes for reviewer:
This PR intentionally covers only the event-driven draft-conversion slice of Revision Guard.
It does not include the broader cron side requirements checklist/reporting work. The scope here is limited to the minimal to the aligned direction:
CHANGES_REQUESTED -> draftValidation run locally:
node --test .github/scripts/revision-guard/index.test.jsChecklist