-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for approval conditions #752
Conversation
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 think this is a good solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty straightforward approach to including conditions.
I'm less certain about how we'd want to use this internally, but it seems like a relatively friendly feature to include for oss.
@@ -213,6 +221,11 @@ | |||
|
|||
{{define "result-reviews-count"}}This rule requires at least {{.Count}} approval{{if gt .Count 1}}s{{end}}{{end}} | |||
|
|||
{{define "result-conditions-details"}} | |||
{{/* TODO(bkeyes): this is a placeholder until I can refactor predicate rendering */}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this something you want to do in a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, trying to refactor the predicate display in this PR was going to overwhelm the actual changes.
If you are able to deploy snapshot versions, this feature is now available in the |
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.