Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cmd/release/shared/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var ReleaseFields = []string{
"id",
"isDraft",
"isPrerelease",
"isImmutable",
"name",
"publishedAt",
"tagName",
Expand All @@ -48,6 +49,7 @@ type Release struct {
Body string `json:"body"`
IsDraft bool `json:"draft"`
IsPrerelease bool `json:"prerelease"`
IsImmutable bool `json:"immutable"`
CreatedAt time.Time `json:"created_at"`
PublishedAt *time.Time `json:"published_at"`

Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/release/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func renderReleasePlain(w io.Writer, release *shared.Release) error {
fmt.Fprintf(w, "tag:\t%s\n", release.TagName)
fmt.Fprintf(w, "draft:\t%v\n", release.IsDraft)
fmt.Fprintf(w, "prerelease:\t%v\n", release.IsPrerelease)
fmt.Fprintf(w, "immutable:\t%v\n", release.IsImmutable)
fmt.Fprintf(w, "author:\t%s\n", release.Author.Login)
fmt.Fprintf(w, "created:\t%s\n", release.CreatedAt.Format(time.RFC3339))
if !release.IsDraft {
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/release/view/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestJSONFields(t *testing.T) {
"id",
"isDraft",
"isPrerelease",
"isImmutable",
"name",
"publishedAt",
"tagName",
Expand Down Expand Up @@ -196,6 +197,7 @@ func Test_viewRun(t *testing.T) {
tag: v1.2.3
draft: false
prerelease: false
immutable: true
author: MonaLisa
created: 2020-08-31T15:44:24+02:00
published: 2020-08-31T15:44:24+02:00
Expand All @@ -220,6 +222,7 @@ func Test_viewRun(t *testing.T) {
tag: v1.2.3
draft: false
prerelease: false
immutable: true
author: MonaLisa
created: 2020-08-31T15:44:24+02:00
published: 2020-08-31T15:44:24+02:00
Expand All @@ -244,6 +247,7 @@ func Test_viewRun(t *testing.T) {
shared.StubFetchRelease(t, fakeHTTP, "OWNER", "REPO", tt.opts.TagName, fmt.Sprintf(`{
"tag_name": "v1.2.3",
"draft": false,
"immutable": true,
"author": { "login": "MonaLisa" },
"body": "%[2]s",
"created_at": "%[1]s",
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/run/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ func IsFailureState(c Conclusion) bool {
}
}

func IsSkipped(c Conclusion) bool {
return c == Skipped
}

type RunsPayload struct {
TotalCount int `json:"total_count"`
WorkflowRuns []Run `json:"workflow_runs"`
Expand Down
12 changes: 12 additions & 0 deletions pkg/cmd/run/shared/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ var LegacySuccessfulJobWithoutStepLogs Job = Job{
},
}

var SkippedJob Job = Job{
ID: 13,
Status: Completed,
Conclusion: Skipped,
Name: "cool job",
StartedAt: TestRunStartTime,
CompletedAt: TestRunStartTime,
URL: "https://github.com/jobs/13",
RunID: 3,
Steps: []Step{},
}

var FailedJob Job = Job{
ID: 20,
Status: Completed,
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/run/view/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func populateLogSegments(httpClient *http.Client, repo ghrepo.Interface, jobs []

apiLogFetcherCount := 0
for _, job := range jobs {
if shared.IsSkipped(job.Conclusion) {
continue
}

if onlyFailed && !shared.IsFailureState(job.Conclusion) {
continue
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/cmd/run/view/view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2254,6 +2254,29 @@ func TestViewRun(t *testing.T) {
wantErr: true,
errMsg: "job 20 is still in progress; logs will be available when it is complete",
},
{
name: "job log but job is skipped",
tty: false,
opts: &ViewOptions{
JobID: "13",
Log: true,
},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/jobs/13"),
httpmock.JSONResponse(shared.SkippedJob))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/3"),
httpmock.JSONResponse(shared.SuccessfulRun))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/3/logs"),
httpmock.BinaryResponse(emptyZipArchive))
reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
httpmock.JSONResponse(shared.TestWorkflow))
},
wantOut: "",
},
{
name: "noninteractive with job",
opts: &ViewOptions{
Expand Down
Loading