diff --git a/pipeline/frontend/yaml/linter/linter_test.go b/pipeline/frontend/yaml/linter/linter_test.go index 0da805d16..63245f7ff 100644 --- a/pipeline/frontend/yaml/linter/linter_test.go +++ b/pipeline/frontend/yaml/linter/linter_test.go @@ -18,6 +18,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "go.woodpecker-ci.org/woodpecker/pipeline/errors" "go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml" "go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml/linter" @@ -60,6 +61,9 @@ steps: settings: repo: foo/bar foo: bar +services: + - name: redis + image: redis `, }, { Title: "merge maps", Data: ` diff --git a/pipeline/frontend/yaml/linter/schema/.woodpecker/test-array-syntax.yml b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-array-syntax.yml new file mode 100644 index 000000000..a21b77261 --- /dev/null +++ b/pipeline/frontend/yaml/linter/schema/.woodpecker/test-array-syntax.yml @@ -0,0 +1,25 @@ +version: 1 + +clone: + - name: git + image: woodpeckerci/plugin-git + settings: + partial: true + - name: testdata + image: woodpeckerci/plugin-git + settings: + remote: https://gitserver/owner/testdata.git + path: testdata + +steps: + - name: build + image: golang + commands: + - go build + - go test + +services: + - name: database + image: mysql + - name: cache + image: redis diff --git a/pipeline/frontend/yaml/linter/schema/schema.json b/pipeline/frontend/yaml/linter/schema/schema.json index 1b8b8cd4e..1adc89c1f 100644 --- a/pipeline/frontend/yaml/linter/schema/schema.json +++ b/pipeline/frontend/yaml/linter/schema/schema.json @@ -70,17 +70,62 @@ "definitions": { "clone": { "description": "Configures the clone step. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#clone", - "type": "object", - "additionalProperties": false, - "properties": { - "git": { + "oneOf": [ + { "type": "object", + "additionalProperties": false, "properties": { - "image": { - "type": "string" + "git": { + "type": "object", + "properties": { + "image": { + "$ref": "#/definitions/step_image" + }, + "settings": { + "$ref": "#/definitions/clone_settings" + } + } } } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/step" + }, + "minLength": 1 } + ] + }, + "clone_settings": { + "description": "Change the settings of your clone plugin. Read more: https://woodpecker-ci.org/plugins/Git%20Clone", + "type": "object", + "properties": { + "depth": { + "type": "number", + "description": "If specified, uses git's --depth option to create a shallow clone with a limited number of commits, overwritten by partial" + }, + "recursive": { + "type": "boolean", + "default": false, + "description": "Clones submodules recursively" + }, + "partial": { + "type": "boolean", + "description": "Only fetch the one commit and it's blob objects to resolve all files, overwrite depth with 1" + }, + "lfs": { + "type": "boolean", + "default": true, + "description": "Set this to false to disable retrieval of LFS files" + }, + "tags": { + "type": "boolean", + "description": "Fetches tags when set to true, default is false if event is not tag else true" + } + }, + "additionalProperties": { + "type": ["boolean", "string", "number", "array", "object"] } }, "branches": { @@ -664,11 +709,22 @@ }, "services": { "description": "Read more: https://woodpecker-ci.org/docs/usage/services", - "type": "object", - "additionalProperties": { - "$ref": "#/definitions/service" - }, - "minProperties": 1 + "oneOf": [ + { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/service" + }, + "minProperties": 1 + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/service" + }, + "minLength": 1 + } + ] }, "service": { "description": "Read more: https://woodpecker-ci.org/docs/usage/services", @@ -677,6 +733,10 @@ "minProperties": 1, "required": ["image"], "properties": { + "name": { + "description": "The name of the service. Can be used if using the array style services list", + "type": "string" + }, "image": { "$ref": "#/definitions/step_image" }, diff --git a/pipeline/frontend/yaml/linter/schema/schema_test.go b/pipeline/frontend/yaml/linter/schema/schema_test.go index 575b5ae49..63bb0f694 100644 --- a/pipeline/frontend/yaml/linter/schema/schema_test.go +++ b/pipeline/frontend/yaml/linter/schema/schema_test.go @@ -101,6 +101,11 @@ func TestSchema(t *testing.T) { testFile: ".woodpecker/test-broken.yml", fail: true, }, + { + name: "Array syntax", + testFile: ".woodpecker/test-array-syntax.yml", + fail: false, + }, } for _, tt := range testTable {