Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to main branch protection rules for PRs targeting branches without protection rules #1900

Merged
merged 3 commits into from
May 2, 2023

Conversation

sarayourfriend
Copy link
Collaborator

@sarayourfriend sarayourfriend commented Apr 26, 2023

Fixes

Fixes #1863 by @sarayourfriend

Description

Fall back to main branch protection for PRs that target branches without their own protection rules.

Testing Instructions

Check out the unit test and confirm that it sufficiently covers the new case.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend added the 🧱 stack: catalog Related to the catalog and Airflow DAGs label Apr 26, 2023
@sarayourfriend sarayourfriend requested a review from a team as a code owner April 26, 2023 00:04
@sarayourfriend sarayourfriend added 🟧 priority: high Stalls work on the project or its dependents 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository labels Apr 26, 2023
Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why skip PRs that do not target main? Isn't there another solution?

I have to look further into the issue but those PR can become stale too.

@sarayourfriend
Copy link
Collaborator Author

Why skip PRs that do not target main? Isn't there another solution?

To determine the number of approvals needed for a PR to be considered "reviewed" (and skipped) we query the branch protection rules. Because no other branches than main have branch protection rules, we don't have a way of deriving the minimum number of required reviews for a PR that targets any other branch.

The alternative to skipping those PRs is to always fall back to 2 required reviews for branches other than main. If that's the preferred approach for reviewers then I am happy to change the PR to that. I don't personally see the need for PR review reminders on PRs that do not target main. In my experience those PRs generally are blocked by their downstream target PR which will inevitably target main and get review reminders.

@krysal
Copy link
Member

krysal commented Apr 28, 2023

The alternative to skipping those PRs is to always fall back to 2 required reviews for branches other than main.

Yeah, I think the default would be better. We haven't changed that requirement since it was implemented. Those PRs can be blocked for merging but the review should still happen at some point.

@dhruvkb
Copy link
Member

dhruvkb commented Apr 30, 2023

we query the branch protection rules

Instead of falling back to a hardcoded value of 2, I would recommend falling back to whatever is the required number of reviews for main in the queried branch protection rules. This will give us the flexibility to change that in the future, if needed.

@sarayourfriend
Copy link
Collaborator Author

Sounds good.

@sarayourfriend sarayourfriend requested a review from krysal May 1, 2023 02:10
@sarayourfriend
Copy link
Collaborator Author

@krysal This is ready for re-review now.

@sarayourfriend sarayourfriend force-pushed the add/ignore-non-main-target-prs branch from e724845 to ba86aba Compare May 1, 2023 02:11
@AetherUnbound AetherUnbound changed the title Skip reminders for PRs that do not target main Use default reviewer count for PRs that do not target main May 2, 2023
@AetherUnbound AetherUnbound changed the title Use default reviewer count for PRs that do not target main Skip reminders for PRs that do not target main May 2, 2023
@sarayourfriend sarayourfriend changed the title Skip reminders for PRs that do not target main Fall back to main branch protection rules for PRs targeting branches without protection rules May 2, 2023
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and makes sense to me!

@sarayourfriend sarayourfriend merged commit 2710483 into main May 2, 2023
@sarayourfriend sarayourfriend deleted the add/ignore-non-main-target-prs branch May 2, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

PR review reminders DAG does not handle base branches other than main
4 participants