diff --git a/docs/docs/20-usage/20-pipeline-syntax.md b/docs/docs/20-usage/20-pipeline-syntax.md index f97def9f31..e334a45148 100644 --- a/docs/docs/20-usage/20-pipeline-syntax.md +++ b/docs/docs/20-usage/20-pipeline-syntax.md @@ -603,6 +603,26 @@ 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. @@ -628,23 +648,6 @@ 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 5047e47528..abe61a830c 100644 --- a/docs/docs/91-migrations.md +++ b/docs/docs/91-migrations.md @@ -7,7 +7,6 @@ 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 dd8bc6f555..4130cf55ae 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 @@ -612,10 +612,6 @@ 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 78457dad78..ed369c1272 100644 --- a/pipeline/frontend/yaml/parse.go +++ b/pipeline/frontend/yaml/parse.go @@ -20,7 +20,6 @@ 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. @@ -41,17 +40,6 @@ func ParseBytes(b []byte) (*types.Workflow, error) { return nil, fmt.Errorf("\"pipeline:\" got removed, use \"steps:\" instead") } - // 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 da5d75821b..5e35cf1d84 100644 --- a/pipeline/frontend/yaml/parse_test.go +++ b/pipeline/frontend/yaml/parse_test.go @@ -139,8 +139,11 @@ 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: @@ -149,9 +152,9 @@ steps: ` sampleYamlPipelineLegacyIgnore := ` -platform: windows/amd64 +platform: linux/amd64 labels: - platform: linux/amd64 + platform: linux/arm64 steps: say hello: diff --git a/pipeline/frontend/yaml/types/base/map.go b/pipeline/frontend/yaml/types/base/map.go index d9777c5a67..35de13cdbf 100644 --- a/pipeline/frontend/yaml/types/base/map.go +++ b/pipeline/frontend/yaml/types/base/map.go @@ -20,7 +20,7 @@ import ( "strings" ) -// SliceOrMap represents a map of strings, string slice are converted into a map +// SliceOrMap represents a slice or a map of strings. 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 fd3afcf924..5a7084091a 100644 --- a/pipeline/frontend/yaml/types/workflow.go +++ b/pipeline/frontend/yaml/types/workflow.go @@ -23,6 +23,7 @@ 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"` @@ -31,14 +32,10 @@ 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 827d4719f9..a8cc86d2b8 100644 --- a/pipeline/stepBuilder.go +++ b/pipeline/stepBuilder.go @@ -54,6 +54,7 @@ type StepBuilder struct { type Item struct { Workflow *model.Workflow + Platform string Labels map[string]string DependsOn []string RunsOn []string @@ -170,6 +171,7 @@ 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 50ff9011f3..51e9f3eed9 100644 --- a/server/pipeline/queue.go +++ b/server/pipeline/queue.go @@ -37,6 +37,7 @@ 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