woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.24k stars 368 forks source link

Add support for YAML 1.2 #517

Open seabass-labrax opened 2 years ago

seabass-labrax commented 2 years ago

Clear and concise description of the problem

It would be convenient to be able to use YAML 1.2 for .woodpecker.yml and other such workflow files. I believe many users are likely to assume that Woodpecker supports the latest version of YAML, but it currently supports only YAML 1.1 (which was published in 2005).

Adding an explicit version directive (%YAML 1.2) to .woodpecker.yml results in the CI not being run, and the CI status not being shown at all in the Gitea (Codeberg) user interface. Woodpecker's own user interface displays the following error message:

Execution error yaml: line 3: found incompatible YAML document

This message is generated by the go-yaml library, in its yaml/parserc.go file.

Suggested solution

We could use a different YAML parsing library which does support YAML 1.2, or contribute support for YAML 1.2 upstream. This may be related to an existing issue and pull request relating to YAML support:

https://github.com/woodpecker-ci/woodpecker/issues/352 https://github.com/woodpecker-ci/woodpecker/pull/384

Alternative

We could also update the documentation to make it clear that only YAML 1.1 is supported. Currently, it is potentially confusing that the 'Getting Started' page on the Woodpecker documentation says that the format "is a superset of the widely used docker-compose file format", despite the fact that Docker Compose does support YAML 1.2.

Additional context

This is the error message I referred to earlier:

error-message

...and this is a pop-up message that appears if one tries to restart the failed build: error-popup

Validations

seabass-labrax commented 2 years ago

I'd be more than happy to lend a hand if you decide to take one of the options I described :)

anbraten commented 2 years ago

The yaml package supports most of YAML 1.2, but preserves some behavior from 1.1 for backwards compatibility.

We are mainly using go-yaml v3 which seems to be the best option regarding yaml 1.2.

My suggestion would be to replace https://github.com/ghodss/yaml by something using go-yaml v3 (maybe by the change started in #384) and patch further bugs by contributing to go-yaml v3 directly.

seabass-labrax commented 2 years ago

I've just made pull request #556 to document the present support for YAML 1.1 and that YAML 1.2 support is being added! :)

6543 commented 2 years ago

@seabass-labrax can you paste an 1.2 yaml example to test against here?

6543 commented 2 years ago

We mostly do support yaml 1.2 but not completly :/

6543 commented 2 years ago

only YAML 1.1 is accepted -> https://codeberg.org/6543/ci_yaml-test/commits/branch/main

else you get 400 -> failure to parse YAML from hook back (web-hook response)

this has to do with https://gopkg.in/yaml.v3 lib