Skip to content

Do not approve draft pull requests - #368

Closed
jaydev-CAstra wants to merge 2 commits into
OCA:masterfrom
jaydev-CAstra:fix-draft-pr-approved-label-305
Closed

jaydev-CAstra wants to merge 2 commits into
OCA:masterfrom
jaydev-CAstra:fix-draft-pr-approved-label-305

Conversation

@jaydev-CAstra

Copy link
Copy Markdown

Fixes #305

Problem

tag_approved only looks at the reviews: a draft PR with enough approvals gets the approved label, and when an approved PR is converted back to draft nothing removes the approved and ready to merge labels (no webhook handles that event, and the task would keep them anyway).

Reproduced with unit tests on a mocked PR (draft=True, two approvals): the task adds approved and schedules tag_ready_to_merge.

Fix

  • tag_approved: a draft PR is never approved; if it carries the approved / ready to merge labels they are removed, same as when changes are requested.
  • New webhook on_pr_draft on pull_request actions converted_to_draft and ready_for_review, which re-evaluates tag_approved for the PR.
  • tag_ready_to_merge: the search query gets draft:false, so a draft PR that still has the approved label cannot become ready to merge.
  • README and a 305.bugfix newsfragment.

Tests

  • tests/test_tag_approved.py (new): approved label added, labels removed on changes requested, draft PR not approved, draft PR loses its labels.
  • tests/test_on_pr_draft.py (new): the webhook schedules tag_approved.
  • First commit, test infrastructure: set_config() restored the new value instead of the saved one, and test_switchable_method left BOT_TASKS modified, so any switchable task called by a later test was silently disabled (that is how the new tests first failed in the full run while passing alone). Both are now restored properly.

78 tests pass locally (the 3 test_build_wheels tests are skipped here because this machine's Python has no ensurepip, unrelated).

set_config restored the new value instead of the saved one, and
test_switchable_method left BOT_TASKS set to its last value, so every
switchable task called by a later test was silently disabled.
A draft PR is not ready for review, so tag_approved no longer sets the
approved label on it and removes the approved and ready to merge labels
if it has them. Converting a PR to draft and marking it ready for review
now re-evaluate the labels, and the ready to merge search skips drafts.

Fixes OCA#305
@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

@legalsylvain It would be nice if you comment the reason why you close the PRs when closing them.

@legalsylvain

Copy link
Copy Markdown
Collaborator

@legalsylvain It would be nice if you comment the reason why you close the PRs when closing them.

I don't see the point in talking to a robot. And I don't want to waste my time doing that. Thanks.

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

I don't see the point in talking to a robot. And I don't want to waste my time doing that. Thanks.

I want to believe it's a real person that uses some LLM, not a real robot, so I think being a bit nicer to a contributor cannot be that difficult. @sbidoul, the PR fixes an issue you created, so you may want to say something here.

@legalsylvain

Copy link
Copy Markdown
Collaborator

I want to believe it's a real person that uses some LLM, not a real robot, so I think being a bit nicer to a contributor cannot be that difficult

I'll not make effort to be "nice" with such robotized contribution. Feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Draft PR should not get the Approved label

3 participants