Skip to content

handle "no checks" races in pr checks --watch #7401

Closed as not planned
Closed as not planned

Description

@jmhodges-color

Describe the feature or problem you’d like to solve

After creating a PR, there's a time period where the GitHub API will say there are "no checks" for the PR and then, a few moments later, the checks will appear.

That means, if you gh pr create && gh pr checks --watch, sometimes pr checks --watch will error and return with exit code 1. (Specifically, the pr checks error text is no checks reported on the 'my-branch' branch)

Proposed solution

It would be nice for gh pr checks to either:

  1. Determine somehow that the GitHub PR check resolution is in an intermediate state and wait for it to finish before saying there's no checks. I'm not sure if this is possible in the GitHub API but it's plausible!
  2. Return a different exit code so that folks can tell if they could retry the pr checks call because they "know" there's checks on this pr.

(I have a strong preference for 1, of course)

Activity

  1. added
    enhancement
    on May 2, 2023
  2. added
    needs-triage
    on May 2, 2023
  3. changed the title [-]handle "no checks" case in `pr checks --watch`[/-] [+]handle "no checks" races in `pr checks --watch`[/+] on May 2, 2023
  4. samcoe commented on May 8, 2023

    @samcoe
    Contributor

    @jmhodges-color Thanks for writing in, as you surmised option 1 as is not possible with the GitHub API, it does return any indication that there are any checks scheduled to run.

    Option 2 I am not sure I understand. Generally the exit codes are for scriptability but pr checks --watch is a command that does not lend itself to be used in scripts IMO. Wouldn't it just be easier to do gh pr create && sleep 5 && gh pr checks --watch?

  5. added
    more-info-needed
    and removed
    needs-triage
    on May 8, 2023
  6. jmhodges-color commented on May 9, 2023

    @jmhodges-color
    Author

    @jmhodges-color Thanks for writing in, as you surmised option 1 as is not possible with the GitHub API, it does return any indication that there are any checks scheduled to run.

    Option 2 I am not sure I understand. Generally the exit codes are for scriptability but pr checks --watch is a command that does not lend itself to be used in scripts IMO. Wouldn't it just be easier to do gh pr create && sleep 5 && gh pr checks --watch?

    Yes but unfortunately that means anyone wanting to use the fact that the checks failed to do other things (emit a notification, exit with an error instead of marking the PR as ready) wouldn't be able to do those things. Retry works fine for when you know the failures are only the race but not when there can be real failures.

  7. samcoe commented on May 9, 2023

    @samcoe
    Contributor

    @jmhodges-color That is a fair point. In other list commands we explicitly output a 0 exit code when there are no results, would something like that work for your situation? I will bring this up with the team to discuss a bit further.

  8. added
    discuss
    and removed
    more-info-needed
    on May 9, 2023
  9. jmhodges-color commented on May 9, 2023

    @jmhodges-color
    Author

    @jmhodges-color That is a fair point. In other list commands we explicitly output a 0 exit code when there are no results, would something like that work for your situation? I will bring this up with the team to discuss a bit further.

    @samcoe oh, specifically a 0 exit code doesn't work, because that'd make "no checks" the same as the "all checks passed" exit code. So, you'd mark PRs as ready or whatever when really it was just that you'd raced the API.

    Tangentially, if there's a place for non-GitHub folks to post issues against the API, I'm happy to be an external request to add some kind of status field to checkable objects that the API uses to tell clients when it's not sure the checkable object has checks, yet

  10. samcoe commented on May 10, 2023

    @samcoe
    Contributor

    @jmhodges-color Usually we direct people to here to leave feedback/bug reports/feature requests for the overall platform.

  11. jmhodges-color commented on May 26, 2023

    @jmhodges-color
    Author

    Oh, additional thing: capturing the output of --watch means you lose the nice progressively updating terminal output (without some trickery). So, it'd be nice to not have to grep the output.

  12. vilmibm commented on Jul 17, 2023

    @vilmibm
    Contributor

    I don't think we can be super helpful here given the API limitations so I'm going to close this after today's planning discussion

  13. 2 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions