Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old pipeline options #4016

Merged
merged 14 commits into from
Aug 15, 2024
12 changes: 6 additions & 6 deletions docs/docs/91-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Some versions need some changes to the server configuration or the pipeline conf

- Removed `WOODPECKER_DEV_OAUTH_HOST` and `WOODPECKER_DEV_GITEA_OAUTH_URL` use `WOODPECKER_EXPERT_FORGE_OAUTH_HOST`
- 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)
- Removed `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
- Pipelines without a config file will now be skipped instead of failing
- Removed implicitly defined `regcred` image pull secret name. Set it explicitly via `WOODPECKER_BACKEND_K8S_PULL_SECRET_NAMES`
- Deprecated `includes` and `excludes` support from **event** filter
- Deprecated uppercasing all secret env vars, instead, the value of the `secrets` property is used. [Read more](./20-usage/40-secrets.md#use-secrets-in-commands)
- Deprecated alternative names for secrets, use `environment` with `from_secret`
- Deprecated slice definition for env vars
- Deprecated `environment` filter, use `when.evaluate`
- Removed `includes` and `excludes` support from **event** filter
- Removed uppercasing all secret env vars, instead, the value of the `secrets` property is used. [Read more](./20-usage/40-secrets.md#use-secrets-in-commands)
- Removed alternative names for secrets, use `environment` with `from_secret`
- Removed slice definition for env vars
- Removed `environment` filter, use `when.evaluate`
- Removed `WOODPECKER_WEBHOOK_HOST` in favor of `WOODPECKER_EXPERT_WEBHOOK_HOST`
- Migrated to rfc9421 for webhook signatures
- Renamed `start_time`, `end_time`, `created_at`, `started_at`, `finished_at` and `reviewed_at` JSON fields to `started`, `finished`, `created`, `started`, `finished`, `reviewed`
Expand Down
1 change: 0 additions & 1 deletion pipeline/frontend/yaml/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ func (c *Compiler) Compile(conf *yaml_types.Workflow) (*backend_types.Config, er
step: step,
position: pos,
name: container.Name,
group: container.Group,
dependsOn: container.DependsOn,
})
}
Expand Down
14 changes: 7 additions & 7 deletions pipeline/frontend/yaml/compiler/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,17 @@ func TestCompilerCompile(t *testing.T) {
},
},
{
name: "workflow with three steps and one group",
name: "workflow with three steps",
fronConf: &yaml_types.Workflow{Steps: yaml_types.ContainerList{ContainerList: []*yaml_types.Container{{
Name: "echo env",
Image: "bash",
Commands: []string{"env"},
}, {
Name: "parallel echo 1",
Group: "parallel",
Image: "bash",
Commands: []string{"echo 1"},
}, {
Name: "parallel echo 2",
Group: "parallel",
Image: "bash",
Commands: []string{"echo 2"},
}}}},
Expand Down Expand Up @@ -194,7 +192,9 @@ func TestCompilerCompile(t *testing.T) {
WorkingDir: "/test/src/github.com/octocat/hello-world",
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"parallel echo 1"}}},
ExtraHosts: []backend_types.HostAlias{},
}, {
}},
}, {
Steps: []*backend_types.Step{{
Name: "parallel echo 2",
Type: backend_types.StepTypeCommands,
Image: "bash",
Expand All @@ -206,8 +206,8 @@ func TestCompilerCompile(t *testing.T) {
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"parallel echo 2"}}},
ExtraHosts: []backend_types.HostAlias{},
}},
}},
},
},
}},
},
{
name: "workflow with three steps and depends_on",
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestCompilerCompile(t *testing.T) {
Name: "step",
Image: "bash",
Commands: []string{"env"},
Secrets: yaml_types.Secrets{Secrets: []*yaml_types.Secret{{Source: "missing", Target: "missing"}}},
Secrets: []string{"missing"},
}}}},
backConf: nil,
expectedErr: "secret \"missing\" not found",
Expand Down
11 changes: 4 additions & 7 deletions pipeline/frontend/yaml/compiler/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,17 @@ func (c *Compiler) createProcess(container *yaml_types.Container, stepType backe
return nil, err
}

for _, requested := range container.Secrets.Secrets {
secretValue, err := getSecretValue(requested.Source)
for _, requested := range container.Secrets {
secretValue, err := getSecretValue(requested)
if err != nil {
return nil, err
}

toUpperTarget := strings.ToUpper(requested.Target)
if !environmentAllowed(toUpperTarget, stepType) {
if !environmentAllowed(requested, stepType) {
continue
}

environment[requested.Target] = secretValue
// TODO: deprecated, remove in 3.x
environment[toUpperTarget] = secretValue
environment[requested] = secretValue
}

if utils.MatchImage(container.Image, c.escalated...) && container.IsPlugin() {
Expand Down
20 changes: 5 additions & 15 deletions pipeline/frontend/yaml/compiler/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type dagCompilerStep struct {
step *backend_types.Step
position int
name string
group string
dependsOn []string
}

Expand All @@ -51,25 +50,16 @@ func (c dagCompiler) compile() ([]*backend_types.Stage, error) {
if c.isDAG() {
return c.compileByDependsOn()
}
return c.compileByGroup()
return c.compileSequence()
}

func (c dagCompiler) compileByGroup() ([]*backend_types.Stage, error) {
func (c dagCompiler) compileSequence() ([]*backend_types.Stage, error) {
stages := make([]*backend_types.Stage, 0, len(c.steps))
var currentStage *backend_types.Stage
var currentGroup string

for _, s := range c.steps {
// create a new stage if current step is in a new group compared to last one
if currentStage == nil || currentGroup != s.group || s.group == "" {
currentGroup = s.group

currentStage = new(backend_types.Stage)
stages = append(stages, currentStage)
}

// add step to current stage
currentStage.Steps = append(currentStage.Steps, s.step)
stages = append(stages, &backend_types.Stage{
Steps: []*backend_types.Step{s.step},
})
}

return stages, nil
Expand Down
3 changes: 0 additions & 3 deletions pipeline/frontend/yaml/compiler/dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestConvertDAGToStages(t *testing.T) {
"echo env": {
position: 0,
name: "echo env",
group: "",
step: &backend_types.Step{
UUID: "01HJDPEW6R7J0JBE3F1T7Q0TYX",
Type: "commands",
Expand All @@ -96,7 +95,6 @@ func TestConvertDAGToStages(t *testing.T) {
"echo 1": {
position: 1,
name: "echo 1",
group: "",
dependsOn: []string{"echo env", "echo 2"},
step: &backend_types.Step{
UUID: "01HJDPF770QGRZER8RF79XVS4M",
Expand All @@ -108,7 +106,6 @@ func TestConvertDAGToStages(t *testing.T) {
"echo 2": {
position: 2,
name: "echo 2",
group: "",
step: &backend_types.Step{
UUID: "01HJDPFF5RMEYZW0YTGR1Y1ZR0",
Type: "commands",
Expand Down
8 changes: 3 additions & 5 deletions pipeline/frontend/yaml/constraint/constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"maps"
"path"
"slices"
"strings"

"github.com/bmatcuk/doublestar/v4"
Expand All @@ -41,16 +42,14 @@ type (
Repo List
Instance List
Platform List
Environment List
Branch List
Cron List
Status List
Matrix Map
Local yamlBaseTypes.BoolTrue
Path Path
Evaluate string `yaml:"evaluate,omitempty"`
// TODO: change to StringOrSlice in 3.x
Event List
Event yamlBaseTypes.StringOrSlice
}

// List defines a runtime constraint for exclude & include string slices.
Expand Down Expand Up @@ -164,8 +163,7 @@ func (c *Constraint) Match(m metadata.Metadata, global bool, env map[string]stri
}

match = match && c.Platform.Match(m.Sys.Platform) &&
c.Environment.Match(m.Curr.DeployTo) &&
c.Event.Match(m.Curr.Event) &&
(len(c.Event) == 0 || slices.Contains(c.Event, m.Curr.Event)) &&
c.Repo.Match(path.Join(m.Repo.Owner, m.Repo.Name)) &&
c.Ref.Match(m.Curr.Commit.Ref) &&
c.Instance.Match(m.Sys.Host)
Expand Down
100 changes: 2 additions & 98 deletions pipeline/frontend/yaml/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,102 +215,6 @@ func (l *Linter) lintDeprecations(config *WorkflowConfig) (err error) {
return err
}

for _, step := range parsed.Steps.ContainerList {
if step.Group != "" {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please use depends_on instead of deprecated 'group' setting",
Data: errors.DeprecationErrorData{
File: config.File,
Field: "steps." + step.Name + ".group",
Docs: "https://woodpecker-ci.org/docs/next/usage/workflow-syntax#depends_on",
},
IsWarning: true,
})
}
}

for i, c := range parsed.When.Constraints {
if len(c.Event.Exclude) != 0 {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please only use allow lists for events",
Data: errors.DeprecationErrorData{
File: config.File,
Field: fmt.Sprintf("when[%d].event", i),
Docs: "https://woodpecker-ci.org/docs/usage/workflow-syntax#event-1",
},
IsWarning: true,
})
}
}

for _, step := range parsed.Steps.ContainerList {
for i, c := range step.When.Constraints {
if len(c.Event.Exclude) != 0 {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Please only use allow lists for events",
Data: errors.DeprecationErrorData{
File: config.File,
Field: fmt.Sprintf("steps.%s.when[%d].event", step.Name, i),
Docs: "https://woodpecker-ci.org/docs/usage/workflow-syntax#event",
},
IsWarning: true,
})
}
}
}

for _, step := range parsed.Steps.ContainerList {
for i, c := range step.Secrets.Secrets {
if c.Source != c.Target {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "Secrets alternative names are deprecated, use environment with from_secret",
Data: errors.DeprecationErrorData{
File: config.File,
Field: fmt.Sprintf("steps.%s.secrets[%d]", step.Name, i),
Docs: "https://woodpecker-ci.org/docs/usage/secrets#use-secrets-in-settings-and-environment",
},
IsWarning: true,
})
}
}
}

for i, c := range parsed.When.Constraints {
if !c.Environment.IsEmpty() {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "environment filters are deprecated, use evaluate with CI_PIPELINE_DEPLOY_TARGET",
Data: errors.DeprecationErrorData{
File: config.File,
Field: fmt.Sprintf("when[%d].environment", i),
Docs: "https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate",
},
IsWarning: true,
})
}
}

for _, step := range parsed.Steps.ContainerList {
for i, c := range step.When.Constraints {
if !c.Environment.IsEmpty() {
err = multierr.Append(err, &errorTypes.PipelineError{
Type: errorTypes.PipelineErrorTypeDeprecation,
Message: "environment filters are deprecated, use evaluate with CI_PIPELINE_DEPLOY_TARGET",
Data: errors.DeprecationErrorData{
File: config.File,
Field: fmt.Sprintf("steps.%s.when[%d].environment", step.Name, i),
Docs: "https://woodpecker-ci.org/docs/usage/workflow-syntax#evaluate",
},
IsWarning: true,
})
}
}
}

return err
}

Expand All @@ -323,7 +227,7 @@ func (l *Linter) lintBadHabits(config *WorkflowConfig) (err error) {

rootEventFilters := len(parsed.When.Constraints) > 0
for _, c := range parsed.When.Constraints {
if len(c.Event.Include) == 0 {
if len(c.Event) == 0 {
rootEventFilters = false
break
}
Expand All @@ -337,7 +241,7 @@ func (l *Linter) lintBadHabits(config *WorkflowConfig) (err error) {
} else {
stepEventIndex := -1
for i, c := range step.When.Constraints {
if len(c.Event.Include) == 0 {
if len(c.Event) == 0 {
stepEventIndex = i
break
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/frontend/yaml/linter/linter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestLintErrors(t *testing.T) {
want: "Cannot configure both entrypoint and settings",
},
{
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",
},
{
Expand Down
18 changes: 1 addition & 17 deletions pipeline/frontend/yaml/linter/schema/.woodpecker/test-step.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,14 @@ steps:
commands:
- go test

environment-array:
image: golang
environment:
- CGO=0
- GOOS=linux
- GOARCH=amd64
commands:
- go test

secrets:
image: docker
commands:
- echo $DOCKER_USERNAME
- echo $DOCKER_PASSWORD
secrets:
- docker_username
- source: docker_prod_password
target: docker_password

group:
group: test
image: golang
commands:
- go test
- docker_prod_password

detached:
image: redis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ steps:
- deployment
- release

when-event-exclude-pull_request_closed:
image: alpine
commands:
- echo "test"
when:
event:
exclude: pull_request_closed

when-ref:
image: alpine
commands:
Expand Down Expand Up @@ -78,7 +70,6 @@ steps:
commands:
- echo "test"
when:
environment: production
event: deployment

when-matrix:
Expand Down
Loading