From f955457dd651b1449b2a2217f4fdb617ab6a45b842e9ee46b3d6e0121cfa541a Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Fri, 16 Aug 2024 14:04:43 +0200 Subject: [PATCH] . --- README.md | 1 + bots-common/obs_utils.go | 7 +++++-- obs-staging-bot/main.go | 12 +++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 732d914..5eedd73 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ The bots that drive Git Workflow for package management * gitea-events-rabbitmq-publisher -- takes all events from a Gitea organization (webhook) and publishes it on a RabbitMQ instance * maintainer-bot -- review bot to make sure maintainer signed off * obs-staging-bot -- build bot for a PR + * obs-status-service -- report build status of an OBS project as an SVG * pr-review -- keeps PR to _ObsPrj consistent with a PR to a package update * prjgit-updater -- update _ObsPrj based on direct pushes and repo creations/removals from organization diff --git a/bots-common/obs_utils.go b/bots-common/obs_utils.go index 33ab783..90fd60e 100644 --- a/bots-common/obs_utils.go +++ b/bots-common/obs_utils.go @@ -427,8 +427,11 @@ func (c *ObsClient) BuildStatus(project string, packages ...string) (*BuildResul query.Add("view", "status") query.Add("view", "binarylist") query.Add("multibuild", "1") - for _, pkg := range packages { - query.Add("package", pkg) + if len(packages) > 0 { + query.Add("lastbuild", "1") + for _, pkg := range packages { + query.Add("package", pkg) + } } u.RawQuery = query.Encode() req, err := http.NewRequest("GET", u.String(), nil) diff --git a/obs-staging-bot/main.go b/obs-staging-bot/main.go index 361124c..df3f94f 100644 --- a/obs-staging-bot/main.go +++ b/obs-staging-bot/main.go @@ -260,7 +260,7 @@ func startBuild(h *common.RequestHandler, pr *models.PullRequest, obsClient *com for _, pkg := range modifiedOrNew { urlPkg = append(urlPkg, "onlybuild="+url.QueryEscape(pkg)) } - meta.ScmSync = pr.Head.Repo.CloneURL + "?" + strings.Join(urlPkg, "&") + "#" + pr.Head.Sha + meta.ScmSync = pr.Head.Repo.CloneURL + "?" + strings.Join(urlPkg, "&") + "#" + pr.Head.Name meta.Title = fmt.Sprintf("PR#%d to %s", pr.Index, pr.Base.Name) meta.PublicFlags = common.Flags{Contents: ""} @@ -410,6 +410,7 @@ func processPullNotification(h *common.RequestHandler, thread *models.Notificati h.LogError("failed fetching build status for '%s': %v", obsProject, err) return } + refProjectResult, err := obsClient.BuildStatus(refPrj, prjResult.GetPackageList()...) if err != nil { h.LogError("failed fetching ref project status for '%s': %v", refPrj, err) @@ -428,6 +429,7 @@ func processPullNotification(h *common.RequestHandler, thread *models.Notificati h.LogPlainError(err) } } + h.Log("Build status waiting: %d", buildStatus) // waiting for build results -- nothing to do case common.ReviewStateApproved: @@ -472,10 +474,10 @@ func main() { // go ProcessingObsMessages("rabbit.opensuse.org", "opensuse", "opensuse", "") - // for { - pollWorkNotifications() - // time.Sleep(1000) - // } + for { + pollWorkNotifications() + time.Sleep(10 * time.Minute) + } stuck := make(chan int) <-stuck