5 Commits

Author SHA256 Message Date
100dc5021c obs-staging-bot: Fix setting of commit status 2025-09-09 10:53:11 +02:00
af6ccb205c Log errors on SetCommitStatus 2025-09-09 09:00:36 +02:00
4f0e9e8a90 Decline too large staging projects
In most cases anyway an error in pull request.
2025-09-09 08:56:39 +02:00
094637080c obs_staging: fix results compare
Esp. with multiple repositories:
* j counter was not reset
* wrong limit of results used (from reference not stage project)
* package name compare using == was always wrong (and unneeded here)
2025-09-08 13:55:20 +02:00
ffd517d525 Staging: include also changed directories
Projects which are not using submodules as package directories
still need to be handled in stagings.
2025-09-08 13:55:20 +02:00
2 changed files with 41 additions and 11 deletions

View File

@@ -821,6 +821,7 @@ func (e *GitHandlerImpl) GitSubmoduleList(gitPath, commitId string) (submoduleLi
for _, te := range tree.items { for _, te := range tree.items {
if te.isTree() { if te.isTree() {
trees[p+te.name+"/"] = te.hash trees[p+te.name+"/"] = te.hash
submoduleList[p+te.name] = te.hash
} else if te.isSubmodule() { } else if te.isSubmodule() {
submoduleList[p+te.name] = te.hash submoduleList[p+te.name] = te.hash
} }

View File

@@ -222,7 +222,6 @@ func ProcessRepoBuildStatus(results, ref []*common.PackageBuildStatus) (status B
slices.SortFunc(results, PackageBuildStatusSorter) slices.SortFunc(results, PackageBuildStatusSorter)
slices.SortFunc(ref, PackageBuildStatusSorter) slices.SortFunc(ref, PackageBuildStatusSorter)
j := 0
SomeSuccess = false SomeSuccess = false
for i := 0; i < len(results); i++ { for i := 0; i < len(results); i++ {
res, ok := common.ObsBuildStatusDetails[results[i].Code] res, ok := common.ObsBuildStatusDetails[results[i].Code]
@@ -237,10 +236,11 @@ func ProcessRepoBuildStatus(results, ref []*common.PackageBuildStatus) (status B
if !res.Success { if !res.Success {
// not failed if reference project also failed for same package here // 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++ { j := 0
for ; j < len(ref) && strings.Compare(results[i].Package, ref[j].Package) != 0; j++ {
} }
if j < len(results) && results[i].Package == ref[j].Package { if j < len(ref) {
refRes, ok := common.ObsBuildStatusDetails[ref[j].Code] refRes, ok := common.ObsBuildStatusDetails[ref[j].Code]
if !ok { if !ok {
common.LogInfo("unknown ref package result code:", ref[j].Code, "package:", ref[j].Package) common.LogInfo("unknown ref package result code:", ref[j].Code, "package:", ref[j].Package)
@@ -322,6 +322,9 @@ func GenerateObsPrjMeta(git common.Git, gitea common.Gitea, pr *models.PullReque
urlPkg = append(urlPkg, "onlybuild="+url.QueryEscape(pkg)) 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.Sha
if len(meta.ScmSync) >= 65535 {
return nil, errors.New("Reached max amount of package changes per request")
}
meta.Title = fmt.Sprintf("PR#%d to %s", pr.Index, pr.Base.Name) meta.Title = fmt.Sprintf("PR#%d to %s", pr.Index, pr.Base.Name)
// QE wants it published ... also we should not hardcode it here, since // QE wants it published ... also we should not hardcode it here, since
// it is configurable via the :PullRequest project // it is configurable via the :PullRequest project
@@ -837,6 +840,25 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
TargetURL: ObsWebHost + "/project/show/" + stagingProject, TargetURL: ObsWebHost + "/project/show/" + stagingProject,
} }
if err != nil {
msg := "Unable to setup stage propject " + stagingConfig.ObsProject
status.Status = common.CommitStatus_Fail
common.LogError(msg)
if !IsDryRun {
_, err := gitea.SetCommitStatus(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Head.Sha, status)
if err != nil {
common.LogError(err)
}
_, err = gitea.AddReviewComment(pr, common.ReviewStateRequestChanges, msg)
if err != nil {
common.LogError(err)
} else {
return true, nil
}
}
return false, nil
}
msg := "Changed source updated for build" msg := "Changed source updated for build"
if change == RequestModificationProjectCreated { if change == RequestModificationProjectCreated {
msg = "Build is started in " + ObsWebHost + "/project/show/" + msg = "Build is started in " + ObsWebHost + "/project/show/" +
@@ -845,7 +867,10 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
if len(stagingConfig.QA) > 0 { if len(stagingConfig.QA) > 0 {
msg = msg + "\nAdditional QA builds: \n" msg = msg + "\nAdditional QA builds: \n"
} }
gitea.SetCommitStatus(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Head.Sha, status) _, err := gitea.SetCommitStatus(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Head.Sha, status)
if err != nil {
common.LogError(err)
}
for _, setup := range stagingConfig.QA { for _, setup := range stagingConfig.QA {
CreateQASubProject(stagingConfig, git, gitea, pr, CreateQASubProject(stagingConfig, git, gitea, pr,
@@ -870,32 +895,36 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
} }
buildStatus := ProcessBuildStatus(stagingResult, baseResult) buildStatus := ProcessBuildStatus(stagingResult, baseResult)
done := false
switch buildStatus { switch buildStatus {
case BuildStatusSummarySuccess: case BuildStatusSummarySuccess:
status.Status = common.CommitStatus_Success status.Status = common.CommitStatus_Success
done = true
if !IsDryRun { if !IsDryRun {
_, err := gitea.AddReviewComment(pr, common.ReviewStateApproved, "Build successful") _, err := gitea.AddReviewComment(pr, common.ReviewStateApproved, "Build successful")
if err != nil { if err != nil {
common.LogError(err) common.LogError(err)
} else {
return true, nil
} }
} }
case BuildStatusSummaryFailed: case BuildStatusSummaryFailed:
status.Status = common.CommitStatus_Fail status.Status = common.CommitStatus_Fail
done = true
if !IsDryRun { if !IsDryRun {
_, err := gitea.AddReviewComment(pr, common.ReviewStateRequestChanges, "Build failed") _, err := gitea.AddReviewComment(pr, common.ReviewStateRequestChanges, "Build failed")
if err != nil { if err != nil {
common.LogError(err) common.LogError(err)
} else {
return true, nil
} }
} }
} }
common.LogInfo("Build status:", buildStatus) common.LogInfo("Build status:", buildStatus)
gitea.SetCommitStatus(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Head.Sha, status) if !IsDryRun {
_, err = gitea.SetCommitStatus(pr.Base.Repo.Owner.UserName, pr.Base.Repo.Name, pr.Head.Sha, status)
// waiting for build results -- nothing to do if err != nil {
common.LogError(err)
return false, err
}
}
return done, nil
} else if err == NonActionableReviewError || err == NoReviewsFoundError { } else if err == NonActionableReviewError || err == NoReviewsFoundError {
return true, nil return true, nil