diff --git a/docs/docs/20-usage/20-pipeline-syntax.md b/docs/docs/20-usage/20-pipeline-syntax.md index e334a45148..f97def9f31 100644 --- a/docs/docs/20-usage/20-pipeline-syntax.md +++ b/docs/docs/20-usage/20-pipeline-syntax.md @@ -603,26 +603,6 @@ Woodpecker has integrated support for matrix builds. Woodpecker executes a separ For more details check the [matrix build docs](./30-matrix-workflows.md). -## `platform` - -To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key. -Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`. - -Example: - -Assuming we have two agents, one `arm` and one `amd64`. Previously this pipeline would have executed on **either agent**, as Woodpecker is not fussy about where it runs the pipelines. By setting the following option it will only be executed on an agent with the platform `linux/arm64`. - -```diff -+platform: linux/arm64 - -steps: - build: - image: golang - commands: - - go build - - go test -``` - ## `labels` You can set labels for your pipeline to select an agent to execute the pipeline on. An agent will pick up and run a pipeline when **every** label assigned to a pipeline matches the agents labels. @@ -648,6 +628,23 @@ steps: - go test ``` +### Filter by platform + +To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key. +Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`. + +Example: + +Assuming we have two agents, one `linux/arm` and one `linux/amd64`. Previously this pipeline would have executed on **either agent**, as Woodpecker is not fussy about where it runs the pipelines. By setting the following option it will only be executed on an agent with the platform `linux/arm64`. + +```diff ++labels: ++ platform: linux/arm64 + +steps: + [...] +``` + ## `variables` Woodpecker supports [YAML anchors & aliases](https://yaml.org/spec/1.2.2/#3222-anchors-and-aliases) in the pipeline configuration. These can be used as variables to not repeat yourself. diff --git a/docs/docs/91-migrations.md b/docs/docs/91-migrations.md index abe61a830c..5047e47528 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -7,6 +7,7 @@ Some versions need some changes to the server configuration or the pipeline conf - 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 +- Deprecate `platform:` filter in favor of `labels:`, [read more](./20-usage/20-pipeline-syntax.md#filter-by-platform) ## 1.0.0 diff --git a/docs/versioned_docs/version-1.0/20-usage/20-pipeline-syntax.md b/docs/versioned_docs/version-1.0/20-usage/20-pipeline-syntax.md index f87136164a..6e632a1067 100644 --- a/docs/versioned_docs/version-1.0/20-usage/20-pipeline-syntax.md +++ b/docs/versioned_docs/version-1.0/20-usage/20-pipeline-syntax.md @@ -605,6 +605,10 @@ For more details check the [matrix build docs](./30-matrix-workflows.md). ## `platform` +:::warning +will be deprecated with v1.1.0 in favor of labels. +::: + To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key. Have a look at the official [go docs](https://go.dev/doc/install/source) for the available platforms. The syntax of the platform is `GOOS/GOARCH` like `linux/arm64` or `linux/amd64`. diff --git a/pipeline/frontend/yaml/parse.go b/pipeline/frontend/yaml/parse.go index 510f273f77..79a0a07ebe 100644 --- a/pipeline/frontend/yaml/parse.go +++ b/pipeline/frontend/yaml/parse.go @@ -6,6 +6,7 @@ import ( "codeberg.org/6543/xyaml" "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. @@ -26,6 +27,17 @@ func ParseBytes(b []byte) (*types.Workflow, error) { return nil, fmt.Errorf("\"pipeline:\" got removed, user \"steps:\"") } + // 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 = "" + } + return out, nil } diff --git a/pipeline/frontend/yaml/parse_test.go b/pipeline/frontend/yaml/parse_test.go index 3f0aed096b..dc417649da 100644 --- a/pipeline/frontend/yaml/parse_test.go +++ b/pipeline/frontend/yaml/parse_test.go @@ -125,11 +125,8 @@ func TestParse(t *testing.T) { } func TestParseLegacy(t *testing.T) { - // adjust with https://github.com/woodpecker-ci/woodpecker/pull/2181 sampleYamlPipelineLegacy := ` platform: linux/amd64 -labels: - platform: linux/arm64 steps: say hello: @@ -138,9 +135,9 @@ steps: ` sampleYamlPipelineLegacyIgnore := ` -platform: linux/amd64 +platform: windows/amd64 labels: - platform: linux/arm64 + platform: linux/amd64 steps: say hello: diff --git a/pipeline/frontend/yaml/types/base/map.go b/pipeline/frontend/yaml/types/base/map.go index 4f1fa23080..808bc1ad9c 100644 --- a/pipeline/frontend/yaml/types/base/map.go +++ b/pipeline/frontend/yaml/types/base/map.go @@ -6,7 +6,7 @@ import ( "strings" ) -// SliceOrMap represents a slice or a map of strings. +// SliceOrMap represents a map of strings, string slice are converted into a map type SliceOrMap map[string]string // UnmarshalYAML implements the Unmarshaler interface. diff --git a/pipeline/frontend/yaml/types/workflow.go b/pipeline/frontend/yaml/types/workflow.go index e5503c7475..04abd729e0 100644 --- a/pipeline/frontend/yaml/types/workflow.go +++ b/pipeline/frontend/yaml/types/workflow.go @@ -9,7 +9,6 @@ type ( // Workflow defines a workflow configuration. Workflow struct { When constraint.When `yaml:"when,omitempty"` - Platform string `yaml:"platform,omitempty"` Workspace Workspace `yaml:"workspace,omitempty"` Clone ContainerList `yaml:"clone,omitempty"` Steps ContainerList `yaml:"steps,omitempty"` @@ -18,10 +17,14 @@ type ( DependsOn []string `yaml:"depends_on,omitempty"` RunsOn []string `yaml:"runs_on,omitempty"` SkipClone bool `yaml:"skip_clone"` + // Undocumented Cache base.StringOrSlice `yaml:"cache,omitempty"` Networks WorkflowNetworks `yaml:"networks,omitempty"` Volumes WorkflowVolumes `yaml:"volumes,omitempty"` + + // Deprecated + PlatformDontUseIt string `yaml:"platform,omitempty"` // TODO: remove after v1.2.x version // Deprecated BranchesDontUseIt *constraint.List `yaml:"branches,omitempty"` // TODO: remove after v1.1.x version // Deprecated diff --git a/pipeline/stepBuilder.go b/pipeline/stepBuilder.go index a8cc86d2b8..827d4719f9 100644 --- a/pipeline/stepBuilder.go +++ b/pipeline/stepBuilder.go @@ -54,7 +54,6 @@ type StepBuilder struct { type Item struct { Workflow *model.Workflow - Platform string Labels map[string]string DependsOn []string RunsOn []string @@ -171,7 +170,6 @@ func (b *StepBuilder) genItemForWorkflow(workflow *model.Workflow, axis matrix.A Labels: parsed.Labels, DependsOn: parsed.DependsOn, RunsOn: parsed.RunsOn, - Platform: parsed.Platform, } if item.Labels == nil { item.Labels = map[string]string{} diff --git a/server/pipeline/queue.go b/server/pipeline/queue.go index 2dd1d7c237..efce2f649e 100644 --- a/server/pipeline/queue.go +++ b/server/pipeline/queue.go @@ -37,7 +37,6 @@ func queuePipeline(repo *model.Repo, pipelineItems []*pipeline.Item) error { for k, v := range item.Labels { task.Labels[k] = v } - task.Labels["platform"] = item.Platform task.Labels["repo"] = repo.FullName task.Dependencies = taskIds(item.DependsOn, pipelineItems) task.RunOn = item.RunsOn