Skip to content
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 allowing skipped checks in has_successful_status #789

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Commits on Jul 7, 2024

  1. Add utility functions to allow predicates to take lists of conclusions

    If a predicate has an `allowedConclusions` member, it will unmarshal
    from a list `["a", "b", "c"]` into a set, so that the handler can easily
    check if the incoming conclusion was allowed.
    iainlane committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    caba90e View commit details
    Browse the repository at this point in the history
  2. Add support for allowing skipped checks in has_successful_status

    The `has_successful_status` predicate currently requires predicates to
    be present and successful in order to pass. But workflows can be run
    conditionally - for example only if certain paths change - and it is
    currently not very convenient to write a policy which considers such
    skipped workflows as passing. The only feasible workaround is to
    duplicate the path filters in the policy, and this quickly gets unwieldy
    and prone to getting out-of-sync in large repositories.
    
    Here we add direct support for specifying such rules. This is done by
    introducing a new alernative form that `has_successful_status`
    predicates can take:
    
    ```yaml
    has_successful_status:
      options:
        skipped_is_success: true
      statuses:
        - "status 1"
        - "status 2"
    ```
    
    In this mode, we will consider the `skipped` result as acceptable. The
    current form:
    
    ```yaml
    has_successful_status:
      - "status 1"
      - "status 2"
    ```
    
    remains supported. We have done this by implementing a custom
    unmarshaling function to be able to handle both forms.
    
    Closes: palantir#760
    iainlane committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    a5acfbc View commit details
    Browse the repository at this point in the history
  3. Rework to expose has_status

    Implement `has_successful_status` in terms of `has_status` and deprecate
    it.
    
    This avoids us having two forms for one predidcate.
    
    An example would be
    
    ```yaml
    has_status:
      conclusions: ["success", "skipped"]
      statuses:
        - "status 1"
        - "status 2"
    ```
    iainlane committed Jul 7, 2024
    Configuration menu
    Copy the full SHA
    d96d2a0 View commit details
    Browse the repository at this point in the history

Commits on Jul 14, 2024

  1. Configuration menu
    Copy the full SHA
    2d9c41c View commit details
    Browse the repository at this point in the history
  2. README: Add back documentation fo has_successful_status

    Mark it as deprecated instead of removing it.
    iainlane committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    06ae646 View commit details
    Browse the repository at this point in the history
  3. Rearrange things to define HasSuccessfulStatus in terms of HasStatus

    This is more direct.
    
    We want to test `HasSuccessfulStatus` now, so jiggle the testsuite a bit
    to make that less repetitive by introducing a `StatusTestSuite` struct.
    iainlane committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    1793921 View commit details
    Browse the repository at this point in the history
  4. Eliminate the sets

    It's more code for not too much gain since we're only dealing with tiny
    slices and not really looking through them that often.
    iainlane committed Jul 14, 2024
    Configuration menu
    Copy the full SHA
    ebee532 View commit details
    Browse the repository at this point in the history