mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
Calculating build steps early on to cut short cases without any runnable steps
This commit is contained in:
parent
c303a4d463
commit
d560643b26
@ -177,6 +177,11 @@ func PostHook(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if zeroSteps(*build, remoteYamlConfigs) {
|
||||||
|
c.String(200, "Step conditions yield zero runnable steps")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if repo.IsGated { // This feature is not clear to me. Reenabling once better understood
|
if repo.IsGated { // This feature is not clear to me. Reenabling once better understood
|
||||||
build.Status = model.StatusBlocked
|
build.Status = model.StatusBlocked
|
||||||
}
|
}
|
||||||
@ -293,6 +298,30 @@ func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bo
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uses pass by value as procBuilder has side effects on build. Something to be fixed
|
||||||
|
func zeroSteps(build model.Build, remoteYamlConfigs []*remote.FileMeta) bool {
|
||||||
|
b := procBuilder{
|
||||||
|
Repo: &model.Repo{},
|
||||||
|
Curr: &build,
|
||||||
|
Last: &model.Build{},
|
||||||
|
Netrc: &model.Netrc{},
|
||||||
|
Secs: []*model.Secret{},
|
||||||
|
Regs: []*model.Registry{},
|
||||||
|
Link: "",
|
||||||
|
Yamls: remoteYamlConfigs,
|
||||||
|
}
|
||||||
|
|
||||||
|
buildItems, err := b.Build()
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(buildItems) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func findOrPersistPipelineConfig(build *model.Build, remoteYamlConfig *remote.FileMeta) (*model.Config, error) {
|
func findOrPersistPipelineConfig(build *model.Build, remoteYamlConfig *remote.FileMeta) (*model.Config, error) {
|
||||||
sha := shasum(remoteYamlConfig.Data)
|
sha := shasum(remoteYamlConfig.Data)
|
||||||
conf, err := Config.Storage.Config.ConfigFindIdentical(build.RepoID, sha)
|
conf, err := Config.Storage.Config.ConfigFindIdentical(build.RepoID, sha)
|
||||||
|
Loading…
Reference in New Issue
Block a user