Rename yaml pipeline to steps (#1833)

Adjust pipeline-config to match
[Terminology](https://woodpecker-ci.org/docs/next/usage/terminology)
This commit is contained in:
6543 2023-06-07 12:04:37 +02:00 committed by GitHub
parent 101e684059
commit 7e708874ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 218 additions and 162 deletions

View file

@ -15,7 +15,7 @@ variables:
# web source code
- "web/**"
pipeline:
pipeline: &legacy
build-web:
group: prepare
image: *node_image
@ -98,3 +98,5 @@ pipeline:
title: ${CI_COMMIT_TAG##v}
when:
event: tag
steps: *legacy

View file

@ -12,7 +12,7 @@ variables:
- &platforms_preview 'linux/arm/v6,linux/arm64/v8,linux/amd64,linux/riscv64,windows/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
pipeline:
pipeline: &legacy
vendor:
image: *golang_image
pull: true
@ -331,3 +331,5 @@ pipeline:
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
when:
event: tag
steps: *legacy

View file

@ -8,7 +8,7 @@ variables:
- "cli/**"
- "cmd/cli/**"
pipeline:
pipeline: &legacy
build-cli:
image: *golang_image
commands:
@ -82,3 +82,5 @@ pipeline:
path: *when_path
- cron: update_docs
event: cron
steps: *legacy

View file

@ -10,7 +10,7 @@ variables:
# schema changes
- "pipeline/schema/**"
pipeline:
pipeline: &legacy
vendor:
image: *golang_image
group: prepare
@ -146,3 +146,5 @@ services:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
when:
path: *when_path
steps: *legacy

View file

@ -6,7 +6,7 @@ variables:
# web source code
- "web/**"
pipeline:
pipeline: &legacy
deps:
image: *node_image
directory: web/
@ -64,3 +64,5 @@ pipeline:
- pnpm test
when:
path: *when_path
steps: *legacy

View file

@ -12,7 +12,7 @@ Woodpecker is a simple CI engine with great extensibility. It runs your pipeline
```yaml
# .woodpecker.yml
pipeline:
steps:
build:
image: debian
commands:
@ -23,7 +23,7 @@ pipeline:
- echo "Testing.."
```
### Pipeline steps are containers
### Steps are containers
- Define any container image as context
- either use your own and install the needed tools in custom image or
@ -31,7 +31,7 @@ pipeline:
- List the commands that should be executed in your container, in order to build or test your application
```diff
pipeline:
steps:
build:
- image: debian
+ image: mycompany/image-with-awscli
@ -41,12 +41,12 @@ pipeline:
### File changes are incremental
- Woodpecker clones the source code in the beginning pipeline
- Woodpecker clones the source code in the beginning
- Changes to files are persisted through steps as the same volume is mounted to all steps
```yaml
# .woodpecker.yml
pipeline:
steps:
build:
image: debian
commands:
@ -78,7 +78,7 @@ kubectl apply -f $PLUGIN_TEMPLATE
```yaml
# .woodpecker.yml
pipeline:
steps:
deploy-to-k8s:
image: laszlocloud/my-k8s-plugin
settings:

View file

@ -32,7 +32,7 @@ Read more at: [https://github.com/go-yaml/yaml](https://github.com/go-yaml/yaml/
Example pipeline configuration:
```yaml
pipeline:
steps:
build:
image: golang
commands:
@ -50,7 +50,7 @@ services:
Example pipeline configuration with multiple, serial steps:
```yaml
pipeline:
steps:
backend:
image: golang
commands:

View file

@ -37,6 +37,6 @@ Sometimes there exist multiple terms that can be used for a thing, we try to def
[Forge]: ../30-administration/11-forges/10-overview.md
[Plugin]: ./51-plugins/10-plugins.md
[Workspace]: ./20-pipeline-syntax.md#workspace
[Matrix]: ./30-matrix-pipelines.md
[Matrix]: ./30-matrix-workflows.md
[Docker]: ../30-administration/22-backends/10-docker.md
[Local]: ../30-administration/22-backends/20-local.md

View file

@ -2,10 +2,10 @@
The pipeline section defines a list of steps to build, test and deploy your code. Pipeline steps are executed serially, in the order in which they are defined. If a step returns a non-zero exit code, the pipeline immediately aborts and returns a failure status.
Example pipeline:
Example steps:
```yaml
pipeline:
steps:
backend:
image: golang
commands:
@ -24,7 +24,7 @@ In the above example we define two pipeline steps, `frontend` and `backend`. The
Another way to name a step is by using the name keyword:
```yaml
pipeline:
steps:
- name: backend
image: golang
commands:
@ -54,7 +54,7 @@ Every step of your pipeline executes arbitrary commands inside a specified conta
The associated commit of a current pipeline run is checked out with git to a workspace which is mounted to every step of the pipeline as the working directory.
```diff
pipeline:
steps:
backend:
image: golang
commands:
@ -69,7 +69,7 @@ The associated commit of a current pipeline run is checked out with git to a wor
```yaml
# .woodpecker.yml
pipeline:
steps:
build:
image: debian
commands:
@ -87,7 +87,7 @@ Woodpecker pulls the defined image and uses it as environment to execute the pip
When using the `local` backend, the `image` entry is used to specify the shell, such as Bash or Fish, that is used to run the commands.
```diff
pipeline:
steps:
build:
+ image: golang:1.6
commands:
@ -116,7 +116,7 @@ image: index.docker.io/library/golang:1.7
Woodpecker does not automatically upgrade container images. Example configuration to always pull the latest image when updates are available:
```diff
pipeline:
steps:
build:
image: golang:latest
+ pull: true
@ -131,7 +131,7 @@ These credentials are never exposed to your pipeline, which means they cannot be
Example configuration using a private image:
```diff
pipeline:
steps:
build:
+ image: gcr.io/custom/golang
commands:
@ -168,7 +168,7 @@ For specific details on configuring access to Google Container Registry, please
Commands of every pipeline step are executed serially as if you would enter them into your local shell.
```diff
pipeline:
steps:
backend:
image: golang
commands:
@ -211,7 +211,7 @@ For more details check the [secrets docs](./40-secrets.md).
Some of the pipeline steps may be allowed to fail without causing the whole pipeline to report a failure (e.g., a step executing a linting check). To enable this, add `failure: ignore` to your pipeline step. If Woodpecker encounters an error while executing the step, it will report it as failed but still execute the next steps of the pipeline, if any, without affecting the status of the pipeline.
```diff
pipeline:
steps:
backend:
image: golang
commands:
@ -225,7 +225,7 @@ Some of the pipeline steps may be allowed to fail without causing the whole pipe
Woodpecker supports defining a list of conditions for a pipeline step by using a `when` block. If at least one of the conditions in the `when` block evaluate to true the step is executed, otherwise it is skipped. A condition can be a check like:
```diff
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -242,7 +242,7 @@ Woodpecker supports defining a list of conditions for a pipeline step by using a
Example conditional execution by repository:
```diff
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -260,7 +260,7 @@ Branch conditions are not applied to tags.
Example conditional execution by branch:
```diff
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -363,7 +363,7 @@ when:
There are use cases for executing pipeline steps on failure, such as sending notifications for failed pipelines. Use the status constraint to execute steps even when the pipeline fails:
```diff
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -375,7 +375,7 @@ pipeline:
#### `platform`
:::note
This condition should be used in conjunction with a [matrix](./30-matrix-pipelines.md#example-matrix-pipeline-using-multiple-platforms) pipeline as a regular pipeline will only executed by a single agent which only has one arch.
This condition should be used in conjunction with a [matrix](./30-matrix-workflows.md#example-matrix-pipeline-using-multiple-platforms) pipeline as a regular pipeline will only executed by a single agent which only has one arch.
:::
Execute a step for a specific platform:
@ -489,7 +489,7 @@ Woodpecker supports parallel step execution for same-machine fan-in and fan-out.
Example parallel configuration:
```diff
pipeline:
steps:
backend:
+ group: build
image: golang
@ -547,7 +547,7 @@ The workspace can be customized using the workspace block in the YAML file:
+ base: /go
+ path: src/github.com/octocat/hello-world
pipeline:
steps:
build:
image: golang:latest
commands:
@ -562,7 +562,7 @@ The base attribute defines a shared base volume available to all pipeline steps.
+ base: /go
path: src/github.com/octocat/hello-world
pipeline:
steps:
deps:
image: golang:latest
commands:
@ -600,7 +600,7 @@ git clone https://github.com/octocat/hello-world \
Woodpecker has integrated support for matrix builds. Woodpecker executes a separate build task for each combination in the matrix, allowing you to build and test a single commit against multiple configurations.
For more details check the [matrix build docs](./30-matrix-pipelines.md).
For more details check the [matrix build docs](./30-matrix-workflows.md).
## `platform`
@ -614,7 +614,7 @@ Assuming we have two agents, one `arm` and one `amd64`. Previously this pipeline
```diff
+platform: linux/arm64
pipeline:
steps:
build:
image: golang
commands:
@ -639,7 +639,7 @@ You can add additional labels as a key value map:
+ weather: sun
+ hostname: "" # this label will be ignored as it is empty
pipeline:
steps:
build:
image: golang
commands:
@ -664,7 +664,7 @@ You can manually configure the clone step in your pipeline for customization:
+ git:
+ image: woodpeckerci/plugin-git
pipeline:
steps:
build:
image: golang
commands:
@ -723,7 +723,7 @@ To use the ssh git url in `.gitmodules` for users cloning with ssh, and also use
+ submodule_override:
+ my-module: https://github.com/octocat/my-module.git
pipeline:
steps:
...
```
@ -747,7 +747,7 @@ Example conditional execution by repository:
+when:
+ repo: test/test
+
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -766,7 +766,7 @@ Example conditional execution by branch:
+when:
+ branch: master
+
pipeline:
steps:
slack:
image: plugins/slack
settings:
@ -896,7 +896,7 @@ Woodpecker gives the ability to configure privileged mode in the YAML. You can u
> Privileged mode is only available to trusted repositories and for security reasons should only be used in private environments. See [project settings](./71-project-settings.md#trusted) to enable trusted mode.
```diff
pipeline:
steps:
build:
image: docker
environment:

View file

@ -36,7 +36,7 @@ If you still need to pass artifacts between the workflows you need use some stor
.woodpecker/.build.yml
```yaml
pipeline:
steps:
build:
image: debian:stable-slim
commands:
@ -47,7 +47,7 @@ pipeline:
.woodpecker/.deploy.yml
```yaml
pipeline:
steps:
deploy:
image: debian:stable-slim
commands:
@ -62,7 +62,7 @@ depends_on:
.woodpecker/.test.yml
```yaml
pipeline:
steps:
test:
image: debian:stable-slim
commands:
@ -76,7 +76,7 @@ depends_on:
.woodpecker/.lint.yml
```yaml
pipeline:
steps:
lint:
image: debian:stable-slim
commands:
@ -97,7 +97,7 @@ Dependencies between workflows can be set with the `depends_on` element. A workf
The name for a `depends_on` entry is the filename without the path, leading dots and without the file extension `.yml` or `.yaml`. If the project config for example uses `.woodpecker/` as path for CI files with a file named `.woodpecker/.lint.yml` the corresponding `depends_on` entry would be `lint`.
```diff
pipeline:
steps:
deploy:
image: debian:stable-slim
commands:
@ -112,7 +112,7 @@ pipeline:
Workflows that need to run even on failures should set the `runs_on` tag.
```diff
pipeline:
steps:
notify:
image: debian:stable-slim
commands:

View file

@ -1,4 +1,4 @@
# Matrix pipelines
# Matrix workflows
Woodpecker has integrated support for matrix workflows. Woodpecker executes a separate workflow for each combination in the matrix, allowing you to build and test a single commit against multiple configurations.
@ -42,7 +42,7 @@ matrix:
- mysql:6.5
- mariadb:10.1
pipeline:
steps:
build:
image: golang:${GO_VERSION}
commands:
@ -58,7 +58,7 @@ services:
Example YAML file after injecting the matrix parameters:
```diff
pipeline:
steps:
build:
- image: golang:${GO_VERSION}
+ image: golang:1.4
@ -87,7 +87,7 @@ matrix:
- 1.8
- latest
pipeline:
steps:
build:
image: golang:${TAG}
commands:
@ -104,7 +104,7 @@ matrix:
- golang:1.8
- golang:latest
pipeline:
steps:
build:
image: ${IMAGE}
commands:
@ -122,7 +122,7 @@ matrix:
platform: ${platform}
pipeline:
steps:
test:
image: alpine
commands:

View file

@ -6,7 +6,7 @@ You can use [YAML anchors & aliases](https://yaml.org/spec/1.2.2/#3222-anchors-a
To convert this:
```yml
pipeline:
steps:
test:
image: golang:1.18
commands: go test ./...
@ -21,7 +21,7 @@ Just add a new section called **variables** like this:
+variables:
+ - &golang_image 'golang:1.18'
pipeline:
steps:
test:
- image: golang:1.18
+ image: *golang_image
@ -44,7 +44,7 @@ variables:
special: true
- &some-plugin codeberg.org/6543/docker-images/print_env
pipeline:
steps:
develop:
image: *some-plugin
settings:
@ -74,7 +74,7 @@ variables:
hello_cmd: &hello_cmd
- echo hello
pipeline:
steps:
step1:
image: debian
commands:

View file

@ -5,7 +5,7 @@ Woodpecker provides the ability to store named parameters external to the YAML c
Secrets are exposed to your pipeline steps and plugins as uppercase environment variables and can therefore be referenced in the commands section of your pipeline.
```diff
pipeline:
steps:
docker:
image: docker
commands:
@ -20,7 +20,7 @@ In this example, the secret named `secret_token` would be passed to the pipeline
**NOTE:** the `from_secret` syntax only works with the newer `settings` block.
```diff
pipeline:
steps:
docker:
image: my-plugin
settings:
@ -32,7 +32,7 @@ pipeline:
Please note parameter expressions are subject to pre-processing. When using secrets in parameter expressions they should be escaped.
```diff
pipeline:
steps:
docker:
image: docker
commands:
@ -52,7 +52,7 @@ Secrets are added to the Woodpecker secret store on the UI or with the CLI.
There may be scenarios where you are required to store secrets using alternate names. You can map the alternate secret name to the expected name using the below syntax:
```diff
pipeline:
steps:
docker:
image: plugins/docker
repo: octocat/hello-world

View file

@ -12,7 +12,7 @@ Read more at: [pipeline-syntax#event](./20-pipeline-syntax.md#event)
1. To create a new cron job adjust your pipeline config(s) and add the event filter to all steps you would like to run by the cron job:
```diff
pipeline:
steps:
sync_locales:
image: weblate_sync
settings:

View file

@ -3,7 +3,7 @@
Woodpecker provides the ability to pass environment variables to individual pipeline steps. Example pipeline step with custom environment variables:
```diff
pipeline:
steps:
build:
image: golang
+ environment:
@ -18,7 +18,7 @@ pipeline:
Please note that the environment section is not able to expand environment variables. If you need to expand variables they should be exported in the commands section.
```diff
pipeline:
steps:
build:
image: golang
- environment:
@ -32,7 +32,7 @@ pipeline:
> Please be warned that `${variable}` expressions are subject to pre-processing. If you do not want the pre-processor to evaluate your expression it must be escaped:
```diff
pipeline:
steps:
build:
image: golang
commands:
@ -146,7 +146,7 @@ services:
These can be used, for example, to manage the image tag used by multiple projects.
```diff
pipeline:
steps:
build:
- image: golang:1.18
+ image: golang:${GOLANG_VERSION}
@ -164,7 +164,7 @@ Woodpecker provides the ability to substitute environment variables at runtime.
Example commit substitution:
```diff
pipeline:
steps:
docker:
image: plugins/docker
settings:
@ -174,7 +174,7 @@ pipeline:
Example tag substitution:
```diff
pipeline:
steps:
docker:
image: plugins/docker
settings:
@ -202,7 +202,7 @@ Woodpecker also emulates bash string operations. This gives us the ability to ma
Example variable substitution with substring:
```diff
pipeline:
steps:
docker:
image: plugins/docker
settings:
@ -212,7 +212,7 @@ pipeline:
Example variable substitution strips `v` prefix from `v.1.0.0`:
```diff
pipeline:
steps:
docker:
image: plugins/docker
settings:

View file

@ -7,7 +7,7 @@ They are automatically pulled from the default container registry the agent's ha
Example pipeline using the Docker and Slack plugins:
```yaml
pipeline:
steps:
build:
image: golang
commands:

View file

@ -7,7 +7,7 @@ This provides a brief tutorial for creating a Woodpecker webhook plugin, using s
The below example demonstrates how we might configure a webhook plugin in the YAML file:
```yaml
pipeline:
steps:
webhook:
image: foo/webhook
settings:

View file

@ -7,7 +7,7 @@ Services are accessed using custom hostnames.
In the example below, the MySQL service is assigned the hostname `database` and is available at `database:3306`.
```diff
pipeline:
steps:
build:
image: golang
commands:
@ -43,7 +43,7 @@ services:
Service and long running containers can also be included in the pipeline section of the configuration using the detach parameter without blocking other steps. This should be used when explicit control over startup order is required.
```diff
pipeline:
steps:
build:
image: golang
commands:
@ -67,7 +67,7 @@ Containers from detached steps will terminate when the pipeline ends.
Service containers require time to initialize and begin to accept connections. If you are unable to connect to a service you may need to wait a few seconds or implement a backoff.
```diff
pipeline:
steps:
test:
image: golang
commands:
@ -89,7 +89,7 @@ services:
environment:
- MYSQL_DATABASE=test
- MYSQL_ROOT_PASSWORD=example
pipeline:
steps:
get-version:
image: ubuntu
commands:

View file

@ -7,7 +7,7 @@ Volumes are only available to trusted repositories and for security reasons shou
:::
```diff
pipeline:
steps:
build:
image: docker
commands:

View file

@ -84,7 +84,7 @@ WOODPECKER_CONFIG_SERVICE_ENDPOINT=https://example.com/ciconfig
"configs": [
{
"name": ".woodpecker.yml",
"data": "pipeline:\n backend:\n image: alpine\n commands:\n - echo \"Hello there from Repo (.woodpecker.yml)\"\n"
"data": "steps:\n backend:\n image: alpine\n commands:\n - echo \"Hello there from Repo (.woodpecker.yml)\"\n"
}
]
}
@ -97,7 +97,7 @@ WOODPECKER_CONFIG_SERVICE_ENDPOINT=https://example.com/ciconfig
"configs": [
{
"name": "central-override",
"data": "pipeline:\n backend:\n image: alpine\n commands:\n - echo \"Hello there from ConfigAPI\"\n"
"data": "steps:\n backend:\n image: alpine\n commands:\n - echo \"Hello there from ConfigAPI\"\n"
}
]
}

View file

@ -85,7 +85,7 @@ used to run the commands.
```yaml
# .woodpecker.yml
pipeline:
steps:
build:
image: bash
commands:
@ -116,7 +116,7 @@ only run on this agent:
labels:
type: exec
pipeline:
steps:
[...]
```

View file

@ -46,7 +46,7 @@ The kubernetes backend also allows for specifying requests and limits on a per-s
Example pipeline configuration:
```yaml
pipeline:
steps:
build:
image: golang
commands:

View file

@ -18,6 +18,7 @@ Some versions need some changes to the server configuration or the pipeline conf
- The pipelines are now also read from `.yaml` files, the new default order is `.woodpecker/*.yml` and `.woodpecker/*.yaml` (without any prioritization) -> `.woodpecker.yml` -> `.woodpecker.yaml`
- Dropped support for [Coding](https://coding.net/) and [Gogs](https://gogs.io).
- `/api/queue/resume` & `/api/queue/pause` endpoint methods were changed from `GET` to `POST`
- rename `pipeline:` key in your workflow config to `steps:`
## 0.15.0
@ -75,7 +76,7 @@ Some versions need some changes to the server configuration or the pipeline conf
- Plugin Settings moved into `settings` section:
```diff
pipeline:
steps:
something:
image: my/plugin
- setting1: foo

View file

@ -33,11 +33,11 @@ func TestEnvVarSubst(t *testing.T) {
want string
}{{
name: "simple substitution",
yaml: `pipeline:
yaml: `steps:
step1:
image: ${HELLO_IMAGE}`,
environ: map[string]string{"HELLO_IMAGE": "hello-world"},
want: `pipeline:
want: `steps:
step1:
image: hello-world`,
}}

View file

@ -8,7 +8,7 @@ import (
func TestLint(t *testing.T) {
testdatas := []struct{ Title, Data string }{{Title: "map", Data: `
pipeline:
steps:
build:
image: docker
privileged: true
@ -27,7 +27,7 @@ services:
redis:
image: redis
`}, {Title: "list", Data: `
pipeline:
steps:
- name: build
image: docker
privileged: true
@ -50,7 +50,7 @@ variables:
commands:
- go version
pipeline:
steps:
test base step:
<<: *base-step
test base step with latest image:
@ -82,52 +82,52 @@ func TestLintErrors(t *testing.T) {
want: "Invalid or missing pipeline section",
},
{
from: "pipeline: { build: { image: '' } }",
from: "steps: { build: { image: '' } }",
want: "Invalid or missing image",
},
{
from: "pipeline: { build: { image: golang, privileged: true } }",
from: "steps: { build: { image: golang, privileged: true } }",
want: "Insufficient privileges to use privileged mode",
},
{
from: "pipeline: { build: { image: golang, shm_size: 10gb } }",
from: "steps: { build: { image: golang, shm_size: 10gb } }",
want: "Insufficient privileges to override shm_size",
},
{
from: "pipeline: { build: { image: golang, dns: [ 8.8.8.8 ] } }",
from: "steps: { build: { image: golang, dns: [ 8.8.8.8 ] } }",
want: "Insufficient privileges to use custom dns",
},
{
from: "pipeline: { build: { image: golang, dns_search: [ example.com ] } }",
from: "steps: { build: { image: golang, dns_search: [ example.com ] } }",
want: "Insufficient privileges to use dns_search",
},
{
from: "pipeline: { build: { image: golang, devices: [ '/dev/tty0:/dev/tty0' ] } }",
from: "steps: { build: { image: golang, devices: [ '/dev/tty0:/dev/tty0' ] } }",
want: "Insufficient privileges to use devices",
},
{
from: "pipeline: { build: { image: golang, extra_hosts: [ 'somehost:162.242.195.82' ] } }",
from: "steps: { build: { image: golang, extra_hosts: [ 'somehost:162.242.195.82' ] } }",
want: "Insufficient privileges to use extra_hosts",
},
{
from: "pipeline: { build: { image: golang, network_mode: host } }",
from: "steps: { build: { image: golang, network_mode: host } }",
want: "Insufficient privileges to use network_mode",
},
{
from: "pipeline: { build: { image: golang, networks: [ outside, default ] } }",
from: "steps: { build: { image: golang, networks: [ outside, default ] } }",
want: "Insufficient privileges to use networks",
},
{
from: "pipeline: { build: { image: golang, volumes: [ '/opt/data:/var/lib/mysql' ] } }",
from: "steps: { build: { image: golang, volumes: [ '/opt/data:/var/lib/mysql' ] } }",
want: "Insufficient privileges to use volumes",
},
{
from: "pipeline: { build: { image: golang, network_mode: 'container:name' } }",
from: "steps: { build: { image: golang, network_mode: 'container:name' } }",
want: "Insufficient privileges to use network_mode",
},
{
from: "pipeline: { build: { image: golang, sysctls: [ net.core.somaxconn=1024 ] } }",
from: "steps: { build: { image: golang, sysctls: [ net.core.somaxconn=1024 ] } }",
want: "Insufficient privileges to use sysctls",
},
}

View file

@ -29,6 +29,12 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
out.BranchesDontUseIt = nil
}
// support deprecated pipeline keyword
if len(out.PipelineDontUseIt.ContainerList) != 0 && len(out.Steps.ContainerList) == 0 {
out.Steps.ContainerList = out.PipelineDontUseIt.ContainerList
}
out.PipelineDontUseIt.ContainerList = nil
return out, nil
}

View file

@ -4,6 +4,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"
@ -123,6 +124,41 @@ func TestParse(t *testing.T) {
})
}
func TestParseLegacy(t *testing.T) {
sampleYamlPipelineLegacy := `
pipeline:
say hello:
image: bash
commands: echo hello
`
sampleYamlPipelineLegacyIgnore := `
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:
@ -137,7 +173,7 @@ build:
workspace:
path: src/github.com/octocat/hello-world
base: /go
pipeline:
steps:
test:
image: golang
commands:
@ -178,7 +214,7 @@ runs_on:
var simpleYamlAnchors = `
vars:
image: &image plugins/slack
pipeline:
steps:
notify_success:
image: *image
`
@ -186,7 +222,7 @@ pipeline:
var sampleVarYaml = `
_slack: &SLACK
image: plugins/slack
pipeline:
steps:
notify_fail: *SLACK
notify_success:
<< : *SLACK

View file

@ -12,7 +12,7 @@ type (
Platform string `yaml:"platform,omitempty"`
Workspace Workspace `yaml:"workspace,omitempty"`
Clone ContainerList `yaml:"clone,omitempty"`
Steps ContainerList `yaml:"pipeline"` // TODO: discussed if we should rename it to "steps"
Steps ContainerList `yaml:"steps,omitempty"`
Services ContainerList `yaml:"services,omitempty"`
Labels base.SliceOrMap `yaml:"labels,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
@ -24,6 +24,8 @@ type (
Volumes WorkflowVolumes `yaml:"volumes,omitempty"`
// Deprecated
BranchesDontUseIt *constraint.List `yaml:"branches,omitempty"`
// Deprecated
PipelineDontUseIt ContainerList `yaml:"pipeline,omitempty"`
}
// Workspace defines a pipeline workspace.

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
build:
image: golang:1.7
commands:

View file

@ -9,7 +9,7 @@ clone:
image: woodpeckerci/plugin-git:windows
depth: 50
pipeline:
steps:
build:
image: golang:1.10.1-nanoserver-sac2016
commands:

View file

@ -2,7 +2,7 @@ workspace:
base: /go
path: src/github.com/go-sql-driver/mysql
pipeline:
steps:
build:
image: golang:1.7
environment:

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
build:
image: golang:1.7
commands:

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
build:
image: golang:1.7
commands:

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
# these steps define a parallel execution
# group and will fan out.

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
build:
image: golang:1.7
commands:

View file

@ -2,7 +2,7 @@ workspace:
base: /go
path: src/github.com/drone/envsubst
pipeline:
steps:
build:
image: redis:3.0
commands:

View file

@ -7,7 +7,7 @@ clone:
image: woodpeckerci/plugin-git
depth: 50
pipeline:
steps:
build:
image: tutum/curl
# A container named "vpn" should exist on the same docker daemon

View file

@ -1,4 +1,4 @@
pipeline:
steps:
ping:
image: postgres
commands:

View file

@ -1,7 +1,7 @@
cache:
- node_modules
pipeline:
steps:
build:
image: node
commands:

View file

@ -1,6 +1,6 @@
branches: [master, pages]
pipeline:
steps:
build:
image: golang
commands:

View file

@ -2,7 +2,7 @@ branches:
include: master
exclude: [ develop, feature/* ]
pipeline:
steps:
build:
image: golang
commands:

View file

@ -1,6 +1,6 @@
branches: master
pipeline:
steps:
build:
image: golang
commands:

View file

@ -5,7 +5,7 @@ matri:
- 1.14
- 1.13
pipeline:
steps:
test:
image: golang:${GO_VERSION}
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
test:
image: alpine
commands:

View file

@ -7,7 +7,7 @@ clone:
submodule_override:
my-module: https://github.com/octocat/my-module.git
pipeline:
steps:
test:
image: alpine
commands:

View file

@ -3,7 +3,7 @@ labels:
weather: sun
hostname: ""
pipeline:
steps:
build:
image: golang:latest
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
test:
image: golang:${GO_VERSION}
commands:

View file

@ -5,7 +5,7 @@ variables:
- go version
- whoami
pipeline:
steps:
test-base-step:
<<: *base-step
test base step with latest image:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
deploy:
image: golang
commands:

View file

@ -11,7 +11,7 @@ when:
include:
- hello
pipeline:
steps:
echo:
image: alpine
commands:

View file

@ -1,6 +1,6 @@
platform: linux/amd64
pipeline:
steps:
build:
image: golang:latest
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
build:
image: golang
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
build:
image: golang
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
build:
image: golang
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
image:
image: golang
commands:

View file

@ -1,4 +1,4 @@
pipeline:
steps:
when-branch:
image: alpine
commands:

View file

@ -2,7 +2,7 @@ workspace:
base: /go
path: src/github.com/octocat/hello-world
pipeline:
steps:
build:
image: golang:latest
commands:

View file

@ -4,7 +4,7 @@
"$id": "https://woodpecker-ci.org/schema/woodpecker.json",
"description": "Schema of a Woodpecker pipeline file. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax",
"type": "object",
"required": ["pipeline"],
"required": ["steps"],
"additionalProperties": false,
"properties": {
"$schema": {
@ -18,7 +18,8 @@
"skip_clone": { "type": "boolean" },
"branches": { "$ref": "#/definitions/branches" },
"when": { "$ref": "#/definitions/pipeline_when" },
"pipeline": { "$ref": "#/definitions/pipeline" },
"steps": { "$ref": "#/definitions/step_list" },
"pipeline": { "$ref": "#/definitions/step_list", "description": "depricated, use steps" },
"services": { "$ref": "#/definitions/services" },
"workspace": { "$ref": "#/definitions/workspace" },
"matrix": { "$ref": "#/definitions/matrix" },
@ -92,8 +93,8 @@
}
]
},
"pipeline": {
"description": "The pipeline section defines a list of steps which will be executed serially, in the order in which they are defined. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax",
"step_list": {
"description": "The steps section defines a list of steps which will be executed serially, in the order in which they are defined. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax",
"oneOf": [
{ "type": "object", "additionalProperties": { "$ref": "#/definitions/step" }, "minProperties": 1 },
{ "type": "array", "items": { "$ref": "#/definitions/step" }, "minLength": 1 }

View file

@ -47,7 +47,7 @@ func TestGlobalEnvsubst(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
build:
image: ${IMAGE}
yyy: ${CI_COMMIT_MESSAGE}
@ -82,7 +82,7 @@ func TestMissingGlobalEnvsubst(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
build:
image: ${IMAGE}
yyy: ${CI_COMMIT_MESSAGE}
@ -114,13 +114,13 @@ bbb`,
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
xxx:
image: scratch
yyy: ${CI_COMMIT_MESSAGE}
`)},
{Data: []byte(`
pipeline:
steps:
build:
image: scratch
yyy: ${CI_COMMIT_MESSAGE}
@ -149,12 +149,12 @@ func TestMultiPipeline(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
xxx:
image: scratch
`)},
{Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
@ -184,17 +184,17 @@ func TestDependsOn(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Name: "lint", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
{Name: "test", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
{Data: []byte(`
pipeline:
steps:
deploy:
image: scratch
@ -231,7 +231,7 @@ func TestRunsOn(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
deploy:
image: scratch
@ -268,12 +268,12 @@ func TestPipelineName(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Name: ".woodpecker/lint.yml", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
{Name: ".woodpecker/.test.yml", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
@ -304,13 +304,13 @@ func TestBranchFilter(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
xxx:
image: scratch
branches: master
`)},
{Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
@ -346,7 +346,7 @@ func TestRootWhenFilter(t *testing.T) {
when:
event:
- tester
pipeline:
steps:
xxx:
image: scratch
`)},
@ -354,12 +354,12 @@ pipeline:
when:
event:
- push
pipeline:
steps:
xxx:
image: scratch
`)},
{Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
@ -393,7 +393,7 @@ func TestZeroSteps(t *testing.T) {
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
skip_clone: true
pipeline:
steps:
build:
when:
branch: notdev
@ -428,19 +428,19 @@ func TestZeroStepsAsMultiPipelineDeps(t *testing.T) {
Yamls: []*forge_types.FileMeta{
{Name: "zerostep", Data: []byte(`
skip_clone: true
pipeline:
steps:
build:
when:
branch: notdev
image: scratch
`)},
{Name: "justastep", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
{Name: "shouldbefiltered", Data: []byte(`
pipeline:
steps:
build:
image: scratch
depends_on: [ zerostep ]
@ -477,25 +477,25 @@ func TestZeroStepsAsMultiPipelineTransitiveDeps(t *testing.T) {
Yamls: []*forge_types.FileMeta{
{Name: "zerostep", Data: []byte(`
skip_clone: true
pipeline:
steps:
build:
when:
branch: notdev
image: scratch
`)},
{Name: "justastep", Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},
{Name: "shouldbefiltered", Data: []byte(`
pipeline:
steps:
build:
image: scratch
depends_on: [ zerostep ]
`)},
{Name: "shouldbefilteredtoo", Data: []byte(`
pipeline:
steps:
build:
image: scratch
depends_on: [ shouldbefiltered ]
@ -533,7 +533,7 @@ func TestTree(t *testing.T) {
Link: "",
Yamls: []*forge_types.FileMeta{
{Data: []byte(`
pipeline:
steps:
build:
image: scratch
`)},