(opts *ViewOptions, client *api.Client, repo ghrepo.Interface, workflow *shared.Workflow)
| 203 | } |
| 204 | |
| 205 | func viewWorkflowInfo(opts *ViewOptions, client *api.Client, repo ghrepo.Interface, workflow *shared.Workflow) error { |
| 206 | wr, err := runShared.GetRuns(client, repo, &runShared.FilterOptions{ |
| 207 | WorkflowID: workflow.ID, |
| 208 | WorkflowName: workflow.Name, |
| 209 | }, 5) |
| 210 | if err != nil { |
| 211 | return fmt.Errorf("failed to get runs: %w", err) |
| 212 | } |
| 213 | |
| 214 | out := opts.IO.Out |
| 215 | cs := opts.IO.ColorScheme() |
| 216 | |
| 217 | // Header |
| 218 | filename := workflow.Base() |
| 219 | fmt.Fprintf(out, "%s - %s\n", cs.Bold(workflow.Name), cs.Cyan(filename)) |
| 220 | fmt.Fprintf(out, "ID: %s\n\n", cs.Cyanf("%d", workflow.ID)) |
| 221 | |
| 222 | // Runs |
| 223 | fmt.Fprintf(out, "Total runs %d\n", wr.TotalCount) |
| 224 | |
| 225 | if wr.TotalCount != 0 { |
| 226 | fmt.Fprintln(out, "Recent runs") |
| 227 | } |
| 228 | |
| 229 | headers := make([]string, 0, 8) |
| 230 | if opts.Raw { |
| 231 | headers = append(headers, "STATUS", "CONCLUSION") |
| 232 | } else { |
| 233 | headers = append(headers, "") |
| 234 | } |
| 235 | headers = append(headers, "TITLE", "WORKFLOW", "BRANCH", "EVENT") |
| 236 | if opts.Raw { |
| 237 | headers = append(headers, "ELAPSED") |
| 238 | } |
| 239 | headers = append(headers, "ID") |
| 240 | |
| 241 | tp := tableprinter.New(opts.IO, tableprinter.WithHeader(headers...)) |
| 242 | for _, run := range wr.WorkflowRuns { |
| 243 | if opts.Raw { |
| 244 | tp.AddField(string(run.Status)) |
| 245 | tp.AddField(string(run.Conclusion)) |
| 246 | } else { |
| 247 | symbol, symbolColor := runShared.Symbol(cs, run.Status, run.Conclusion) |
| 248 | tp.AddField(symbol, tableprinter.WithColor(symbolColor)) |
| 249 | } |
| 250 | |
| 251 | tp.AddField(run.Title(), tableprinter.WithColor(cs.Bold)) |
| 252 | |
| 253 | tp.AddField(run.WorkflowName()) |
| 254 | tp.AddField(run.HeadBranch, tableprinter.WithColor(cs.Bold)) |
| 255 | tp.AddField(string(run.Event)) |
| 256 | |
| 257 | if opts.Raw { |
| 258 | tp.AddField(run.Duration(opts.now).String()) |
| 259 | } |
| 260 | |
| 261 | tp.AddField(fmt.Sprintf("%d", run.ID), tableprinter.WithColor(cs.Cyan)) |
| 262 |
no test coverage detected