mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 19:31:05 +00:00
Revert breaking pipeline changes (#2677)
Revert #2180 and #2480 so we can release v2.0 without breaking changes in pipeline config. After merging #2476 we should apply these changes to a new v2. After merging this, we should be ready for the 2.0 release. --------- Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
parent
f270be4940
commit
c1faa95d8f
6 changed files with 85 additions and 6 deletions
|
@ -5,8 +5,6 @@ Some versions need some changes to the server configuration or the pipeline conf
|
|||
## next (2.0.0)
|
||||
|
||||
- Dropped deprecated `CI_BUILD_*`, `CI_PREV_BUILD_*`, `CI_JOB_*`, `*_LINK`, `CI_SYSTEM_ARCH`, `CI_REPO_REMOTE` built-in environment variables
|
||||
- Dropped deprecated `pipeline:` keyword in favor of `steps:` in pipeline config
|
||||
- Dropped deprecated `branches:` filter in favor of global [`when.branch`](./20-usage/20-workflow-syntax.md#branch-1) filter
|
||||
- Deprecated `platform:` filter in favor of `labels:`, [read more](./20-usage/20-workflow-syntax.md#filter-by-platform)
|
||||
- Secrets `event` property was renamed to `events` and `image` to `images` as both are lists. The new property `events` / `images` has to be used in the api and as cli argument. The old properties `event` and `image` were removed.
|
||||
- The secrets `plugin_only` option was removed. Secrets with images are now always only available for plugins using listed by the `images` property. Existing secrets with a list of `images` will now only be available to the listed images if they are used as a plugin.
|
||||
|
|
|
@ -15,9 +15,13 @@
|
|||
package yaml
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"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/base"
|
||||
)
|
||||
|
||||
// ParseBytes parses the configuration from bytes b.
|
||||
|
@ -28,6 +32,35 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// support 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
|
||||
}
|
||||
|
||||
// support deprecated pipeline keyword
|
||||
if len(out.PipelineDontUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 {
|
||||
out.Steps.ContainerList = out.PipelineDontUseIt.ContainerList
|
||||
}
|
||||
|
||||
// support deprecated platform filter
|
||||
if out.PlatformDontUseIt != "" {
|
||||
if out.Labels == nil {
|
||||
out.Labels = make(base.SliceOrMap)
|
||||
}
|
||||
if _, set := out.Labels["platform"]; !set {
|
||||
out.Labels["platform"] = out.PlatformDontUseIt
|
||||
}
|
||||
out.PlatformDontUseIt = ""
|
||||
}
|
||||
out.PipelineDontUseIt.ContainerList = nil
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/franela/goblin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata"
|
||||
yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
|
||||
|
@ -137,6 +138,47 @@ func TestParse(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestParseLegacy(t *testing.T) {
|
||||
sampleYamlPipelineLegacy := `
|
||||
platform: linux/amd64
|
||||
|
||||
pipeline:
|
||||
say hello:
|
||||
image: bash
|
||||
commands: echo hello
|
||||
`
|
||||
|
||||
sampleYamlPipelineLegacyIgnore := `
|
||||
platform: windows/amd64
|
||||
labels:
|
||||
platform: linux/amd64
|
||||
|
||||
steps:
|
||||
say hello:
|
||||
image: bash
|
||||
commands: echo hello
|
||||
|
||||
pipeline:
|
||||
old crap:
|
||||
image: bash
|
||||
commands: meh!
|
||||
`
|
||||
|
||||
workflow1, err := ParseString(sampleYamlPipelineLegacy)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
workflow2, err := ParseString(sampleYamlPipelineLegacyIgnore)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
assert.EqualValues(t, workflow1, workflow2)
|
||||
assert.Len(t, workflow1.Steps.ContainerList, 1)
|
||||
assert.EqualValues(t, "say hello", workflow1.Steps.ContainerList[0].Name)
|
||||
}
|
||||
|
||||
var sampleYaml = `
|
||||
image: hello-world
|
||||
when:
|
||||
|
|
|
@ -36,6 +36,13 @@ type (
|
|||
Cache base.StringOrSlice `yaml:"cache,omitempty"`
|
||||
Networks WorkflowNetworks `yaml:"networks,omitempty"`
|
||||
Volumes WorkflowVolumes `yaml:"volumes,omitempty"`
|
||||
|
||||
// Deprecated
|
||||
PlatformDontUseIt string `yaml:"platform,omitempty"` // TODO: remove in next major version
|
||||
// Deprecated
|
||||
BranchesDontUseIt *constraint.List `yaml:"branches,omitempty"` // TODO: remove in next major version
|
||||
// Deprecated
|
||||
PipelineDontUseIt ContainerList `yaml:"pipeline,omitempty"` // TODO: remove in next major version
|
||||
}
|
||||
|
||||
// Workspace defines a pipeline workspace.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"branches": { "$ref": "#/definitions/branches" },
|
||||
"when": { "$ref": "#/definitions/pipeline_when" },
|
||||
"steps": { "$ref": "#/definitions/step_list" },
|
||||
"pipeline": { "$ref": "#/definitions/step_list", "description": "depricated, use steps" },
|
||||
"pipeline": { "$ref": "#/definitions/step_list", "description": "deprecated, use steps" },
|
||||
"services": { "$ref": "#/definitions/services" },
|
||||
"workspace": { "$ref": "#/definitions/workspace" },
|
||||
"matrix": { "$ref": "#/definitions/matrix" },
|
||||
|
|
|
@ -290,7 +290,7 @@ steps:
|
|||
}
|
||||
}
|
||||
|
||||
func TestRootWhenBranchFilter(t *testing.T) {
|
||||
func TestBranchFilter(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
b := StepBuilder{
|
||||
|
@ -307,8 +307,7 @@ func TestRootWhenBranchFilter(t *testing.T) {
|
|||
steps:
|
||||
xxx:
|
||||
image: scratch
|
||||
when:
|
||||
branch: main
|
||||
branches: main
|
||||
`)},
|
||||
{Data: []byte(`
|
||||
steps:
|
||||
|
|
Loading…
Reference in a new issue