pr: do not stop processing if failed on some pacakge during check
This commit is contained in:
@@ -7,7 +7,7 @@ import "src.opensuse.org/autogits/common"
|
|||||||
|
|
||||||
type StateChecker interface {
|
type StateChecker interface {
|
||||||
VerifyProjectState(configs *common.AutogitConfig) ([]*PRToProcess, error)
|
VerifyProjectState(configs *common.AutogitConfig) ([]*PRToProcess, error)
|
||||||
CheckRepos() error
|
CheckRepos()
|
||||||
ConsistencyCheckProcess() error
|
ConsistencyCheckProcess() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path"
|
"path"
|
||||||
@@ -43,6 +42,15 @@ func pullRequestToEventState(state models.StateType) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefaultStateChecker) ProcessPR(pr *models.PullRequest, config *common.AutogitConfig) error {
|
func (s *DefaultStateChecker) ProcessPR(pr *models.PullRequest, config *common.AutogitConfig) error {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
common.LogError("panic caught in ProcessPR", common.PRtoString(pr))
|
||||||
|
if err, ok := r.(error); !ok {
|
||||||
|
common.LogError(err)
|
||||||
|
}
|
||||||
|
common.LogError(string(debug.Stack()))
|
||||||
|
}
|
||||||
|
}()
|
||||||
return ProcesPullRequest(pr, common.AutogitConfigs{config})
|
return ProcesPullRequest(pr, common.AutogitConfigs{config})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +159,7 @@ func (s *DefaultStateChecker) VerifyProjectState(config *common.AutogitConfig) (
|
|||||||
return PrjGitSubmoduleCheck(config, git, prjGitRepo, submodules)
|
return PrjGitSubmoduleCheck(config, git, prjGitRepo, submodules)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefaultStateChecker) CheckRepos() error {
|
func (s *DefaultStateChecker) CheckRepos() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
common.LogError("panic caught")
|
common.LogError("panic caught")
|
||||||
@@ -161,7 +169,6 @@ func (s *DefaultStateChecker) CheckRepos() error {
|
|||||||
common.LogError(string(debug.Stack()))
|
common.LogError(string(debug.Stack()))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
errorList := make([]error, 0, 10)
|
|
||||||
|
|
||||||
for org, configs := range s.processor.configuredRepos {
|
for org, configs := range s.processor.configuredRepos {
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
@@ -175,12 +182,12 @@ func (s *DefaultStateChecker) CheckRepos() error {
|
|||||||
prs, err := s.i.VerifyProjectState(config)
|
prs, err := s.i.VerifyProjectState(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.LogError(" *** verification failed, org:", org, err)
|
common.LogError(" *** verification failed, org:", org, err)
|
||||||
errorList = append(errorList, err)
|
|
||||||
}
|
}
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
prs, err := Gitea.GetRecentPullRequests(pr.Org, pr.Repo, pr.Branch)
|
prs, err := Gitea.GetRecentPullRequests(pr.Org, pr.Repo, pr.Branch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error fetching pull requests for %s/%s#%s. Err: %w", pr.Org, pr.Repo, pr.Branch, err)
|
common.LogError("Error fetching pull requests for", fmt.Sprintf("%s/%s#%s", pr.Org, pr.Repo, pr.Branch), err)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if len(prs) > 0 {
|
if len(prs) > 0 {
|
||||||
common.LogDebug(fmt.Sprintf("%s/%s#%s", pr.Org, pr.Repo, pr.Branch), " - # of PRs to check:", len(prs))
|
common.LogDebug(fmt.Sprintf("%s/%s#%s", pr.Org, pr.Repo, pr.Branch), " - # of PRs to check:", len(prs))
|
||||||
@@ -194,8 +201,6 @@ func (s *DefaultStateChecker) CheckRepos() error {
|
|||||||
common.LogInfo(" ++ verification complete, org:", org, "config:", config.GitProjectName)
|
common.LogInfo(" ++ verification complete, org:", org, "config:", config.GitProjectName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Join(errorList...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DefaultStateChecker) ConsistencyCheckProcess() error {
|
func (s *DefaultStateChecker) ConsistencyCheckProcess() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user