Skip to content

Commit

Permalink
Remove empty pipeline validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tothszabi committed Nov 11, 2024
1 parent ce48edc commit 56c5796
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions cli/run_util_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ workflows:
c: {}
`

const emptyPipeline = `
format_version: '13'
pipelines:
dag:
workflows: {}
workflows:
a: {}
`

func TestValidation(t *testing.T) {
tests := []struct {
name string
Expand Down Expand Up @@ -184,6 +193,10 @@ func TestValidation(t *testing.T) {
name: "Valid staged pipeline",
config: validStagedPipeline,
},
{
name: "Empty pipeline",
config: emptyPipeline,
},
{
name: "The last pipeline is invalid",
config: `
Expand Down
8 changes: 6 additions & 2 deletions models/models_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,12 @@ func validatePipelines(config *BitriseDataModel) ([]string, error) {

if hasStages && hasWorkflows {
return pipelineWarnings, fmt.Errorf("pipeline (%s) has both stages and workflows", pipelineID)
} else if !hasStages && !hasWorkflows {
return pipelineWarnings, fmt.Errorf("pipeline (%s) should have at least 1 stage or workflow", pipelineID)
}

// A pipeline is considered valid if it has neither stages nor workflows.
// This is useful for the WFE to be able to save a pipeline that is not yet fully defined.
if !hasStages && !hasWorkflows {
continue
}

if hasStages {
Expand Down

0 comments on commit 56c5796

Please sign in to comment.