From 56c57965bd5d8427f3d9fa9a89f109bc4c1953cf Mon Sep 17 00:00:00 2001 From: Szabolcs Toth <54896607+tothszabi@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:30:42 +0100 Subject: [PATCH] Remove empty pipeline validation --- cli/run_util_pipeline_test.go | 13 +++++++++++++ models/models_methods.go | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cli/run_util_pipeline_test.go b/cli/run_util_pipeline_test.go index ed721c17..6cd06400 100644 --- a/cli/run_util_pipeline_test.go +++ b/cli/run_util_pipeline_test.go @@ -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 @@ -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: ` diff --git a/models/models_methods.go b/models/models_methods.go index 604d296f..f067d46e 100644 --- a/models/models_methods.go +++ b/models/models_methods.go @@ -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 {