Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pr checks returns failure code if there are no checks #9390

@mtfurlan

Description

@mtfurlan

Describe the bug

The help describes pr checks as

Show CI status for a single pull request.

From that description, I expect that it returns an error code if there are failed checks, maybe an error code if there are pending checks, and 0 for all checks successful.

I do not expect it to fail when there are no checks, because there is no negative CI status

gh version 2.53.0 (2024-07-17)

Steps to reproduce the behavior

  1. On a PR with no checks, run gh pr checks
  2. return code is 1

Expected vs actual behavior

return code of 0

Proposed solution

Document return codes in the help
Looks like

  • 8: pending checks
  • 0: all checks passed
  • 1: no checks
  • 1: failed check

Separate return code for no checks and failed check

It would be cool if no checks returned 0, but as long as I can separate it from failed checks without grep I'm okay

workaround

if (gh pr checks 2>&1 || true) | grep -qE "^All checks were successful|^no checks reported" ; then
    ...
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsgh-prrelating to the gh pr commandhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions