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