-
Notifications
You must be signed in to change notification settings - Fork 115
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
Inconsistent naming of Github Status Check related predicates #921
Comments
The naming of the We combined the predicates because for the average user, the distinction between commit statuses and checks is not very obvious and is usually not relevant. While the API makes this distinction, the pull request UI combines these in to a single element and they all need to have a neutral or positive conclusion for the pull request to be "green" and look like everything is good. When we added
Could you expand on this, maybe with an example of the specific problem you are trying to solve? I don't think I've encountered this before. Usually knowing the conclusion of the check or workflow is sufficient |
@bluekeyes Ah understandable i did not know github also evolved the naming of their features there over time. Given one has many many github action workflows lets say 50. They all run conditionally based on path filters e.g.
I now want to require that workflow to be successful for Pull Requests in case it was triggered(due to files in the PR are matching the path filters). In case it is not triggered(PR does not change something within those path filters), i also dont want to require it as i want to handle it similar as the In the discussion solutions arise like creating a workflow that checks that all others finished - which i want to avoid since it blocks compute capacity for the time the longest workflow/job takes to finish.
And that works perfectly when the policybot changed_file predicates logic exaclty matches the workflows path filte logic. However it duplicates the logic of the running condition in an expensive/error prone way. While github actions uses file globs in policybot one uses regex. The conversion(getting the same behaviour right) has turned out to be quite error prone. Also writing/maintaining that logic is quite time consuming for 50+ workflows. So i also tried out different methods to use the has_workflow_result predicate.
What i could imagine would work out enforcing such roules would be e.g. having a timeout for the predicate somehow
Or e.g. having a predicate that can be put into the if condition to check for the existence of a run and enforce conclusions
What do you tink, is this something already possible and i oversee some predicate/usage here or does it make sense to add support for this in one or the other way ? |
Supporting this workflow is tricky because it's difficult to know for sure if a status will appear without encoding the same conditions (like the modified file paths) in the policy. If a status is not present at the moment we evaluate the pull request, does that mean it will never appear or does it only mean that GitHub hasn't started running the workflow yet? In the current architecture, anything based around a timeout is not really feasible because Policy Bot only responds to events from GitHub. Without maintaining internal state, we can't easily tell when to "wake up" and evaluate a policy again. In a previous comment on a different issue, I suggested a policy that might work here. It enforces the condition that if a check conclusion is present, it must be Supporting pending / incomplete checks might be possible. We discussed this a bit on a previous PR and decided to restrict the check to completed checks only as an optimization. Handling every status event can generate a lot of extra work, so any changes here would have to be extra careful about performance. Limiting this to the |
Ah understandable, i wasn't sure when the policies are evaluated by the raw code. But it being event driven and stateless makes this really difficult to implement indeed. Status checks usually are not there from the very beginning and this could very well lead to a rule acceptance even if it takes several seconds to start a check. When the predicates would considder the state(which they already have in the response of the github api) i think this could cover the scenario like you proposed in your comment in issue #760 without jobs in progress counting as successfull rules.
Which would already be enough to implement a predicate that works in the The sole thing that is not covered is e.g. on a webhook event |
My performance concern with pending statuses is that while we already receive the necessary webhooks, the handlers currently exit immediately if the status is not for a completed run (there's a similar condition for traditional commit statuses.) If the policy does not use pending statuses, I'd like to avoid all of the API calls required to run a full policy evaluation. This especially important when dealing with integrations that post multiple pending statuses to provide progress updates. There are probably ways to solve this (see for instance the existing idea of triggers that skips evaluating events when it is known that the policy will not change), but it makes the implementation more involved. One option that might work and be easier to add is to not evaluate the policy on pending events, but to still consider pending statuses when evaluating based on other events. Basically, if a pending status appears in a rule's predicates, mark the rule as pending rather than skipped. I'd have to think about if this would have other consequences. I'd like to also avoid sleeping if possible since it increases the latency from making a change in GitHub to receiving feedback from Policy Bot. It's also hard to get this value right - 10s is probably too much in most cases, leading to extra waiting, but there may still be cases where it wasn't enough. What if we allowed matching (completed) statuses/workflows by pattern? I think this would allow you to add a rule like this: - name: has workflow results
requires:
condition:
has_workflow_result:
conclusions: ["success", "skipped"]
workflow_patterns:
- "\\.github/workflows/.*" This would block approval until at least one workflow finished, without caring about which one. You'd then combine it in an You could also look at #853 (glob support), which doesn't directly help, but might make it easier to keep the file paths synchronized between your workflows and Policy Bot. In the end though, it's unfortunate that GitHub doesn't support requiring conditional workflows natively. Policy Bot really wasn't built to handle this and is still primarily focused on code review usage, which is why all of the solutions feel like hacks. |
According to how github names their functionality according to their doc
The current predicates:
do not really fit into the naming from github.
For github there are
checks
which have an attribute calledstatus
that can have multiple values. In case thestatus
value iscompleted
, acheck
has an additional attribute calledconclusion
which gives more information over the termination reason.So i would see some config similar to following example be more understandable as it uses the same terminology and hierarchy.
Which would i suppose result in the same, current behaviour yet giving a lot more options.
It would btw also allow to put a
has_check
predicate into theif condition
of a policybot rule allowing e.g. to enforce a rule if acheck
exists with anystate
even when not having a conclusion yet and skipping it if there is no check at all by the if condition of a rule.I currently am fiddling around tying to implement support for that scenario where i want to require a check/workflow having certain conclusions but only if the check/workflow actually was triggered/created and im struggling to add this into the current naming schema of
has_workflow_results
as well ashas_status
.Whats the opinions regarding the naming of these predicates ?
The text was updated successfully, but these errors were encountered: