Merge pull request #11312 from cli/babakks/avoid-fetching-logs-for-skipped-jobs
Avoid fetching logs for skipped jobs
This commit is contained in:
commit
73cb3ec8a8
4 changed files with 43 additions and 0 deletions
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue