mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 02:11:01 +00:00
Fail hard on deprecated pipeline keys (#2180)
so we can drop it in next minor version complete
This commit is contained in:
parent
4bed647000
commit
71666f0500
4 changed files with 20 additions and 22 deletions
|
@ -5,6 +5,8 @@ Some versions need some changes to the server configuration or the pipeline conf
|
||||||
## next (1.1.0)
|
## 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 `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
|
## 1.0.0
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
|
|
||||||
"codeberg.org/6543/xyaml"
|
"codeberg.org/6543/xyaml"
|
||||||
|
|
||||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/constraint"
|
|
||||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,23 +16,15 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// support deprecated branch filter
|
// fail hard on deprecated branch filter
|
||||||
if out.BranchesDontUseIt != nil {
|
if out.BranchesDontUseIt != nil {
|
||||||
if out.When.Constraints == nil {
|
return nil, fmt.Errorf("\"branches:\" filter got removed, use \"branch\" in global when filter")
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// support deprecated pipeline keyword
|
// fail hard on deprecated pipeline keyword
|
||||||
if len(out.PipelineDontUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 {
|
if len(out.PipelineDontUseIt.ContainerList) != 0 {
|
||||||
out.Steps.ContainerList = out.PipelineDontUseIt.ContainerList
|
return nil, fmt.Errorf("\"pipeline:\" got removed, user \"steps:\"")
|
||||||
}
|
}
|
||||||
out.PipelineDontUseIt.ContainerList = nil
|
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,23 +125,27 @@ func TestParse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseLegacy(t *testing.T) {
|
func TestParseLegacy(t *testing.T) {
|
||||||
|
// adjust with https://github.com/woodpecker-ci/woodpecker/pull/2181
|
||||||
sampleYamlPipelineLegacy := `
|
sampleYamlPipelineLegacy := `
|
||||||
pipeline:
|
platform: linux/amd64
|
||||||
|
labels:
|
||||||
|
platform: linux/arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
say hello:
|
say hello:
|
||||||
image: bash
|
image: bash
|
||||||
commands: echo hello
|
commands: echo hello
|
||||||
`
|
`
|
||||||
|
|
||||||
sampleYamlPipelineLegacyIgnore := `
|
sampleYamlPipelineLegacyIgnore := `
|
||||||
|
platform: linux/amd64
|
||||||
|
labels:
|
||||||
|
platform: linux/arm64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
say hello:
|
say hello:
|
||||||
image: bash
|
image: bash
|
||||||
commands: echo hello
|
commands: echo hello
|
||||||
|
|
||||||
pipeline:
|
|
||||||
old crap:
|
|
||||||
image: bash
|
|
||||||
commands: meh!
|
|
||||||
`
|
`
|
||||||
|
|
||||||
workflow1, err := ParseString(sampleYamlPipelineLegacy)
|
workflow1, err := ParseString(sampleYamlPipelineLegacy)
|
||||||
|
|
|
@ -290,7 +290,7 @@ steps:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBranchFilter(t *testing.T) {
|
func TestRootWhenBranchFilter(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
b := StepBuilder{
|
b := StepBuilder{
|
||||||
|
@ -307,7 +307,8 @@ func TestBranchFilter(t *testing.T) {
|
||||||
steps:
|
steps:
|
||||||
xxx:
|
xxx:
|
||||||
image: scratch
|
image: scratch
|
||||||
branches: main
|
when:
|
||||||
|
branch: main
|
||||||
`)},
|
`)},
|
||||||
{Data: []byte(`
|
{Data: []byte(`
|
||||||
steps:
|
steps:
|
||||||
|
|
Loading…
Reference in a new issue