Enable status/workflow predicates for use in if condition #922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change is a proposal for the use-cases described in #921
It introduces new predicates
status_check
andworkflow
that compared to the currently existingstatus
andworkflow
introduce the capability to specify resources by regular expression as well as defining the desiredstatus
workflows and status_checks should be in. Additionally the changes in naming of the GitHub documentation(1,2) is applied to these new predicates.Also a status and conclusion
any
is introduced that will populate the statuses/conclusions with all possible values.This now allows for more scenarios where a status check or workflow may be required in a rule but only if it exists.
Hereby the rule
All started workflow concluded(at least one)
makes sure all started workflows finished but at least one workflow needs to complete to fullfill the rule. This is to ensure the rules all does not get approved before all workflows are properly created in the api and can be used for rule evaluation. This assumes that it is "unlikely" for a workflow to be scheduled by github actions after a workflow completely finished timing wise.The rule
Test Dependencies
requires the workflowtest-dependencies.yml
(attention regex so this will match alsorandom-test-dependencies.yml
) to be present with any status or conclusion and if so it must finish with conclusionsuccess
orskipped
. The usual regex escape mechanism can be applied here.This allows now to require certain status checks, repo statuses and workflows to be in a certain state/conclusion if they exist at all, wich with the current predicates is not possible to cover efficiently. Currenlty the only workaround is to define the running condition twice with
only_changed_files
predicate which does not work reliably with good user experience. Also for status checks it might not be able to mimic the running condition in policy-bot of arbitrary statuses that could possibly have complex logic when they appear and when not.Hereby the predicates
has_workflow_result
,has_status
andhas_successful_status
remain identical and are just marked as deprecated. Internally they also use the meta predicatehas_status_check
andhas_workflow
so no code duplication exists.