forked from git-workflow/autogits
Compare commits
3 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| 79eb2874ba | |||
| 52e9b9931c | |||
| 783c676ad0 |
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 | | [] |
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user