palantir/policy-bot

Multiple teams and requires.count > 2 produces unintuitive result

aw185176 opened this issue · 1 comments

A rule like

- name: rule/1
  if:
    changed_files:
      paths:
      - .*
  requires:
    count: 2
    teams:
    - team/1
    - team/2

Will require at least one review from each team. Based on the README, we were under the impression this would define a rule where 2 reviews from any combo of those teams (2 team/2, 2 team/1, 1 team/1 1 team/2) would satisfy the predicate

Thanks for reporting this. Can you share any more details about the PR where you saw this behavior? It will be helpful to know who opened or contributed to the PR, who approved it, which teams they belonged to, and what Policy Bot reported as the status for the rule.

I ran a quick test with the latest version of Policy Bot, and this rule behaved as you expected and as the docs imply. I was able to approve my PR with two approvals from members of team/1, two approvals from members of team/2, or one approval from a member of team/1 and one approval from a member of team/2.

Some other factors that might influence the behavior:

  • The count property sets the number of unique users who must approve the rule. If userA is a member of both team/1 and team/2, their approval will only count once for this rule.
  • By default, Policy Bot does not count approvals from the PR author or contributors. You can use the allow_author, allow_contributor, and allow_non_author_contributor options to change this behavior.