diff --git a/common/config.go b/common/config.go index dceccf2..7e61fef 100644 --- a/common/config.go +++ b/common/config.go @@ -54,6 +54,7 @@ type ReviewGroup struct { type QAConfig struct { Name string Origin string + BuildDisableRepos []string // which repos to build disable in the new project } type Permissions struct { diff --git a/obs-staging-bot/README.md b/obs-staging-bot/README.md index 727ce42..ff20c0e 100644 --- a/obs-staging-bot/README.md +++ b/obs-staging-bot/README.md @@ -34,7 +34,8 @@ It's a JSON file with following syntax: "QA": [ { "Name": "SLES", - "Origin": "SUSE:SLFO:Products:SLES:16.0" + "Origin": "SUSE:SLFO:Products:SLES:16.0", + "BuildDisableRepos": ["product"] } ] } @@ -47,6 +48,7 @@ It's a JSON file with following syntax: | *QA* | Crucial for generating a product build (such as an ISO or FTP tree) that incorporates the packages. | no | array of objects | | | | *QA > Name* | Suffix for the QA OBS staging project. The project is named *StagingProject::Name*. | no | string | | | | *QA > Origin* | OBS reference project | no | string | | | +| *QA > BuildDisableRepos* | The names of OBS repositories to build-disable, if any. | no | array of strings | | [] | Details @@ -65,6 +67,6 @@ Details * **PrjGit PR - QA staging project** * The QA staging project is meant for building the product; the relative build config is inherited from the `QA > Origin` project. * In this case, the **scmsync** tag is inherited from the `QA > Origin` project. - - + * It is desirable in some cases to avoid building some specific build service repositories when not needed. In this case, `QA > BuildDisableRepos` can be specified. + These repositories would be disabled in the project meta when generating the QA project. diff --git a/obs-staging-bot/main.go b/obs-staging-bot/main.go index fd14c37..ccd13c6 100644 --- a/obs-staging-bot/main.go +++ b/obs-staging-bot/main.go @@ -109,6 +109,11 @@ const ( BuildStatusSummaryUnknown = 4 ) +type DisableFlag struct { + XMLName string `xml:"disable"` + Name string `xml:"repository,attr"` +} + func ProcessBuildStatus(project, refProject *common.BuildResultList) BuildStatusSummary { if _, finished := refProject.BuildResultSummary(); !finished { common.LogDebug("refProject not finished building??") @@ -377,7 +382,7 @@ func GenerateObsPrjMeta(git common.Git, gitea common.Gitea, pr *models.PullReque // stagingProject:$buildProject // ^- stagingProject:$buildProject:$subProjectName (based on templateProject) -func CreateQASubProject(stagingConfig *common.StagingConfig, git common.Git, gitea common.Gitea, pr *models.PullRequest, stagingProject, templateProject, subProjectName string) error { +func CreateQASubProject(stagingConfig *common.StagingConfig, git common.Git, gitea common.Gitea, pr *models.PullRequest, stagingProject, templateProject, subProjectName string, buildDisableRepos []string) error { common.LogDebug("Setup QA sub projects") templateMeta, err := ObsClient.GetProjectMeta(templateProject) if err != nil { @@ -407,7 +412,21 @@ func CreateQASubProject(stagingConfig *common.StagingConfig, git common.Git, git repository.Fragment = branch.SHA templateMeta.ScmSync = repository.String() common.LogDebug("Setting scmsync url to ", templateMeta.ScmSync) - } + } + // Build-disable repositories if asked + if len(buildDisableRepos) > 0 { + toDisable := make([]DisableFlag, len(buildDisableRepos)) + for idx, repositoryName := range buildDisableRepos { + toDisable[idx] = DisableFlag{Name: repositoryName} + } + + output, err := xml.Marshal(toDisable) + if err != nil { + common.LogError("error while marshalling, skipping BuildDisableRepos: ", err) + } else { + templateMeta.BuildFlags.Contents += string(output) + } + } // Cleanup ReleaseTarget and modify affected path entries for idx, r := range templateMeta.Repositories { templateMeta.Repositories[idx].ReleaseTargets = nil @@ -922,7 +941,8 @@ func ProcessPullRequest(gitea common.Gitea, org, repo string, id int64) (bool, e CreateQASubProject(stagingConfig, git, gitea, pr, stagingProject, setup.Origin, - setup.Name) + setup.Name, + setup.BuildDisableRepos) msg = msg + ObsWebHost + "/project/show/" + stagingProject + ":" + setup.Name + "\n" }