Repository navigation
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
| # from forks it only gets a read-only token (see review-policy-trigger.yml); | ||
| # - schedule: re-evaluate all open pull requests. This is mostly for the | ||
| # time-based rule, but it also catches up with MAINTAINERS changes, missed | ||
| # events, and pull requests opened before this workflow was added. |
There was a problem hiding this comment.
I'd add very explictely what to avoid also, as it was not obvious to me:
# When changing this workflow, do NOT:
# - add pull_request, pull_request_review or pull_request_review_comment triggers: those run the pull request's copy of this file;
# - add actions/checkout, or run anything from a checked out tree;
# - read repository files with a ref other than the default branch;
| const largeDays = 14; | ||
| const largeLines = 100; | ||
|
|
||
| // MAINTAINERS lines look like "Name <email> (@login)". |
There was a problem hiding this comment.
I'd add something like:
// XXX: Always get this from the default branch, even for pull requests against
// release-* branches, so that there is a single source of truth.
| # commit status. | ||
| name: review-policy-trigger | ||
| on: | ||
| pull_request_review: |
There was a problem hiding this comment.
I'd add something like:
# XXX: We need to be careful here. This runs on `pull_request_review`, this file is
# run from the pull request's merge commit, so a pull request can change it.
# That is harmless only as long as it stays a no-op: no permissions, no
# secrets, no token use. review-policy.yml does the actual work from the
# default branch and only accepts this trigger for pull_request_review runs.
|
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
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 <kolyshkin@gmail.com>
Add a check enforcing the pull request merge rules from MAINTAINERS_GUIDE.md. The result is set as a "review-policy" commit status on the pull request head, to be used as a required status check (instead of 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 policy is evaluated when a pull request is opened, updated, or its draft status changes (pull_request_target), when a review is submitted or dismissed (pull_request_review, chained via workflow_run so that it works for pull requests from forks), and every 4 hours (schedule), which is needed for the time-based rule. Runs triggered by Dependabot are skipped, as they only get a read-only token; such pull requests are handled once reviewed, or by the scheduled run. The pull_request and pull_request_review triggers are not used directly as those run the workflow from the pull request itself, which means a pull request could change the policy it is checked against. The workflow never checks out the pull request code, so add a zizmor exception for the dangerous-triggers audit. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
85b39ca to
b83e951
Compare
|
@thaJeztah also, if you agree with this in principle, please LGTM (we can address pinging and nagging in a followup) |
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-policyworkflows) 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 and sets a commit statuson the PR head. It is designed so that a PR can't change the policy it is
checked against: it runs via
pull_request_target,workflow_run(forreviews), and
schedule(for the time-based rule), using the workflow andMAINTAINERSfrom the default branch, and never checks out the PR code.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.
I did a dry run of the policy script against all open PRs (with the API write
call stubbed out) and the results look right. The triggers themselves can only
be tested once this is in the default branch.
After merging
Once the check has set statuses on open PRs (it runs every 4 hours), a repo
admin needs to update the
mainbranch protection:review-policy(from GitHub Actions) as a required status check.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