yamllint: Lint YAML Files in CI
yamllint parses YAML files and reports syntax errors and style problems, exiting 1 when any error-level problem is found.
yamllint guards the many YAML files in a modern repo (CI configs, Kubernetes manifests, Compose). In CI you run it across the tree and gate on the exit code.
What it does
yamllint takes files or directories, loads its config, and reports problems as warnings or errors. It exits 1 when any error-level problem exists (and, with --strict, when warnings exist too), and 0 otherwise. -d supplies config inline without a file.
Common usage
yamllint .
# use a named preset inline
yamllint -d relaxed config/
# treat warnings as failures
yamllint --strict .github/Flags
| Flag | What it does |
|---|---|
| <path> | File or directory to lint (recurses directories) |
| -c <file> | Use a specific config file |
| -d <data> | Inline config or a preset name (default, relaxed) |
| -f <format> | Output format (standard, github, parsable, colored) |
| --strict | Return non-zero on warnings as well as errors |
| --no-warnings | Hide warnings, show only errors |
In CI
By default yamllint only scans files with .yml/.yaml extensions when given a directory; pass explicit paths for oddly named files. --strict is the usual CI choice so style warnings cannot pile up unnoticed.
Common errors in CI
"syntax error: mapping values are not allowed here" means malformed YAML, often an unquoted colon in a value. "[error] too many blank lines" and "[warning] line too long" are style rules from the default config. "[error] trailing spaces" is one of the most common first failures when adopting yamllint.