From c7569c7f9548bf7ce6ec3ae71bf7d40f20a17916f1b6a365177462332c4479d1 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 2 Aug 2024 15:34:44 +0200 Subject: [PATCH] . --- bots-common/obs_utils.go | 4 ++++ obs-staging-bot/main.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/bots-common/obs_utils.go b/bots-common/obs_utils.go index f280cec..33ab783 100644 --- a/bots-common/obs_utils.go +++ b/bots-common/obs_utils.go @@ -229,6 +229,10 @@ func (r *BuildResultList) GetPackageList() []string { } func (r *BuildResultList) BuildResultSummary() (success, finished bool) { + if r == nil { + return true, true + } + finished = len(r.Result) > 0 && len(r.Result[0].Status) > 0 success = finished diff --git a/obs-staging-bot/main.go b/obs-staging-bot/main.go index 9144e90..3a2f1f1 100644 --- a/obs-staging-bot/main.go +++ b/obs-staging-bot/main.go @@ -96,6 +96,39 @@ func processBuildStatus(h *common.RequestHandler, project, refProject *common.Bu panic("Should not happen -- BuiltResultSorter equal repos?") } slices.SortFunc(project.Result, BuildResultSorter) + if refProject == nil { + // just return if buid finished and have some successes, since new package + SomeSuccess := false + for i := 0; i < len(project.Result); i++ { + repoRes := &project.Result[i] + repoResStatus, ok := common.ObsRepoStatusDetails[repoRes.Code] + if !ok { + return BuildStatusSummaryUnknown + } + if !repoResStatus.Finished { + return BuildStatusSummaryBuilding + } + + for _, pkg := range repoRes.Status { + pkgStatus, ok := common.ObsBuildStatusDetails[pkg.Code] + if !ok { + h.LogError("Unknown package build status: %s for %s", pkg.Code, pkg.Package) + h.LogError("Details: %s", pkg.Details) + return BuildStatusSummaryUnknown + } + + if pkgStatus.Success { + SomeSuccess = true + } + } + } + + if SomeSuccess { + return BuildStatusSummarySuccess + } + return BuildStatusSummaryFailed + } + slices.SortFunc(refProject.Result, BuildResultSorter) j := 0