Merge pull request #11312 from cli/babakks/avoid-fetching-logs-for-skipped-jobs

Avoid fetching logs for skipped jobs
This commit is contained in:
Kynan Ware 2025-07-17 09:48:41 -06:00 committed by GitHub
commit 73cb3ec8a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 0 deletions

View file

@ -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"`

View file

@ -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,

View file

@ -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
}

View file

@ -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{