Commit 05341be7 authored by Kevin Daudt's avatar Kevin Daudt

ci: add job and scripts to lint yaml files

parent 04eefe93
image: python:alpine
stages:
- verify
lint:
stage: verify
before_script:
- pip install pyyaml
script:
- scripts/lint-templates
tags:
- docker-alpine
#!/bin/sh
for file in $(find -name '*.yml' -not -name '.*')
do
scripts/yaml-lint.py "$file" || exit $?
done
#!/usr/bin/env python3
import sys
import yaml
filename = sys.argv[1]
try:
with open(filename, 'r') as f:
try:
yaml.safe_load(f)
except yaml.parser.ParserError as e:
print("Could not parse {filename}".format(filename=filename))
print(e.problem)
print(e.problem_mark)
sys.exit(1)
except FileNotFoundError:
print("Could not find file {filename}".format(filename=filename))
sys.exit(2)
print("Parsed {filename} succesfully".format(filename=filename))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment