Skip to content

Commit

Permalink
Fix pipeline validation loop (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
tothszabi authored Nov 11, 2024
1 parent 358984d commit ce48edc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
25 changes: 19 additions & 6 deletions cli/run_util_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,27 @@ func TestValidation(t *testing.T) {
wantErr: "failed to get Bitrise config (bitrise.yml) from base 64 data: Failed to parse bitrise config, error: the dependency between workflow 'b' and workflow 'c' creates a cycle in the graph",
},
{
name: "Valid DAG pipeline",
config: validDAGPipeline,
wantErr: "",
name: "Valid DAG pipeline",
config: validDAGPipeline,
},
{
name: "Valid staged pipeline",
config: validStagedPipeline,
wantErr: "",
name: "Valid staged pipeline",
config: validStagedPipeline,
},
{
name: "The last pipeline is invalid",
config: `
format_version: '13'
pipelines:
pipeline1:
workflows:
a: {}
pipeline2:
workflows: {}
workflows:
a: {}
`,
wantErr: "failed to get Bitrise config (bitrise.yml) from base 64 data: Failed to parse bitrise config, error: pipeline (pipeline2) should have at least 1 stage or workflow",
},
}
for _, tt := range tests {
Expand Down
13 changes: 7 additions & 6 deletions models/models_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,13 @@ func validatePipelines(config *BitriseDataModel) ([]string, error) {
}

if hasStages {
return pipelineWarnings, validateStagedPipeline(pipelineID, &pipeline, config)
}

//TODO: Why is this always true?
if hasWorkflows {
return pipelineWarnings, validateDAGPipeline(pipelineID, &pipeline, config)
if err := validateStagedPipeline(pipelineID, &pipeline, config); err != nil {
return pipelineWarnings, err
}
} else {
if err := validateDAGPipeline(pipelineID, &pipeline, config); err != nil {
return pipelineWarnings, err
}
}
}

Expand Down

0 comments on commit ce48edc

Please sign in to comment.