95
96
// generateTestReportTable creates a markdown table of test reports with rate column.
97
>
func generateTestReportTable(reports []TestReport, rateHeader string, maxLinks int) string {
report.go
98
>
if len(reports) == 0 {
99
return ""
100
}
101
103
>
sb.WriteString(fmt.Sprintf("| Test | %s | Last Failure | Trend | Links |\n", rateHeader))
104
>
sb.WriteString("|------|------------|-------------|-------|-------|\n")
105
>
106
>
for _, report := range reports {
107
>
pct := 0.0
108
>
if report.TotalRuns > 0 {
109
>
pct = float64(report.FailureCount) / float64(report.TotalRuns) * 100.0
110
>
}
111
>
links := formatLinks(report.GitHubURLs, maxLinks)
112
>
lastFailure := "N/A"
113
>
if !report.LastFailure.IsZero() {
114
>
lastFailure = hoursAgo(report.LastFailure)
115
>
}
116
>
rate := fmt.Sprintf("%.1f%% (%d/%d)", pct, report.FailureCount, report.TotalRuns)
117
>
if pct > boldFlakeRateThreshold {
118
>
rate = "**" + rate + "**"
119
>
}
120
>
sb.WriteString(fmt.Sprintf("| `%s` | %s | %s | `%s` | %s |\n",
121
>
report.TestName, rate, lastFailure, formatSparkline(report.TrendPoints), links))
122
}
123
125
}