1
0
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:
Laszlo Fogas 2019-07-19 10:13:02 +02:00
parent c303a4d463
commit d560643b26

View File

@ -177,6 +177,11 @@ func PostHook(c *gin.Context) {
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
build.Status = model.StatusBlocked
}
@ -293,6 +298,30 @@ func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) bo
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) {
sha := shasum(remoteYamlConfig.Data)
conf, err := Config.Storage.Config.ConfigFindIdentical(build.RepoID, sha)