Merge pull request #12679 from cli/wm-run-view-exit-status-not-respected

Respect `--exit-status` with `--log` and `--log-failed` in `run view`
This commit is contained in:
William Martin 2026-02-13 19:40:48 +01:00 committed by GitHub
commit 4e76bb0f47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 1 deletions

View file

@ -331,7 +331,14 @@ func runView(opts *ViewOptions) error {
return err
}
return displayLogSegments(opts.IO.Out, segments)
if err := displayLogSegments(opts.IO.Out, segments); err != nil {
return err
}
if opts.ExitStatus && shared.IsFailureState(run.Conclusion) {
return cmdutil.SilentError
}
return nil
}
prNumber := ""

View file

@ -1048,6 +1048,64 @@ func TestViewRun(t *testing.T) {
},
wantOut: quuxTheBarfLogOutput,
},
{
name: "exit status respected with log-failed, failed run",
opts: &ViewOptions{
RunID: "1234",
LogFailed: true,
ExitStatus: true,
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
httpmock.JSONResponse(shared.FailedRun))
reg.Register(
httpmock.REST("GET", "runs/1234/jobs"),
httpmock.JSONResponse(shared.JobsPayload{
Jobs: []shared.Job{
shared.SuccessfulJob,
shared.FailedJob,
},
}))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234/logs"),
httpmock.BinaryResponse(zipArchive))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
httpmock.JSONResponse(shared.TestWorkflow))
},
wantOut: quuxTheBarfLogOutput,
wantErr: true,
},
{
name: "exit status respected with log, failed run",
opts: &ViewOptions{
RunID: "1234",
Log: true,
ExitStatus: true,
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
httpmock.JSONResponse(shared.FailedRun))
reg.Register(
httpmock.REST("GET", "runs/1234/jobs"),
httpmock.JSONResponse(shared.JobsPayload{
Jobs: []shared.Job{
shared.SuccessfulJob,
shared.FailedJob,
},
}))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234/logs"),
httpmock.BinaryResponse(zipArchive))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
httpmock.JSONResponse(shared.TestWorkflow))
},
wantOut: expectedRunLogOutput,
wantErr: true,
},
{
name: "interactive with log, with no step logs available (#10551)",
tty: true,