diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index 2fb7974ec..abe61a830 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -5,6 +5,8 @@ Some versions need some changes to the server configuration or the pipeline conf ## next (1.1.0) - Drop deprecated `CI_BUILD_*`, `CI_PREV_BUILD_*`, `CI_JOB_*`, `*_LINK`, `CI_SYSTEM_ARCH`, `CI_REPO_REMOTE` built-in environment variables +- Drop deprecated `pipeline:` keyword for steps in yaml config +- Drop deprecated `branches:` keyword for global branch filter ## 1.0.0 diff --git a/pipeline/frontend/yaml/parse.go b/pipeline/frontend/yaml/parse.go index 10bfb2d3d..510f273f7 100644 --- a/pipeline/frontend/yaml/parse.go +++ b/pipeline/frontend/yaml/parse.go @@ -5,7 +5,6 @@ import ( "codeberg.org/6543/xyaml" - "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/constraint" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types" ) @@ -17,23 +16,15 @@ func ParseBytes(b []byte) (*types.Workflow, error) { return nil, err } - // support deprecated branch filter + // fail hard on deprecated branch filter if out.BranchesDontUseIt != nil { - if out.When.Constraints == nil { - out.When.Constraints = []constraint.Constraint{{Branch: *out.BranchesDontUseIt}} - } else if len(out.When.Constraints) == 1 && out.When.Constraints[0].Branch.IsEmpty() { - out.When.Constraints[0].Branch = *out.BranchesDontUseIt - } else { - return nil, fmt.Errorf("could not apply deprecated branches filter into global when filter") - } - out.BranchesDontUseIt = nil + return nil, fmt.Errorf("\"branches:\" filter got removed, use \"branch\" in global when filter") } - // support deprecated pipeline keyword - if len(out.PipelineDontUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 { - out.Steps.ContainerList = out.PipelineDontUseIt.ContainerList + // fail hard on deprecated pipeline keyword + if len(out.PipelineDontUseIt.ContainerList) != 0 { + return nil, fmt.Errorf("\"pipeline:\" got removed, user \"steps:\"") } - out.PipelineDontUseIt.ContainerList = nil return out, nil } diff --git a/pipeline/frontend/yaml/parse_test.go b/pipeline/frontend/yaml/parse_test.go index d72eaef38..3f0aed096 100644 --- a/pipeline/frontend/yaml/parse_test.go +++ b/pipeline/frontend/yaml/parse_test.go @@ -125,23 +125,27 @@ func TestParse(t *testing.T) { } func TestParseLegacy(t *testing.T) { + // adjust with https://github.com/woodpecker-ci/woodpecker/pull/2181 sampleYamlPipelineLegacy := ` -pipeline: +platform: linux/amd64 +labels: + platform: linux/arm64 + +steps: say hello: image: bash commands: echo hello ` sampleYamlPipelineLegacyIgnore := ` +platform: linux/amd64 +labels: + platform: linux/arm64 + steps: say hello: image: bash commands: echo hello - -pipeline: - old crap: - image: bash - commands: meh! ` workflow1, err := ParseString(sampleYamlPipelineLegacy) diff --git a/pipeline/stepBuilder_test.go b/pipeline/stepBuilder_test.go index a0ebc1b7c..f875f59d3 100644 --- a/pipeline/stepBuilder_test.go +++ b/pipeline/stepBuilder_test.go @@ -290,7 +290,7 @@ steps: } } -func TestBranchFilter(t *testing.T) { +func TestRootWhenBranchFilter(t *testing.T) { t.Parallel() b := StepBuilder{ @@ -307,7 +307,8 @@ func TestBranchFilter(t *testing.T) { steps: xxx: image: scratch -branches: main +when: + branch: main `)}, {Data: []byte(` steps: