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

Skip to content

[gh run watch] Support --compact flag #10629

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

iamazeem
Copy link
Contributor

Fixes #4535.

Introduce --compact flag for gh run watch to show only one step:

  • if the job is running, the current in-progress step, or
  • if the job is complete with error(s), the first failing step, or
  • if the job is complete without error(s), the last successful step.

Tests

bin/gh run watch --help

Output
$ bin/gh run watch --help
Watch a run until it completes, showing its progress.

By default, all the steps are shown with each refresh.
Use `--compact` to show the current step only.
For a successfully completed job, the last step is shown.
For a failed job, the first step that failed is shown.

This command does not support authenticating via fine grained PATs
as it is not currently possible to create a PAT with the `checks:read` permission.


USAGE
  gh run watch <run-id> [flags]

FLAGS
      --compact        Show the current step only
      --exit-status    Exit with non-zero status if run fails
  -i, --interval int   Refresh interval in seconds (default 3)

INHERITED FLAGS
      --help                     Show help for command
  -R, --repo [HOST/]OWNER/REPO   Select another repository using the [HOST/]OWNER/REPO format

EXAMPLES
  # Watch a run until it's done
  $ gh run watch
  
  # Run some other command when the run is finished
  $ gh run watch && notify-send 'run is done!'
  
  # Watch a run until it's done, showing only the current step
  $ gh run watch --compact

LEARN MORE
  Use `gh <command> <subcommand> --help` for more information about a command.
  Read the manual at https://cli.github.com/manual
  Learn about exit codes using `gh help exit-codes`

bin/gh run watch --compact <RUN_ID>

$ bin/gh workflow run --repo iamazeem/test ci-matrix-jobs.yml
✓ Created workflow_dispatch event for ci-matrix-jobs.yml at main

To see runs for this workflow, try: gh run list --workflow=ci-matrix-jobs.yml

$ RUN_ID=$(bin/gh run list --repo iamazeem/test --workflow matrix_jobs --json databaseId --jq '.[0].databaseId')

$ bin/gh run watch --repo iamazeem/test --interval 1 "$RUN_ID" --compact
✓ main matrix_jobs · 13922234701
Triggered via workflow_dispatch about 1 minute ago

JOBS
✓ lint (macos-latest) in 18s (ID 38957971785)
  ✓ Complete job
✓ build (ubuntu-latest) in 17s (ID 38957971791)
  ✓ Complete job
✓ lint (ubuntu-latest) in 17s (ID 38957971794)
  ✓ Complete job
X lint (windows-latest) in 19s (ID 38957971802)
  X Step 2
✓ build (macos-latest) in 18s (ID 38957971808)
  ✓ Complete job
X build (windows-latest) in 23s (ID 38957971826)
  X Step 3
✓ publish (ubuntu-latest) in 18s (ID 38958001386)
  ✓ Complete job
✓ publish (macos-latest) in 18s (ID 38958001394)
  ✓ Complete job
X publish (windows-latest) in 14s (ID 38958001399)
  X Step 1

ANNOTATIONS
X Process completed with exit code 1.
lint (windows-latest): .github#9

X Process completed with exit code 1.
build (windows-latest): .github#9


✓ Run matrix_jobs (13922234701) completed with 'success'

Demo:

gh-run-watch-compact-demo

@iamazeem iamazeem requested a review from a team as a code owner March 18, 2025 11:44
@iamazeem iamazeem requested a review from BagToad March 18, 2025 11:44
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Mar 18, 2025
@BagToad BagToad force-pushed the 4535-gh-run-watch-compact-flag branch from 22e092a to 37690a7 Compare April 14, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external pull request originating outside of the CLI core team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: add a --compact flag to gh run watch
2 participants