feat: add revision guard draft conversion flow#2279
Conversation
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
|
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:
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)
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
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
|
Fork testing completed successfully in I followed the fork-testing flow by deploying the revision-guard workflow to my fork During testing, I found that Final validation:
Relevant workflow logs: |
exploreriii
left a comment
There was a problem hiding this comment.
Hi @NssGourav
I think this is pretty good, thank you for polishing this up.
I think the next challenge will be making decisions on how to organise this given the .github surface area will likely grow, and we've already experienced some pains when code is duplicated or it grew overly independently. We do need to ensure a good test surface too, this may require a little refactoring. i think these are the primary concerns.
I'm not happy with pushing the idea of drafting a pr unless it is realistically feasible, in whcih case we can be open to alternatives.
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
Signed-off-by: Gourav NSS <gourav341111@gmail.com>
a18a177 to
daf0df3
Compare
|
I’ve addressed the draft-conversion feasibility and CI test coverage feedback in the latest push: draft conversion is now optional/best-effort with I still need to follow up on the remaining structure/shared helper feedback and the reviewer permission gating discussion. |
exploreriii
left a comment
There was a problem hiding this comment.
Hi @NssGourav
You have written some good code but this PR is not feasible in its current form. We should confirm the current approach does not work, consider archiving the issue, or attempt to resolve it in a different way
| - name: Handle changes requested | ||
| env: | ||
| REVISION_GUARD_MANAGED_LABELS: ${{ vars.REVISION_GUARD_MANAGED_LABELS }} | ||
| REVIEWBOT_TOKEN: ${{ secrets.REVIEWBOT_TOKEN || '' }} |
There was a problem hiding this comment.
Note you are using the trigger pull_request_review https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows
Because of that trigger, PR's from a fork to this repo will operate with reduced permissions.
Passing reviewbot token here will not necessarily work, since i believe it will only allow you to pass the github token with read only permissions due to this trigger
https://github.com/orgs/community/discussions/55940
As a result, the things you are wanting to do are not feasible through this approach
As previously suggested, i think, a cron job may be able to do something similar to your intention
But if its not possible, we should argue for archiving the issue
There was a problem hiding this comment.
i get that, and it's true , that's not an easy thing to do..
|
|
||
| jobs: | ||
| test: | ||
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false |
There was a problem hiding this comment.
You are triggering the workflow to run based on fork PRs to this repo, but you never test it in these cases. So, the tests won't run in the majority of cases
The repo already has a single JS test setup: Jest, rooted at .github/scripts with testMatch: tests/jest/**/*.test.js, executed by test-scripts.yml. Conforming to this would be ideal
Hi @exploreriii thanks for the appreciation of the work, i understand what you say regarding the current approach and i think now this issue is not a medium level task, through our convo i see that it has escalated to Advance task, i have to observe try different methods to solve it. |
|
Hi @NssGourav, This pull request has had no activity for 10 days. Are you still working on it?
If you're no longer working on this, please comment Reach out on discord or join our office hours if you need assistance. From the Python SDK Team |
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