Skip to content

Commit 0fab6b1

Browse files
committed
Revert "Deprecate "platform" filter in favour of "labels" (woodpecker-ci#2181)"
This reverts commit 63d5c40.
1 parent 54b590b commit 0fab6b1

File tree

9 files changed

+30
-41
lines changed

9 files changed

+30
-41
lines changed

docs/docs/20-usage/20-pipeline-syntax.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,26 @@ Woodpecker has integrated support for matrix builds. Woodpecker executes a separ
603603

604604
For more details check the [matrix build docs](./30-matrix-workflows.md).
605605

606+
## `platform`
607+
608+
To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
609+
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`.
610+
611+
Example:
612+
613+
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`.
614+
615+
```diff
616+
+platform: linux/arm64
617+
618+
steps:
619+
build:
620+
image: golang
621+
commands:
622+
- go build
623+
- go test
624+
```
625+
606626
## `labels`
607627

608628
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:
628648
- go test
629649
```
630650
631-
### Filter by platform
632-
633-
To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
634-
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`.
635-
636-
Example:
637-
638-
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`.
639-
640-
```diff
641-
+labels:
642-
+ platform: linux/arm64
643-
644-
steps:
645-
[...]
646-
```
647-
648651
## `variables`
649652

650653
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.

docs/docs/91-migrations.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Some versions need some changes to the server configuration or the pipeline conf
77
- Drop deprecated `CI_BUILD_*`, `CI_PREV_BUILD_*`, `CI_JOB_*`, `*_LINK`, `CI_SYSTEM_ARCH`, `CI_REPO_REMOTE` built-in environment variables
88
- Drop deprecated `pipeline:` keyword for steps in yaml config
99
- Drop deprecated `branches:` keyword for global branch filter
10-
- Deprecate `platform:` filter in favor of `labels:`, [read more](./20-usage/20-pipeline-syntax.md#filter-by-platform)
1110

1211
## 1.0.0
1312

docs/versioned_docs/version-1.0/20-usage/20-pipeline-syntax.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,6 @@ For more details check the [matrix build docs](./30-matrix-workflows.md).
612612

613613
## `platform`
614614

615-
:::warning
616-
will be deprecated with v1.1.0 in favor of labels.
617-
:::
618-
619615
To configure your pipeline to only be executed on an agent with a specific platform, you can use the `platform` key.
620616
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`.
621617

pipeline/frontend/yaml/parse.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"codeberg.org/6543/xyaml"
2121

2222
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
23-
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
2423
)
2524

2625
// ParseBytes parses the configuration from bytes b.
@@ -41,17 +40,6 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
4140
return nil, fmt.Errorf("\"pipeline:\" got removed, use \"steps:\" instead")
4241
}
4342

44-
// support deprecated platform filter
45-
if out.PlatformDontUseIt != "" {
46-
if out.Labels == nil {
47-
out.Labels = make(base.SliceOrMap)
48-
}
49-
if _, set := out.Labels["platform"]; !set {
50-
out.Labels["platform"] = out.PlatformDontUseIt
51-
}
52-
out.PlatformDontUseIt = ""
53-
}
54-
5543
return out, nil
5644
}
5745

pipeline/frontend/yaml/parse_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ func TestParse(t *testing.T) {
139139
}
140140

141141
func TestParseLegacy(t *testing.T) {
142+
// adjust with https://github.com/woodpecker-ci/woodpecker/pull/2181
142143
sampleYamlPipelineLegacy := `
143144
platform: linux/amd64
145+
labels:
146+
platform: linux/arm64
144147
145148
steps:
146149
say hello:
@@ -149,9 +152,9 @@ steps:
149152
`
150153

151154
sampleYamlPipelineLegacyIgnore := `
152-
platform: windows/amd64
155+
platform: linux/amd64
153156
labels:
154-
platform: linux/amd64
157+
platform: linux/arm64
155158
156159
steps:
157160
say hello:

pipeline/frontend/yaml/types/base/map.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"strings"
2121
)
2222

23-
// SliceOrMap represents a map of strings, string slice are converted into a map
23+
// SliceOrMap represents a slice or a map of strings.
2424
type SliceOrMap map[string]string
2525

2626
// UnmarshalYAML implements the Unmarshaler interface.

pipeline/frontend/yaml/types/workflow.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type (
2323
// Workflow defines a workflow configuration.
2424
Workflow struct {
2525
When constraint.When `yaml:"when,omitempty"`
26+
Platform string `yaml:"platform,omitempty"`
2627
Workspace Workspace `yaml:"workspace,omitempty"`
2728
Clone ContainerList `yaml:"clone,omitempty"`
2829
Steps ContainerList `yaml:"steps,omitempty"`
@@ -31,14 +32,10 @@ type (
3132
DependsOn []string `yaml:"depends_on,omitempty"`
3233
RunsOn []string `yaml:"runs_on,omitempty"`
3334
SkipClone bool `yaml:"skip_clone"`
34-
3535
// Undocumented
3636
Cache base.StringOrSlice `yaml:"cache,omitempty"`
3737
Networks WorkflowNetworks `yaml:"networks,omitempty"`
3838
Volumes WorkflowVolumes `yaml:"volumes,omitempty"`
39-
40-
// Deprecated
41-
PlatformDontUseIt string `yaml:"platform,omitempty"` // TODO: remove after v1.2.x version
4239
// Deprecated
4340
BranchesDontUseIt *constraint.List `yaml:"branches,omitempty"` // TODO: remove after v1.1.x version
4441
// Deprecated

pipeline/stepBuilder.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type StepBuilder struct {
5454

5555
type Item struct {
5656
Workflow *model.Workflow
57+
Platform string
5758
Labels map[string]string
5859
DependsOn []string
5960
RunsOn []string
@@ -170,6 +171,7 @@ func (b *StepBuilder) genItemForWorkflow(workflow *model.Workflow, axis matrix.A
170171
Labels: parsed.Labels,
171172
DependsOn: parsed.DependsOn,
172173
RunsOn: parsed.RunsOn,
174+
Platform: parsed.Platform,
173175
}
174176
if item.Labels == nil {
175177
item.Labels = map[string]string{}

server/pipeline/queue.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func queuePipeline(repo *model.Repo, pipelineItems []*pipeline.Item) error {
3737
for k, v := range item.Labels {
3838
task.Labels[k] = v
3939
}
40+
task.Labels["platform"] = item.Platform
4041
task.Labels["repo"] = repo.FullName
4142
task.Dependencies = taskIds(item.DependsOn, pipelineItems)
4243
task.RunOn = item.RunsOn

0 commit comments

Comments
 (0)