Repository navigation
Proposal: relax PR merge rules, enforce them via CI - #5512
Conversation
| * one LGTM from a maintainer, if it is a routine change; or | ||
| * one LGTM from another maintainer, if the author is a maintainer, the pull | ||
| request is not a governance change, and it has been open for review (that | ||
| is, not a draft) for at least 7 days. This gives other maintainers a chance |
There was a problem hiding this comment.
A large PR (e.g., > 100 lines) should require a longer period?
There was a problem hiding this comment.
What do you have in mind? A month?
Also, a maintainer can submit require changes and just ask for more time.
There was a problem hiding this comment.
I looked at the sizes of last 50 PRs (both opened and merged), to check lines added + removed, excluding vendor/, here's what I got:
Lines (except vendor/) |
Last 50 merged PRs | Last 50 open PRs |
|---|---|---|
| ≤ 20 | 33 | 7 |
| 21–100 | 12 | 18 |
| 101–300 | 4 | 15 |
| > 300 | 1 | 10 |
| median | 11 | ~100 |
So small PRs get merged, and it's the large ones that get stuck. That's exactly where a longer review period makes sense. So your threshold of 100 lines affects only 10% of what we merge, but half of what's waiting, and it seems right to me.
I've added this: a maintainer's PR with one LGTM can be merged after 14 days instead of 7 if it has more than 100 lines changed (not counting vendor/).
NOTE tests are counted. Let me know if you think they shouldn't be.
3d3832f to
f6467f7
Compare
|
I agree with the idea. It's EOD here now, I'd like my AI friend to take a closer look tomorrow.
Let's remove their access. Nothing good can come out of that, right? We can always give access to people that need it. But I guess we need to ask some LF people to do that? |
Yes, one needs to be an org admin to do that. I can only file a bug in the org: opencontainers/tob#160 |
rata
left a comment
There was a problem hiding this comment.
Left a few minor comments. Thanks a lot for proposing this and automating it!
f6467f7 to
87a92c5
Compare
87a92c5 to
4b28eac
Compare
|
@rata thanks for the detailed review -- I think I've addressed all the comments, PTAL. @opencontainers/runc-maintainers PTAL, this is an important process change. |
rata
left a comment
There was a problem hiding this comment.
LGTM, thanks!
I'd add a few more comments to make sure all the precautions to keep this safe (never run from the PR branch, etc.) are not lifted by mistake
|
In general, I'm in favor of relaxing the approval requirements (as enforced by branch protection rules). I think it's reasonable to enforce a single approval, and leave it to the maintainers' discretion to decide if additional reviews are needed. Someone who was given maintainer status was given that status based on trust, which (IMO) includes the trust to decide whether a change has risk, and because of that requires more eyes (which can be a review of a specific person / domain expert, or more review than enforced). At times, I wish GitHub reviews were not a "binary" approval; there's been many pull requests (across projects) where I'm not a domain expert, and my review / approval may be "best judgement". GitHub doesn't really have mechanisms to communicate that, beyond writing it in words ( Requiring two (or "majority") approvals for governance or policy changes makes sense. I'm not sure if the LOC and waiting period complexity is needed; in my experience, a single-line change can be just as risky (or riskier) than a large change; they sometimes are more risky because they may appear innocuous, so get merged without verifying the impact 😂 That said; I wouldn't mind some "nag" automation to ping maintainers for a (second) review. My notification inbox tends to fill up pretty fast, so "review requested" PRs may end up at page 2 or 3 of my notifications within a day. |
So this is not about the risk but about the complexity of doing a review. We assume that changes with smaller LOC require less maintainer's time to be reviewed, and big PRs with more LOC changed call for more review time. While this is not always the case, usually it is. So we (rather arbitrarily) divide all PRs into two categories, big and small, and set the rule that big PRs need more time to review than the small ones. It's not perfect but there is no way to have it perfect (in a perfect world you wake up and all your PRs from yesterday are reviewed by all other maintainers). The other thing is, small PRs gets merged and larger ones gets stuck (see some statistics at #5512 (comment)). The two-week "deadline" is here to help with that.
I use |
4b28eac to
85b39ca
Compare
85b39ca to
b83e951
Compare
|
@thaJeztah also, if you agree with this in principle, please LGTM (we can address pinging and nagging in a followup) |
lifubang
left a comment
There was a problem hiding this comment.
LGTM
I totally agree. My apologies, I just returned from a long holiday and have fallen behind on a lot of work. I will make time to catch up. Besides, another factor affecting reviews is that PRs are getting bigger and harder to review. We really need an AI assistant to make reviews manageable.
We have copilot here but I don't like it much. I will look for alternatives. |
My experience with using Opus and Fable for reviews (and seeing how systemd has done with their new Claude-powered review system) is that they do tend to find annoying mistakes quite well but I don't think they are any good at making higher-level decisions or catching non-obvious flaws. Yeah, people say you can write skills to improve their behaviour but I still find them severely lacking and still review the code (meaning the workload hasn't really gone down as much). By the way, we can all get access to the open source maintainer programs from OpenAI and Anthropic. |
|
We have 5 out of 7 LGTMs from maintainers (me included), so I'm going to merge this tomorrow. If there are any changes or additions needed, we can always address those in followup PRs. |
cyphar
left a comment
There was a problem hiding this comment.
I'm not sure that encoding this as a CI job is really that necessary and pull_request_target gives me the willies, but on the whole I'm fine with this.
@kolyshkin has been doing a lot of work recently and a few maintainers (myself included) being very busy for the past year isn't really a great reason to excessively slow down that work.
|
But yeah to be honest my GitHub notifications are basically unmanageable at this stage -- I would probably need to spend a week doing nothing but reviews to clear everything and I unfortunately can't carve out that much time. I feel quite awful about being such an absentee maintainer recently... It would be really nice if there was a way to tag a PR as "important" when pinging so I could just look at those with the little time I have but no such luck on GitHub. :/ |
+1 |
Agreed on this part. @kolyshkin - wondering if we should/could keep the CI scope more minimal? Could we use (e.g.) a
+1 I unfortunately also get a ton of "code-owner" review requests (internal policies requiring them); many of which don't actually need my attention (but still make my notifications run at the speed of light).
Perhaps labels (or custom properties) could help for this 🤔 also might be worth looking if GitHub has thoughts on improvements in this area 🤔 |
Many pull requests stay open for weeks waiting for a second review, which slows down development considerably. Spell out the merge rules, and relax them for maintainers: a pull request authored by a maintainer can be merged with a single LGTM from another maintainer, provided it has been open for review for at least 7 days (14 days for large changes, i.e. more than 100 lines not counting vendor/), so that other maintainers had a chance to object. Also, allow routine pull requests (opened by Dependabot, or only changing documentation and/or CI configuration) to be merged with a single LGTM. Neither of the above applies to governance changes, i.e. changes to the project rules (such as this document) or their enforcement, which always require two LGTMs. While at it, clarify that: - an LGTM is a pull request approval; - the author's own LGTM does not count; - a maintainer requesting changes blocks the merge. Signed-off-by: Kir Kolyshkin <[email protected]>
b83e951 to
80166e1
Compare
|
@cyphar @thaJeztah Reworked the check per your concerns. It now fails a CI job. Upside is Downside is is requires more from maintainers. First, once the review period is over, if it's still one LGTM, a maintainer who wants to merge the PR need to re-run it. Second, the check's own code is run from a PR, so any PR can change its code (that's the price for being unpriviledged). Hope it addresses all concerns. Will merge tomorrow. |
Add a check enforcing the pull request merge rules from MAINTAINERS_GUIDE.md, to be used as a required status check (in addition to the GitHub's required number of approvals, which can not depend on who the author is, and also counts approvals from anyone having write access, not just from current maintainers). The check is a pull_request_review workflow with a read-only token, which evaluates the current state of the pull request using the GitHub API. No other triggers are used, since branch protection requires the latest run for each event type to pass, so a failed run triggered by, say, a push would keep blocking the merge after a review fixes it. As a result, the check needs a review (a comment-only one is fine) to be run after a push, and it needs to be re-run manually once a review period is over. Note that since the workflow runs from the pull request, a pull request can change it. This is the price for not using privileged triggers (pull_request_target or workflow_run) and write permissions. To mitigate, the workflow is a governance file (so changing it requires two LGTMs), and GitHub's own required approval stays as a backstop. Signed-off-by: Kir Kolyshkin <[email protected]>
80166e1 to
97d719f
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
The added review-policy check is triggered by any review comment. Three ways to add a review comment:
- Submit a review (Comment / Approve / Request changes);
- Comment on a specific line(s) of code;
- Reply to a comment on a specific line(s) of code.
Done, and tested on #5553 that it works as expected. |
|
Also checked in #5547, see #5547 (comment) |
|
well the biggest downside of read-only approach is we always have red CI (unless we have two LGTMs), so it's indistinguishable from real CI failures when looking at the list of PRs. |
Add a check enforcing the pull request merge rules from MAINTAINERS_GUIDE.md, to be used as a required status check (in addition to the GitHub's required number of approvals, which can not depend on who the author is, and also counts approvals from anyone having write access, not just from current maintainers). The check is a pull_request_review workflow with a read-only token, which evaluates the current state of the pull request using the GitHub API. No other triggers are used, since branch protection requires the latest run for each event type to pass, so a failed run triggered by, say, a push would keep blocking the merge after a review fixes it. As a result, the check needs a review (a comment-only one is fine) to be run after a push, and it needs to be re-run manually once a review period is over. Note that since the workflow runs from the pull request, a pull request can change it. This is the price for not using privileged triggers (pull_request_target or workflow_run) and write permissions. To mitigate, the workflow is a governance file (so changing it requires two LGTMs), and GitHub's own required approval stays as a backstop. The check itself is the runc one (see opencontainers/runc#5512), used as a reusable workflow (made so in opencontainers/runc#5573), pinned to a commit. Dependabot is told not to bump it, since a bump may change the rules, so it should be a deliberate (and governance) change. Signed-off-by: Kir Kolyshkin <[email protected]>
Many pull requests stay open for weeks waiting for a second review, which slows down development considerably. Spell out the merge rules, and relax them for maintainers: a pull request authored by a maintainer can be merged with a single LGTM from another maintainer, provided it has been open for review for at least 7 days (14 days for large changes, i.e. more than 100 lines), so that other maintainers had a chance to object. Also, allow routine pull requests (opened by Dependabot, or only changing documentation and/or CI configuration) to be merged with a single LGTM. Neither of the above applies to governance changes, i.e. changes to the project rules (such as this document) or their enforcement, which always require two LGTMs. While at it, clarify that: - an LGTM is a pull request approval; - a maintainer requesting changes blocks the merge. This is the same as done in runc (see opencontainers/runc#5512). Signed-off-by: Kir Kolyshkin <[email protected]>
Add a check enforcing the pull request merge rules from MAINTAINERS_GUIDE.md, to be used as a required status check (in addition to the GitHub's required number of approvals, which can not depend on who the author is, and also counts approvals from anyone having write access, not just from current maintainers). The check is a pull_request_review workflow with a read-only token, which evaluates the current state of the pull request using the GitHub API. No other triggers are used, since branch protection requires the latest run for each event type to pass, so a failed run triggered by, say, a push would keep blocking the merge after a review fixes it. As a result, the check needs a review (a comment-only one is fine) to be run after a push, and it needs to be re-run manually once a review period is over. Note that since the workflow runs from the pull request, a pull request can change it. This is the price for not using privileged triggers (pull_request_target or workflow_run) and write permissions. To mitigate, the workflow is a governance file (so changing it requires two LGTMs), and GitHub's own required approval stays as a backstop. The check itself is the runc one (see opencontainers/runc#5512), used as a reusable workflow (made so in opencontainers/runc#5573), pinned to a commit. Dependabot is told not to bump it, since a bump may change the rules, so it should be a deliberate (and governance) change. Signed-off-by: Kir Kolyshkin <[email protected]>
This is a proposal. Maintainers, please share your opinion (or LGTM, if you agree).
Problem
We have quite a few maintainers, but most of us are busy with other things, so
reviews are scarce. As a result, many pull requests stay open for weeks or
months waiting for two LGTMs, which slows down the development a lot
(or requires a lot of pinging).
Proposal
Relax the merge rules (see the
MAINTAINERS_GUIDE.mdchange for exact wording).A pull request can be merged once it has:
changing documentation and/or CI configuration; or
pull request has been open for review (not a draft) for at least 7 days
(14 days if it changes more than 100 lines, not counting
vendor/),giving other maintainers a chance to review and object.
Governance changes (
MAINTAINERS, top-level*.mdfiles other thanREADME.mdandCHANGELOG.md, and thereview-policyworkflow) alwaysrequire two LGTMs.
In all cases, a maintainer requesting changes blocks the merge.
The guide also clarifies a few things which are current practice but are not
written down: an LGTM is a PR approval, and the author's own LGTM is not counted.
Enforcement
GitHub can't require a different number of approvals depending on who the
author is, or what files are changed. So the second commit adds a
review-policycheck which evaluates the above rules.Update: following the concerns about
pull_request_target, the check wasrewritten to be as unprivileged as possible. It is now a single
pull_request_reviewworkflow with a read-only token (contents: read,pull-requests: read), which evaluates the current state of the PR via theGitHub API, and passes or fails accordingly. No
pull_request_target, noworkflow_run, noschedule, no write permissions, no secrets, no checkout.Using
pull_request_reviewas the only trigger is deliberate. I tested it onmy fork, and found that branch protection requires the latest run for each
event type to pass, so if the check also ran on
pull_request, a failed runfrom a push (say, "needs an LGTM") would keep blocking the merge even after a
review fixes it. The consequences are:
until a review is submitted; a comment-only review is fine, and the author
can submit it, too (e.g. "rebased");
manually once the period is over.
The price for being unprivileged is that, like any
pull_request_reviewworkflow, the check runs from the PR itself, so a PR can modify it. To
mitigate, the workflow is a governance file (so changing it requires two
LGTMs), and GitHub's own required approval stays as a backstop.
A nice side effect is that only approvals from current
MAINTAINERSarecounted. Currently GitHub also counts approvals from anyone with write access,
which includes a few emeritus maintainers (being fixed in
opencontainers/tob#160).
After merging
A repo admin needs to update the
mainbranch protection:review-policy(from GitHub Actions) as a required status check.Once the check is required, open PRs won't have it until someone reviews
them (a comment-only review is enough).
Note that since
enforce_adminsis currently disabled, and all maintainersare repo admins, any of us can still merge bypassing the rules. Whether to
change that is a separate discussion.
cc @mrunalp @cyphar @AkihiroSuda @thaJeztah @lifubang @rata