.
This commit is contained in:
parent
641885a2d7
commit
a8d392ea53
@ -10,7 +10,6 @@ import (
|
||||
"path"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -74,8 +73,6 @@ const (
|
||||
)
|
||||
|
||||
func processBuildStatus(h *common.RequestHandler, project, refProject *common.BuildResultList) BuildStatusSummary {
|
||||
targetResults := project.Result
|
||||
|
||||
if _, finished := project.BuildResultSummary(); !finished {
|
||||
return BuildStatusSummaryBuilding
|
||||
}
|
||||
@ -89,9 +86,6 @@ func processBuildStatus(h *common.RequestHandler, project, refProject *common.Bu
|
||||
// need to verify that packages that are building in `refProject` are not
|
||||
// failing in the `project`
|
||||
BuildResultSorter := func(a, b common.BuildResult) int {
|
||||
if c := strings.Compare(a.Project, b.Project); c != 0 {
|
||||
return c
|
||||
}
|
||||
if c := strings.Compare(a.Repository, b.Repository); c != 0 {
|
||||
return c
|
||||
}
|
||||
@ -104,7 +98,75 @@ func processBuildStatus(h *common.RequestHandler, project, refProject *common.Bu
|
||||
slices.SortFunc(project.Result, BuildResultSorter)
|
||||
slices.SortFunc(refProject.Result, BuildResultSorter)
|
||||
|
||||
return BuildStatusSummaryUnknown
|
||||
j := 0
|
||||
for i := 0; i < len(project.Result); i++ {
|
||||
for ; j < len(refProject.Result); j++ {
|
||||
if project.Result[i].Repository != refProject.Result[j].Repository ||
|
||||
project.Result[i].Arch != refProject.Result[j].Arch {
|
||||
continue
|
||||
}
|
||||
|
||||
res := processRepoBuildStatus(h, project.Result[i].Status, refProject.Result[j].Status)
|
||||
switch res {
|
||||
case BuildStatusSummarySuccess:
|
||||
break
|
||||
default:
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
if j >= len(refProject.Result) {
|
||||
return BuildStatusSummaryUnknown
|
||||
}
|
||||
}
|
||||
return BuildStatusSummarySuccess
|
||||
}
|
||||
|
||||
func processRepoBuildStatus(h *common.RequestHandler, results, ref []common.PackageBuildStatus) BuildStatusSummary {
|
||||
PackageBuildStatusSorter := func(a, b common.PackageBuildStatus) int {
|
||||
return strings.Compare(a.Package, b.Package)
|
||||
}
|
||||
|
||||
// compare build result
|
||||
slices.SortFunc(results, PackageBuildStatusSorter)
|
||||
slices.SortFunc(ref, PackageBuildStatusSorter)
|
||||
|
||||
j := 0
|
||||
for i := 0; i < len(results); i++ {
|
||||
res, ok := common.ObsBuildStatusDetails[results[i].Code]
|
||||
if !ok {
|
||||
h.LogError("unknown package result code: %s for package %s", results[i].Code, results[i].Package)
|
||||
return BuildStatusSummaryUnknown
|
||||
}
|
||||
|
||||
if !res.Finished {
|
||||
return BuildStatusSummaryBuilding
|
||||
}
|
||||
|
||||
if !res.Success {
|
||||
// not failed if reference project also failed for same package here
|
||||
for ; j < len(results) && strings.Compare(results[i].Package, ref[j].Package) < 0; j++ {
|
||||
}
|
||||
|
||||
if j < len(results) && results[i].Package == ref[j].Package {
|
||||
refRes, ok := common.ObsBuildStatusDetails[ref[j].Code]
|
||||
if !ok {
|
||||
h.LogError("unknown package result code: %s for package %s", ref[j].Code, ref[j].Package)
|
||||
return BuildStatusSummaryUnknown
|
||||
}
|
||||
|
||||
if !refRes.Finished {
|
||||
h.LogError("not finished building in reference project?!")
|
||||
}
|
||||
|
||||
if refRes.Success {
|
||||
return BuildStatusSummaryFailed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BuildStatusSummarySuccess
|
||||
}
|
||||
|
||||
func startBuild(h *common.RequestHandler, pr *models.PullRequest, obsClient *common.ObsClient) error {
|
||||
|
Loading…
Reference in New Issue
Block a user