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