(out io.Writer, opts WatchOptions, client *api.Client, repo ghrepo.Interface, run *shared.Run, prNumber string, annotationCache map[int64][]shared.Annotation)
| 213 | } |
| 214 | |
| 215 | func renderRun(out io.Writer, opts WatchOptions, client *api.Client, repo ghrepo.Interface, run *shared.Run, prNumber string, annotationCache map[int64][]shared.Annotation) (*shared.Run, error) { |
| 216 | cs := opts.IO.ColorScheme() |
| 217 | |
| 218 | var err error |
| 219 | |
| 220 | run, err = shared.GetRun(client, repo, fmt.Sprintf("%d", run.ID), 0) |
| 221 | if err != nil { |
| 222 | return nil, fmt.Errorf("failed to get run: %w", err) |
| 223 | } |
| 224 | |
| 225 | jobs, err := shared.GetJobs(client, repo, run.ID, safeurl.NewImmutableSafeURL(run.JobsURL), 0) |
| 226 | if err != nil { |
| 227 | return nil, fmt.Errorf("failed to get jobs: %w", err) |
| 228 | } |
| 229 | run.Jobs = jobs |
| 230 | |
| 231 | var annotations []shared.Annotation |
| 232 | var missingAnnotationsPermissions bool |
| 233 | |
| 234 | for _, job := range jobs { |
| 235 | if as, ok := annotationCache[job.ID]; ok { |
| 236 | annotations = as |
| 237 | continue |
| 238 | } |
| 239 | |
| 240 | as, err := shared.GetAnnotations(client, repo, job) |
| 241 | if err != nil { |
| 242 | if err != shared.ErrMissingAnnotationsPermissions { |
| 243 | return nil, fmt.Errorf("failed to get annotations: %w", err) |
| 244 | } |
| 245 | |
| 246 | missingAnnotationsPermissions = true |
| 247 | break |
| 248 | } |
| 249 | |
| 250 | annotations = append(annotations, as...) |
| 251 | |
| 252 | if job.Status != shared.InProgress { |
| 253 | annotationCache[job.ID] = annotations |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | fmt.Fprintln(out, shared.RenderRunHeader(cs, *run, text.FuzzyAgo(opts.Now(), run.StartedTime()), prNumber, 0)) |
| 258 | fmt.Fprintln(out) |
| 259 | |
| 260 | if len(jobs) == 0 { |
| 261 | return run, nil |
| 262 | } |
| 263 | |
| 264 | fmt.Fprintln(out, cs.Bold("JOBS")) |
| 265 | if opts.Compact { |
| 266 | fmt.Fprintln(out, shared.RenderJobsCompact(cs, jobs)) |
| 267 | } else { |
| 268 | fmt.Fprintln(out, shared.RenderJobs(cs, jobs, true)) |
| 269 | } |
| 270 | |
| 271 | if missingAnnotationsPermissions { |
| 272 | fmt.Fprintln(out) |
no test coverage detected