You've already forked woodpecker
							
							
				mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-30 23:27:39 +02:00 
			
		
		
		
	Calculating build steps early on to cut short cases without any runnable steps
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user