Compare commits

...

3 Commits

Author SHA256 Message Date
79eb2874ba staging: support multiple labels for a QA project
This is fixing the invalid cleanup and avoids duplication of the
same project in staging.config.

Just, how should we deal with Label and Labels set?
Atm only Label is used.
2026-03-05 15:12:15 +01:00
52e9b9931c staging: Fix error message of missing staging.config 2026-03-04 11:17:25 +01:00
783c676ad0 obs-staging-bot: Temporary hack for current factory setup
We accept currently the temporary openSUSE:Factory:git not being the
master of openSUSE:Factory:PullRequest. We want to have it at the final
place. Once factory switches to git, content of openSUSE:Factory:git
will move to openSUSE:Factory and we can drop this exception again
2026-03-03 15:56:49 +01:00
3 changed files with 28 additions and 5 deletions

View File

@@ -55,6 +55,7 @@ type QAConfig struct {
Name string
Origin string
Label string // requires this gitea lable to be set or skipped
Labels []string // requires any of the lables to be set
BuildDisableRepos []string // which repos to build disable in the new project
}
@@ -326,6 +327,14 @@ func ParseStagingConfig(data []byte) (*StagingConfig, error) {
if err := json.Unmarshal(data, &staging); err != nil {
return nil, err
}
// backward compability, transfer Label to new Labels array
// should we fail when both are set?
for i := range staging.QA {
if len(staging.QA[i].Labels) == 0 && len(staging.QA[i].Label) > 0 {
staging.QA[i].Labels = []string{staging.QA[i].Label}
staging.QA[i].Label = ""
}
}
return &staging, nil
}

View File

@@ -50,6 +50,7 @@ It's a JSON file with following syntax:
| *QA > Name* | Suffix for the QA OBS staging project. The project is named *StagingProject:<PR_Number>:Name*. | no | string | | |
| *QA > Origin* | OBS reference project | no | string | | |
| *QA > Label* | Setup the project only when the given gitea label is set on pull request | no | string | | |
| *QA > Labels* | Setup the project only when the one of gitea labels is set on pull request. Do not combine with Label. | no | array of strings | | [] |
| *QA > BuildDisableRepos* | The names of OBS repositories to build-disable, if any. | no | array of strings | | [] |

View File

@@ -718,8 +718,16 @@ func ProcessQaProjects(stagingConfig *common.StagingConfig, git common.Git, gite
msg := ""
for _, setup := range stagingConfig.QA {
QAproject := stagingProject + ":" + setup.Name
if len(setup.Label) > 0 {
if _, ok := prLabelNames[setup.Label]; !ok {
if len(setup.Labels) > 0 {
matchedLabel := false
for labelName := range prLabelNames {
if slices.Contains(setup.Labels, labelName) {
matchedLabel = true
break
}
}
if ! matchedLabel {
if !IsDryRun {
// blindly remove, will fail when not existing
ObsClient.DeleteProject(QAproject)
@@ -802,7 +810,7 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
if err != nil {
common.LogError("Staging config", common.StagingConfigFile, "not found in PR to the project. Aborting.")
if !IsDryRun {
_, err = gitea.AddReviewComment(pr, common.ReviewStateRequestChanges, "Cannot find project config in PR: "+common.ProjectConfigFile)
_, err = gitea.AddReviewComment(pr, common.ReviewStateRequestChanges, "Cannot find staging config in PR ("+common.StagingConfigFile+")")
}
return true, err
}
@@ -861,8 +869,11 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
// NOTE: this is user input, so we need some limits here
l := len(stagingConfig.ObsProject)
if l >= len(stagingConfig.StagingProject) || stagingConfig.ObsProject != stagingConfig.StagingProject[0:l] {
common.LogError("StagingProject (", stagingConfig.StagingProject, ") is not child of target project", stagingConfig.ObsProject)
return true, nil
// TEMPORARY HACK: We remove this when Factory has switched to git
if ( stagingConfig.ObsProject != "openSUSE:Factory:git" && stagingConfig.StagingProject != "openSUSE:Factory:PullRequest" ) {
common.LogError("StagingProject (", stagingConfig.StagingProject, ") is not child of target project", stagingConfig.ObsProject)
return true, nil
}
}
}
@@ -1003,9 +1014,11 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e
done := false
overallBuildStatus := ProcessBuildStatus(stagingResult)
commentSuffix := ""
common.LogDebug("Number of QA Projects: ", len(qaProjects))
if len(qaProjects) > 0 && overallBuildStatus == BuildStatusSummarySuccess {
seperator := " in "
for _, qaProject := range qaProjects {
common.LogDebug(" QA Project: ", qaProject)
qaResult, err := ObsClient.BuildStatus(qaProject)
if err != nil {
common.LogError("failed fetching stage project status for", qaProject, ":", err)