Skip to content

Also count reviews required by org-level rulesets - #106

Merged
rafecolton merged 3 commits into
mainfrom
rory/668528-ruleset-required-reviews
Sep 12, 2026
Merged

rafecolton merged 3 commits into
mainfrom
rory/668528-ruleset-required-reviews

Conversation

@roryabraham

@roryabraham roryabraham commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Details

getRequiredApprovingReviewCount (used by verifyPeerReview to decide how many independent approvals a PR needs before it can merge) only read the review count from classic branchProtectionRule.requiredApprovingReviewCount. It never checked reviews required by org-level (or repo-level) Rulesets, so a repo/branch that enforces its review requirement exclusively through a Ruleset was treated as requiring 0 approving reviews, letting the peer-review check pass with no review at all.

Note that this a hypothetical problem for now. I'm not aware of any repos that rely on repo-level or org-level rulesets for requiring reviews rather than traditional branch protection.

Related Issues

$ https://github.com/Expensify/Expensify/issues/668528

Manual Tests

n/a - automated tests only.

Linked PRs

N/A

`getRequiredApprovingReviewCount` only read classic
`branchProtectionRule.requiredApprovingReviewCount`, so a repo that
enforces its review requirement via a repository- or org-level
Ruleset instead of (or in addition to) classic branch protection was
treated as requiring 0 approving reviews.

`Ref.rules` returns "a list of rules from active Repository and
Organization rulesets that apply to this ref", so query it alongside
`branchProtectionRule` and take the higher of the two required
counts - satisfying the higher requirement independently also
satisfies the lower one, so the two aren't summed. Only rules of type
`PULL_REQUEST` carry a review count; other rule types are skipped.

Request `pageInfo.hasNextPage` on the rules connection and fail loudly
if there are more than 100 active rules, rather than silently
under-counting rules past the first page.

Fixes Expensify/Expensify#668528
@roryabraham

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: a25b23b0c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@roryabraham

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@roryabraham
roryabraham marked this pull request as ready for review September 7, 2026 23:01

@rafecolton rafecolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Let's test on the test repo once it's merged?

@rafecolton
rafecolton merged commit bc348f0 into main Sep 12, 2026
9 of 10 checks passed
@rafecolton
rafecolton deleted the rory/668528-ruleset-required-reviews branch September 12, 2026 01:06
@rafecolton

Copy link
Copy Markdown
Member

Tested in https://github.com/Expensify/test/pull/1039 and tl;dr it worked great! 🎉

  1. First, the check failed because we had repo-level branch protection requiring 1 review.
  2. I set that to not require reviews, and the check passed:
    Screenshot 2026-09-11 at 6 11 19 PM
  3. Then I enabled review enforcement on an org ruleset and re-ran the check. It failed as expected:
    Screenshot 2026-09-11 at 6 13 00 PM

My only feedback is it might be handy to log whether the review rule was from a branch setting or ruleset (NAB)

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.

2 participants