Skip to content

Commit

Permalink
Merge pull request #67 from kubevirt/sig-badge-total-relative
Browse files Browse the repository at this point in the history
sig,badges: Add total number of jobs run per SIG to each SIG badge
  • Loading branch information
dhiller authored Sep 12, 2024
2 parents 19c3d72 + 662a50f commit 08ee6e2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
2 changes: 1 addition & 1 deletion pkg/constants/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,32 @@ 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 {
return err
}
defer f.Close()

badgeString := fmt.Sprintf("%.0f", value)
badgeString := fmt.Sprintf("%.0f / %.0f", value, total)

return badge.Render(name, badgeString, color, f)
}
Expand Down
53 changes: 34 additions & 19 deletions pkg/sigretests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
20 changes: 12 additions & 8 deletions pkg/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 08ee6e2

Please sign in to comment.