From 662a50fa00859251b8542ce07e8a57edaa05d7ee Mon Sep 17 00:00:00 2001 From: Brian Carey Date: Tue, 10 Sep 2024 16:39:07 +0100 Subject: [PATCH] sig,badges: Add total number of jobs run per SIG to each SIG badge The number of failed runs per SIG does not give a clear picture on its own without the total number of job runs per SIG as each SIG has a different number of lanes that runs against each PR. This includes the total number of jobs run per SIG in each SIG badge and sets the badge colour to reflect the percentage of failed jobs out of total jobs run. Signed-off-by: Brian Carey --- pkg/constants/main.go | 2 +- pkg/output/output.go | 9 +++++-- pkg/sigretests/main.go | 53 +++++++++++++++++++++++++++--------------- pkg/stats/stats.go | 20 +++++++++------- pkg/types/main.go | 4 ++++ 5 files changed, 58 insertions(+), 30 deletions(-) diff --git a/pkg/constants/main.go b/pkg/constants/main.go index e294e14969..873eec88c4 100644 --- a/pkg/constants/main.go +++ b/pkg/constants/main.go @@ -33,7 +33,7 @@ const ( DefaultMergedPRsNoRetestYellowLevel = 0.75 DefaultMergedPRsNoRetestRedLevel = 0.5 DefaultSIGRetestYellowLevel = 1 - DefaultSIGRetestRedLevel = 20 + DefaultSIGRetestRedLevel = 15 DefaultBatchStartDate = "2019-05-06" TimeToMergeBadgeFileName = "time-to-merge.svg" diff --git a/pkg/output/output.go b/pkg/output/output.go index 74a37d4468..8d8c4d198e 100644 --- a/pkg/output/output.go +++ b/pkg/output/output.go @@ -191,19 +191,24 @@ func (b *Handler) writeBadge(name, filePath string, data types.RunningAverageDat func (b *Handler) writeSIGRetestBadge(name, filePath string, data types.RunningAverageDataItem, levels *Levels) error { var value float64 + var total float64 switch name { case constants.SIGComputeRetestBadgeName: value = data.SIGComputeRetest + total = data.SIGComputeTotal case constants.SIGNetworkRetestBadgeName: value = data.SIGNetworkRetest + total = data.SIGNetworkTotal case constants.SIGStorageRetestBadgeName: value = data.SIGStorageRetest + total = data.SIGStorageTotal case constants.SIGOperatorRetestBadgeName: value = data.SIGOperatorRetest + total = data.SIGOperatorTotal } - color := BadgeColor(value, levels) + color := BadgeColor(((value / total) * 100), levels) f, err := os.Create(filePath) if err != nil { @@ -211,7 +216,7 @@ func (b *Handler) writeSIGRetestBadge(name, filePath string, data types.RunningA } defer f.Close() - badgeString := fmt.Sprintf("%.0f", value) + badgeString := fmt.Sprintf("%.0f / %.0f", value, total) return badge.Render(name, badgeString, color, f) } diff --git a/pkg/sigretests/main.go b/pkg/sigretests/main.go index 1a8f779280..8aad8930ea 100644 --- a/pkg/sigretests/main.go +++ b/pkg/sigretests/main.go @@ -21,12 +21,16 @@ type job struct { } type SigRetests struct { - SigCompute int - SigNetwork int - SigStorage int - SigOperator int - FailedJobNames []string - SuccessJobNames []string + SigComputeFailure int + SigNetworkFailure int + SigStorageFailure int + SigOperatorFailure int + SigComputeSuccess int + SigNetworkSuccess int + SigStorageSuccess int + SigOperatorSuccess int + FailedJobNames []string + SuccessJobNames []string } var prowjobs []job @@ -165,19 +169,30 @@ func sortJobNamesOnResult(job job, sigRetests SigRetests) (jobCounts SigRetests) func FilterJobsPerSigs(jobs []job) (prSigRetests SigRetests) { prSigRetests = SigRetests{} for _, job := range jobs { - if job.failure { - switch { - case strings.Contains(job.jobName, "sig-compute") || strings.Contains(job.jobName, "vgpu"): - prSigRetests.SigCompute += 1 - - case strings.Contains(job.jobName, "sig-network") || strings.Contains(job.jobName, "sriov"): - prSigRetests.SigNetwork += 1 - - case strings.Contains(job.jobName, "sig-storage"): - prSigRetests.SigStorage += 1 - - case strings.Contains(job.jobName, "sig-operator"): - prSigRetests.SigOperator += 1 + switch { + case strings.Contains(job.jobName, "sig-compute") || strings.Contains(job.jobName, "vgpu"): + if job.failure { + prSigRetests.SigComputeFailure += 1 + } else { + prSigRetests.SigComputeSuccess += 1 + } + case strings.Contains(job.jobName, "sig-network") || strings.Contains(job.jobName, "sriov"): + if job.failure { + prSigRetests.SigNetworkFailure += 1 + } else { + prSigRetests.SigNetworkSuccess += 1 + } + case strings.Contains(job.jobName, "sig-storage"): + if job.failure { + prSigRetests.SigStorageFailure += 1 + } else { + prSigRetests.SigStorageSuccess += 1 + } + case strings.Contains(job.jobName, "sig-operator"): + if job.failure { + prSigRetests.SigOperatorFailure += 1 + } else { + prSigRetests.SigOperatorSuccess += 1 } } prSigRetests = sortJobNamesOnResult(job, prSigRetests) diff --git a/pkg/stats/stats.go b/pkg/stats/stats.go index 1deded3136..3f62852af9 100644 --- a/pkg/stats/stats.go +++ b/pkg/stats/stats.go @@ -271,21 +271,25 @@ func (h *Handler) sigRetestsProcessor(results *types.Results) (*types.Results, e } for _, mergedPR := range mergedPRs { - failuresPerSIG, err := sigretests.GetJobsPerSIG(strconv.Itoa(mergedPR.Number), "kubevirt", "kubevirt") + jobsPerSIG, err := sigretests.GetJobsPerSIG(strconv.Itoa(mergedPR.Number), "kubevirt", "kubevirt") if err != nil { return results, err } - dataItem.SIGComputeRetest = dataItem.SIGComputeRetest + float64(failuresPerSIG.SigCompute) - dataItem.SIGNetworkRetest = dataItem.SIGNetworkRetest + float64(failuresPerSIG.SigNetwork) - dataItem.SIGStorageRetest = dataItem.SIGStorageRetest + float64(failuresPerSIG.SigStorage) - dataItem.SIGOperatorRetest = dataItem.SIGOperatorRetest + float64(failuresPerSIG.SigOperator) + dataItem.SIGComputeRetest = dataItem.SIGComputeRetest + float64(jobsPerSIG.SigComputeFailure) + dataItem.SIGNetworkRetest = dataItem.SIGNetworkRetest + float64(jobsPerSIG.SigNetworkFailure) + dataItem.SIGStorageRetest = dataItem.SIGStorageRetest + float64(jobsPerSIG.SigStorageFailure) + dataItem.SIGOperatorRetest = dataItem.SIGOperatorRetest + float64(jobsPerSIG.SigOperatorFailure) + dataItem.SIGComputeTotal = dataItem.SIGComputeTotal + float64(jobsPerSIG.SigComputeFailure) + float64(jobsPerSIG.SigComputeSuccess) + dataItem.SIGNetworkTotal = dataItem.SIGNetworkTotal + float64(jobsPerSIG.SigNetworkFailure) + float64(jobsPerSIG.SigNetworkSuccess) + dataItem.SIGStorageTotal = dataItem.SIGStorageTotal + float64(jobsPerSIG.SigStorageFailure) + float64(jobsPerSIG.SigStorageSuccess) + dataItem.SIGOperatorTotal = dataItem.SIGOperatorTotal + float64(jobsPerSIG.SigOperatorFailure) + float64(jobsPerSIG.SigOperatorSuccess) dataItem.DataPoints = append(dataItem.DataPoints, types.DataPoint{ - Value: float64(len(failuresPerSIG.FailedJobNames)), + Value: float64(len(jobsPerSIG.FailedJobNames)), PRs: []types.PR{mergedPR}, }) - failedJobNames = slices.Concat(failedJobNames, failuresPerSIG.FailedJobNames) - successJobNames = slices.Concat(successJobNames, failuresPerSIG.SuccessJobNames) + failedJobNames = slices.Concat(failedJobNames, jobsPerSIG.FailedJobNames) + successJobNames = slices.Concat(successJobNames, jobsPerSIG.SuccessJobNames) } sortedFailedJobs := types.SortByMostFailed(countFailedJobs(failedJobNames)) for i, job := range sortedFailedJobs { diff --git a/pkg/types/main.go b/pkg/types/main.go index b6cc9a8393..17f0a2f863 100644 --- a/pkg/types/main.go +++ b/pkg/types/main.go @@ -245,6 +245,10 @@ type RunningAverageDataItem struct { SIGStorageRetest float64 SIGNetworkRetest float64 SIGOperatorRetest float64 + SIGComputeTotal float64 + SIGStorageTotal float64 + SIGNetworkTotal float64 + SIGOperatorTotal float64 FailedJobLeaderBoard FailedJobs DataPoints []DataPoint }