(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64)
| 493 | } |
| 494 | |
| 495 | func getRunLog(cache RunLogCache, httpClient *http.Client, repo ghrepo.Interface, run *shared.Run, attempt uint64) (*zip.ReadCloser, error) { |
| 496 | cacheKey := fmt.Sprintf("%d-%d", run.ID, run.StartedTime().Unix()) |
| 497 | isCached, err := cache.Exists(cacheKey) |
| 498 | if err != nil { |
| 499 | return nil, err |
| 500 | } |
| 501 | |
| 502 | if !isCached { |
| 503 | // Run log does not exist in cache so retrieve and store it |
| 504 | logURL, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", strconv.FormatInt(run.ID, 10), "logs") |
| 505 | if err != nil { |
| 506 | return nil, err |
| 507 | } |
| 508 | |
| 509 | if attempt > 0 { |
| 510 | logURL, err = safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", strconv.FormatInt(run.ID, 10), "attempts", strconv.FormatUint(attempt, 10), "logs") |
| 511 | if err != nil { |
| 512 | return nil, err |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | resp, err := getLog(httpClient, logURL) |
| 517 | if err != nil { |
| 518 | return nil, err |
| 519 | } |
| 520 | defer resp.Close() |
| 521 | |
| 522 | data, err := io.ReadAll(resp) |
| 523 | if err != nil { |
| 524 | return nil, err |
| 525 | } |
| 526 | respReader := bytes.NewReader(data) |
| 527 | |
| 528 | // Check if the response is a valid zip format |
| 529 | _, err = zip.NewReader(respReader, respReader.Size()) |
| 530 | if err != nil { |
| 531 | return nil, err |
| 532 | } |
| 533 | |
| 534 | err = cache.Create(cacheKey, respReader) |
| 535 | if err != nil { |
| 536 | return nil, err |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | return cache.Open(cacheKey) |
| 541 | } |
| 542 | |
| 543 | func promptForJob(prompter shared.Prompter, cs *iostreams.ColorScheme, jobs []shared.Job) (*shared.Job, error) { |
| 544 | candidates := []string{"View all jobs in this run"} |
no test coverage detected