-
Notifications
You must be signed in to change notification settings - Fork 103
-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Question] Is there a way to force rule checks? #462
Comments
Policy Bot has a limited ability to post failures on pull requests by using policy:
disapproval:
if:
title:
not_matches:
- "^[a-zA-Z]+:"
- "(\\[ENTPMTS-[0-9]+\\]\\s?)+$" For the most part, Policy Bot is currently meant to implement review policies rather than arbitrary policies about PR details like titles or labels. If you want to "enforce" conditions, the strategy is to make rules that auto-approve (as you've started to do) and then have some fallback rule that is impossible to satisfy (e.g. because it requires too many reviews or approval from users that don't exist.) Note that Policy Bot must have at least one rule that is not skipped for every PR. You'll also need to be careful with conditions. When a predicate is skipped because the condition is not true, the rule is removed from evaluation. In your example, the A policy like this might achieve what you want, but it can be kind of confusing: policy:
approval:
- or:
- Automated PR
- PR title is correct
- Other conditions are not met
approval_rules:
- name: Automated PR
if:
has_author_in:
users: ["codegenie[bot]", "whitesource[bot]"]
requires:
count: 0 # change this if you want to approve bot PRs
- name: PR title is correct
if:
title:
matches:
- "^[a-zA-Z]+:.*(\\[ENTPMTS-[0-9]+\\]\\s?)+$"
requires:
count: 0
- name: Other conditions are not met
description: You must meet one of the other conditions to approve this PR
requires:
count: 9999 # an arbitrary large number that is impractical |
thanks for the reply and suggestion! Not sure if it fits into the goals of policy-bot or is possible given the code, but would it be possible to:
Again, I'm new to policy bot so I apologize if this goes against the principals or is impossible to implement. |
If we were to implement something like this, I think one way to do it is to expand how disapproval works so that it can contain multiple rules and conditions, like approval policies. Disapproval rules probably would not have the concept of skipping, since it doesn't really make sense in that context. Another option is to introduce a third type of policy, maybe While your proposed To set expectations, we don't currently have plans to expand disapproval support or implement a condition policy, as it's not something that comes up often internally at Palantir. But I'm happy to iterate on a design and pull request if you or anyone else would like to try implementing it. |
I would like to evaluate multiple PR title requirements using policy-bot but not on autogenerated PRs.
For example:
As per the documentation, it is my understanding that only 1 of the AND block needs to be evaluate for the entire policy to pass.
All I just want to show the status check as failed saying "Failed the end of the PR Title Format" or "Failed the beginning of the PR Title Format". Is this possible?
The text was updated successfully, but these errors were encountered: