Remove deprecated pipeline settings (#3916)

This commit is contained in:
6543 2024-07-23 13:06:47 +02:00 committed by GitHub
parent bbdeb4622c
commit 1c7c87b8f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 20 additions and 201 deletions

View file

@ -11,6 +11,7 @@ Some versions need some changes to the server configuration or the pipeline conf
## `next` ## `next`
- Compatibility mode of deprecated `pipeline:`, `platform:` and `branches:` pipeline config options are now removed and pipeline will now fail if still in use.
- Deprecated `steps.[name].group` in favor of `steps.[name].depends_on` (see [workflow syntax](./20-usage/20-workflow-syntax.md#depends_on) to learn how to set dependencies) - Deprecated `steps.[name].group` in favor of `steps.[name].depends_on` (see [workflow syntax](./20-usage/20-workflow-syntax.md#depends_on) to learn how to set dependencies)
- Removed `WOODPECKER_ROOT_PATH` and `WOODPECKER_ROOT_URL` config variables. Use `WOODPECKER_HOST` with a path instead - Removed `WOODPECKER_ROOT_PATH` and `WOODPECKER_ROOT_URL` config variables. Use `WOODPECKER_HOST` with a path instead
- Pipelines without a config file will now be skipped instead of failing - Pipelines without a config file will now be skipped instead of failing

View file

@ -215,45 +215,6 @@ func (l *Linter) lintDeprecations(config *WorkflowConfig) (err error) {
return err return err
} }
if parsed.PipelineDoNotUseIt.ContainerList != nil {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please use 'steps:' instead of deprecated 'pipeline:' list",
Data: errors.DeprecationErrorData{
File: config.File,
Field: "pipeline",
Docs: "https://woodpecker-ci.org/docs/next/migrations#next-200",
},
IsWarning: true,
})
}
if parsed.PlatformDoNotUseIt != "" {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please use labels instead of deprecated 'platform' filters",
Data: errors.DeprecationErrorData{
File: config.File,
Field: "platform",
Docs: "https://woodpecker-ci.org/docs/next/migrations#next-200",
},
IsWarning: true,
})
}
if parsed.BranchesDoNotUseIt != nil {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please use global when instead of deprecated 'branches' filter",
Data: errors.DeprecationErrorData{
File: config.File,
Field: "branches",
Docs: "https://woodpecker-ci.org/docs/next/migrations#next-200",
},
IsWarning: true,
})
}
for _, step := range parsed.Steps.ContainerList { for _, step := range parsed.Steps.ContainerList {
if step.Group != "" { if step.Group != "" {
err = multierr.Append(err, &errorTypes.PipelineError{ err = multierr.Append(err, &errorTypes.PipelineError{

View file

@ -165,6 +165,10 @@ func TestLintErrors(t *testing.T) {
from: "steps: { build: { image: golang, settings: { test: 'true' }, environment: [ 'TEST=true' ] } }", from: "steps: { build: { image: golang, settings: { test: 'true' }, environment: [ 'TEST=true' ] } }",
want: "Cannot configure both environment and settings", want: "Cannot configure both environment and settings",
}, },
{
from: "{pipeline: { build: { image: golang, settings: { test: 'true' } } }, when: { branch: main, event: push } }",
want: "Additional property pipeline is not allowed",
},
} }
for _, test := range testdata { for _, test := range testdata {

View file

@ -1,7 +0,0 @@
branches: [main, pages]
steps:
build:
image: golang
commands:
- go test

View file

@ -1,9 +0,0 @@
branches:
include: main
exclude: [develop, feature/*]
steps:
build:
image: golang
commands:
- go test

View file

@ -1,7 +0,0 @@
branches: main
steps:
build:
image: golang
commands:
- go test

View file

@ -1,7 +0,0 @@
platform: linux/amd64
steps:
build:
image: golang:latest
commands:
- go test

View file

@ -19,6 +19,9 @@ steps:
- echo "test" - echo "test"
when: when:
event: push event: push
branch:
include: main
exclude: [develop, feature/*]
when-event-array: when-event-array:
image: alpine image: alpine

View file

@ -20,19 +20,12 @@
"skip_clone": { "skip_clone": {
"type": "boolean" "type": "boolean"
}, },
"branches": {
"$ref": "#/definitions/branches"
},
"when": { "when": {
"$ref": "#/definitions/pipeline_when" "$ref": "#/definitions/workflow_when"
}, },
"steps": { "steps": {
"$ref": "#/definitions/step_list" "$ref": "#/definitions/step_list"
}, },
"pipeline": {
"$ref": "#/definitions/step_list",
"description": "deprecated, use steps"
},
"services": { "services": {
"$ref": "#/definitions/services" "$ref": "#/definitions/services"
}, },
@ -42,9 +35,6 @@
"matrix": { "matrix": {
"$ref": "#/definitions/matrix" "$ref": "#/definitions/matrix"
}, },
"platform": {
"$ref": "#/definitions/platform"
},
"labels": { "labels": {
"$ref": "#/definitions/labels" "$ref": "#/definitions/labels"
}, },
@ -128,55 +118,6 @@
"type": ["boolean", "string", "number", "array", "object"] "type": ["boolean", "string", "number", "array", "object"]
} }
}, },
"branches": {
"description": "deprecated, use when.branch",
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minProperties": 1
},
{
"type": "string"
},
{
"type": "object",
"additionalProperties": false,
"properties": {
"exclude": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minLength": 1
},
{
"type": "string"
}
]
},
"include": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minLength": 1
},
{
"type": "string"
}
]
}
}
}
]
},
"step_list": { "step_list": {
"description": "The steps section defines a list of steps which will be executed serially, in the order in which they are defined. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#steps", "description": "The steps section defines a list of steps which will be executed serially, in the order in which they are defined. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#steps",
"oneOf": [ "oneOf": [
@ -196,22 +137,22 @@
} }
] ]
}, },
"pipeline_when": { "workflow_when": {
"description": "Whole pipelines can be skipped based on conditions. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#when---global-workflow-conditions", "description": "Whole workflow can be skipped based on conditions. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#when---global-workflow-conditions",
"oneOf": [ "oneOf": [
{ {
"type": "array", "type": "array",
"minLength": 1, "minLength": 1,
"items": { "items": {
"$ref": "#/definitions/pipeline_when_condition" "$ref": "#/definitions/workflow_when_condition"
} }
}, },
{ {
"$ref": "#/definitions/pipeline_when_condition" "$ref": "#/definitions/workflow_when_condition"
} }
] ]
}, },
"pipeline_when_condition": { "workflow_when_condition": {
"type": "object", "type": "object",
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
@ -1120,11 +1061,6 @@
"minLength": 1 "minLength": 1
} }
}, },
"platform": {
"description": "deprecated, use labels.platform",
"type": "string",
"additionalProperties": false
},
"labels": { "labels": {
"description": "Configures the labels used for the agent selection. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#labels", "description": "Configures the labels used for the agent selection. Read more: https://woodpecker-ci.org/docs/usage/workflow-syntax#labels",
"type": "object", "type": "object",

View file

@ -32,18 +32,6 @@ func TestSchema(t *testing.T) {
testFile string testFile string
fail bool fail bool
}{ }{
{
name: "Branches",
testFile: ".woodpecker/test-branches.yaml",
},
{
name: "Branches Array",
testFile: ".woodpecker/test-branches-array.yaml",
},
{
name: "Branches exclude & include",
testFile: ".woodpecker/test-branches-exclude-include.yaml",
},
{ {
name: "Clone", name: "Clone",
testFile: ".woodpecker/test-clone.yaml", testFile: ".woodpecker/test-clone.yaml",
@ -84,10 +72,6 @@ func TestSchema(t *testing.T) {
name: "Workspace", name: "Workspace",
testFile: ".woodpecker/test-workspace.yaml", testFile: ".woodpecker/test-workspace.yaml",
}, },
{
name: "Platform",
testFile: ".woodpecker/test-platform.yaml",
},
{ {
name: "Labels", name: "Labels",
testFile: ".woodpecker/test-labels.yaml", testFile: ".woodpecker/test-labels.yaml",

View file

@ -15,11 +15,8 @@
package yaml package yaml
import ( import (
"fmt"
"codeberg.org/6543/xyaml" "codeberg.org/6543/xyaml"
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml/constraint"
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml/types" "go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml/types"
) )
@ -30,37 +27,6 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
// support deprecated branch filter
if out.BranchesDoNotUseIt != nil {
switch {
case out.When.Constraints == nil:
out.When.Constraints = []constraint.Constraint{{Branch: *out.BranchesDoNotUseIt}}
case len(out.When.Constraints) == 1 && out.When.Constraints[0].Branch.IsEmpty():
out.When.Constraints[0].Branch = *out.BranchesDoNotUseIt
default:
return nil, fmt.Errorf("could not apply deprecated branches filter into global when filter")
}
out.BranchesDoNotUseIt = nil
}
// support deprecated pipeline keyword
if len(out.PipelineDoNotUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 {
out.Steps.ContainerList = out.PipelineDoNotUseIt.ContainerList
}
// support deprecated platform filter
if out.PlatformDoNotUseIt != "" {
if out.Labels == nil {
out.Labels = make(map[string]string)
}
if _, set := out.Labels["platform"]; !set {
out.Labels["platform"] = out.PlatformDoNotUseIt
}
out.PlatformDoNotUseIt = ""
}
out.PipelineDoNotUseIt.ContainerList = nil
return out, nil return out, nil
} }

View file

@ -139,10 +139,11 @@ func TestParse(t *testing.T) {
} }
func TestParseLegacy(t *testing.T) { func TestParseLegacy(t *testing.T) {
sampleYamlPipelineLegacy := ` sampleYamlPipeline := `
platform: linux/amd64 labels:
platform: linux/amd64
pipeline: steps:
say hello: say hello:
image: bash image: bash
commands: echo hello commands: echo hello
@ -164,7 +165,7 @@ pipeline:
commands: meh! commands: meh!
` `
workflow1, err := ParseString(sampleYamlPipelineLegacy) workflow1, err := ParseString(sampleYamlPipeline)
if !assert.NoError(t, err) { if !assert.NoError(t, err) {
return return
} }

View file

@ -34,13 +34,6 @@ type (
// Undocumented // Undocumented
Networks WorkflowNetworks `yaml:"networks,omitempty"` Networks WorkflowNetworks `yaml:"networks,omitempty"`
Volumes WorkflowVolumes `yaml:"volumes,omitempty"` Volumes WorkflowVolumes `yaml:"volumes,omitempty"`
// Deprecated
PlatformDoNotUseIt string `yaml:"platform,omitempty"` // TODO: remove in next major version
// Deprecated
BranchesDoNotUseIt *constraint.List `yaml:"branches,omitempty"` // TODO: remove in next major version
// Deprecated
PipelineDoNotUseIt ContainerList `yaml:"pipeline,omitempty"` // TODO: remove in next major version
} }
// Workspace defines a pipeline workspace. // Workspace defines a pipeline workspace.

View file

@ -348,10 +348,10 @@ func TestBranchFilter(t *testing.T) {
{Data: []byte(` {Data: []byte(`
when: when:
event: push event: push
branch: main
steps: steps:
xxx: xxx:
image: scratch image: scratch
branches: main
`)}, `)},
{Data: []byte(` {Data: []byte(`
when: when: