From 58b175e2aadf962d3e146b23702a462ea63e5c7b Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Wed, 22 Jan 2025 12:51:15 -0500 Subject: [PATCH] disallow uses: with a nested pipeline Signed-off-by: Jason Hall --- pkg/config/config.go | 4 ++++ pkg/config/config_test.go | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2748aa5a0..8e6b89781 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1526,6 +1526,10 @@ func validatePipelines(ps []Pipeline) error { return fmt.Errorf("pipeline cannot contain both uses %q and runs", p.Uses) } + if p.Uses != "" && len(p.Pipeline) > 0 { + return fmt.Errorf("pipeline cannot contain both uses %q and a pipeline", p.Uses) + } + if len(p.With) > 0 && p.Runs != "" { return fmt.Errorf("pipeline cannot contain both with and runs") } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e049d9c3b..d71de6829 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -407,6 +407,14 @@ func TestValidatePipelines(t *testing.T) { }, wantErr: true, }, + + { + name: "invalid pipeline with both uses and pipeline", + p: []Pipeline{ + {Uses: "deploy", Pipeline: []Pipeline{{Runs: "somescript.sh"}}}, + }, + wantErr: true, + }, } for _, tt := range tests {