| 48 | } |
| 49 | |
| 50 | func RenderJobsCompact(cs *iostreams.ColorScheme, jobs []Job) string { |
| 51 | lines := []string{} |
| 52 | for _, job := range jobs { |
| 53 | elapsed := job.CompletedAt.Sub(job.StartedAt) |
| 54 | elapsedStr := fmt.Sprintf(" in %s", elapsed) |
| 55 | if elapsed < 0 { |
| 56 | elapsedStr = "" |
| 57 | } |
| 58 | symbol, symbolColor := Symbol(cs, job.Status, job.Conclusion) |
| 59 | id := cs.Cyanf("%d", job.ID) |
| 60 | lines = append(lines, fmt.Sprintf("%s %s%s (ID %s)", symbolColor(symbol), cs.Bold(job.Name), elapsedStr, id)) |
| 61 | |
| 62 | if job.Status == Completed && job.Conclusion == Success { |
| 63 | continue |
| 64 | } |
| 65 | |
| 66 | var inProgressStepLine string |
| 67 | var failedStepLines []string |
| 68 | |
| 69 | for _, step := range job.Steps { |
| 70 | stepSymbol, stepSymColor := Symbol(cs, step.Status, step.Conclusion) |
| 71 | stepLine := fmt.Sprintf(" %s %s", stepSymColor(stepSymbol), step.Name) |
| 72 | |
| 73 | if IsFailureState(step.Conclusion) { |
| 74 | failedStepLines = append(failedStepLines, stepLine) |
| 75 | } |
| 76 | |
| 77 | if step.Status == InProgress { |
| 78 | inProgressStepLine = stepLine |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | lines = append(lines, failedStepLines...) |
| 83 | |
| 84 | if inProgressStepLine != "" { |
| 85 | lines = append(lines, inProgressStepLine) |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return strings.Join(lines, "\n") |
| 90 | } |
| 91 | |
| 92 | func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string { |
| 93 | lines := []string{} |