From efe7aa1f784ad10f1821091d201759b20ac1611f Mon Sep 17 00:00:00 2001 From: vilmibm Date: Tue, 13 Apr 2021 22:03:59 -0500 Subject: [PATCH] fix small bug with startup_failure conclusion --- pkg/cmd/run/view/view.go | 2 +- pkg/cmd/run/view/view_test.go | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/run/view/view.go b/pkg/cmd/run/view/view.go index 9751d1f38..5bed0f7f1 100644 --- a/pkg/cmd/run/view/view.go +++ b/pkg/cmd/run/view/view.go @@ -308,7 +308,7 @@ func runView(opts *ViewOptions) error { fmt.Fprintln(out, shared.RenderRunHeader(cs, *run, utils.FuzzyAgo(ago), prNumber)) fmt.Fprintln(out) - if len(jobs) == 0 && run.Conclusion == shared.Failure { + if len(jobs) == 0 && run.Conclusion == shared.Failure || run.Conclusion == shared.StartupFailure { fmt.Fprintf(out, "%s %s\n", cs.FailureIcon(), cs.Bold("This run likely failed because of a workflow file issue.")) diff --git a/pkg/cmd/run/view/view_test.go b/pkg/cmd/run/view/view_test.go index 355ac3c68..8ddde1cd0 100644 --- a/pkg/cmd/run/view/view_test.go +++ b/pkg/cmd/run/view/view_test.go @@ -771,6 +771,44 @@ func TestViewRun(t *testing.T) { browsedURL: "jobs/10?check_suite_focus=true", wantOut: "Opening jobs/10 in your browser.\n", }, + { + name: "hide job header, failure", + tty: true, + opts: &ViewOptions{ + RunID: "123", + }, + httpStubs: func(reg *httpmock.Registry) { + reg.Register( + httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123"), + httpmock.JSONResponse(shared.TestRun("failed no job", 123, shared.Completed, shared.Failure))) + reg.Register( + httpmock.REST("GET", "runs/123/jobs"), + httpmock.JSONResponse(shared.JobsPayload{Jobs: []shared.Job{}})) + reg.Register( + httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123/artifacts"), + httpmock.StringResponse(`{}`)) + }, + wantOut: "\nX trunk failed no job · 123\nTriggered via push about 59 minutes ago\n\nX This run likely failed because of a workflow file issue.\n\nFor more information, see: runs/123\n", + }, + { + name: "hide job header, startup_failure", + tty: true, + opts: &ViewOptions{ + RunID: "123", + }, + httpStubs: func(reg *httpmock.Registry) { + reg.Register( + httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123"), + httpmock.JSONResponse(shared.TestRun("failed no job", 123, shared.Completed, shared.StartupFailure))) + reg.Register( + httpmock.REST("GET", "runs/123/jobs"), + httpmock.JSONResponse(shared.JobsPayload{Jobs: []shared.Job{}})) + reg.Register( + httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/123/artifacts"), + httpmock.StringResponse(`{}`)) + }, + wantOut: "\nX trunk failed no job · 123\nTriggered via push about 59 minutes ago\n\nX This run likely failed because of a workflow file issue.\n\nFor more information, see: runs/123\n", + }, } for _, tt := range tests {