Many users try to use Policy Bot as a general purpose rule engine, constructing policies that enforce things about status checks, labels, and other conditions. This was poorly supported because predicates skip rules when the conditions don't match, whereas users working in this model expect the rule to apply, but remain in the pending state.
This commit introduces the concept of "conditions", which are predicates that count toward approval. All of the existing predicates tests are available, but when used as a condition they control whether the rule is pending or approved, instead of active or skipped.
Conditions can combine with regular approval requirements, but I expect most uses will either use predicates and regular approval or conditions without additional approval.
Due to limitations in how predicates work internally, the details UI shows limited information about conditions. I hope to fix this in a follow-up, but I wanted to separate the main change from the predicate refactoring.
Finally, this adds a new README section explaining how to design a policy and what all the different terms mean.
I'm open to a different name for this new feature, since it's easy to accidentally say "condition" when talking about predicates, but I couldn't think of anything else that fit better.
This is an alternative to #750, which only works for status checks. See also #627.
Many users try to use Policy Bot as a general purpose rule engine, constructing policies that enforce things about status checks, labels, and other conditions. This was poorly supported because predicates skip rules when the conditions don't match, whereas users working in this model expect the rule to apply, but remain in the pending state.
This commit introduces the concept of "conditions", which are predicates that count toward approval. All of the existing predicates tests are available, but when used as a condition they control whether the rule is pending or approved, instead of active or skipped.
Conditions can combine with regular approval requirements, but I expect most uses will either use predicates and regular approval or conditions without additional approval.
Due to limitations in how predicates work internally, the details UI shows limited information about conditions. I hope to fix this in a follow-up, but I wanted to separate the main change from the predicate refactoring.
Finally, this adds a new README section explaining how to design a policy and what all the different terms mean.
I'm open to a different name for this new feature, since it's easy to accidentally say "condition" when talking about predicates, but I couldn't think of anything else that fit better.
This is an alternative to #750, which only works for status checks. See also #627.