view raw
Emily M Emily M - 6 months ago 49
YAML Question

Does the .travis.yml configuration file of Travis-CI support YAML directives?

YAML supports a language feature called a directive, as indicated here, and the specific directive I was attempting to use was the version directive. This directive is simply the string "%YAML 1.1" placed at the start of the YAML document, where 1.1 is the document's compliant YAML specification version. By marking the YAML version of my document I was seeking obvious clarity on the contents of the YAML configuration.

The Travis-CI developers developed a very nice linting tool for the Travis-CI configuration files provided via "dogfooding" of the travis-yaml gem. This linter is able to give specific errors and error locations- it is very helpful for verifying that the .travis.yml file is valid and I use it very liberally when configuring my Travis-CI build jobs. Despite the usage of a YAML directive being valid YAML, the travis-yaml linter says that using the directive is an error (it even refuses to read the rest of the document!)

Essentially, my question is regarding the YAML directive above and what support Travis-CI has for such a directive. Does Travis-CI support valid YAML directives such as "%YAML 1.2"? Is the .travis.yml file actually using a somewhat non-compliant YAML parser configured to be specifically for parsing .travis.yml instead of simply being a normal YAML parser?


The linting tool validates the following YAML without problems:

%YAML 1.1
language: python
  - "2.7"
  - "3.5"
  - "3.6"
# command to run tests
script: nosetests

so I suspect your YAML somehow has an error (did you forget the --- separating directives from the rest of the document?).

Please note that the travis linter does not support YAML 1.2 (specified in 2009) only the older YAML 1.1 specification. If you change 1.1 to 1.2 in the YAML file above, the linter will give found incompatible YAML document at line 1 column 1 and incorrectly calls that a syntax error.