From e596b87724c004c156d2e53ed1073e7d40438694 Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Sep 26 2019 11:51:10 +0000 Subject: Merge #373 `add test for yaml syntax` --- diff --git a/ci/Dockerfile b/ci/Dockerfile index 41cb2d7..8312fde 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -2,7 +2,7 @@ FROM docker.io/fedora:29 LABEL maintainer "Andrei Stepanov " RUN yum install -y which copr-cli nss_wrapper fedora-packager wget rpmdevtools \ gcc python3-devel redhat-rpm-config python3 python3-virtualenv python3-pip \ - ansible python3-fmf; \ + ansible python3-fmf yamllint; \ yum clean all; \ rm -rf /var/cache/yum ENV PARAM_WDIR="/work" \ diff --git a/tests/yaml-syntax.sh b/tests/yaml-syntax.sh new file mode 100755 index 0000000..f85f845 --- /dev/null +++ b/tests/yaml-syntax.sh @@ -0,0 +1,31 @@ +#!/usr/bin/bash + +function run() { + # Function to show the command line it will execute, + # otherwise it only shows command output + if [[ -z $1 ]]; then + echo "run() requires command as argument" + return 1 + fi + echo "Running: $1" + eval $1 + return $? +} + +test_path=$(readlink -f $0) +tests_dir=$(dirname $test_path) +# Use the directory above tests to search for yaml files +source_dir=$(dirname $tests_dir) + +# We can make it more strict later, like yamllint -d '{extends: default, rules: {line-length: {max: 120}, indentation: disable, document-start: {level: error}}}' +cmd="yamllint -d '{extends: default, rules: {line-length: {max: 120}, indentation: disable}}' ${source_dir}" + +run "${cmd}" +error=$? + +if [[ ${error} -ne 0 ]]; then + echo "FAIL: problem with yaml syntax" + exit 1 +fi + +exit 0