From 826f9bc09ea1e0b53a76517959e26a79fa55885a Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Thu, 21 Mar 2019 07:38:38 -0500 Subject: [PATCH] Validate yaml files with yamllint --- Dockerfile | 5 +++-- test/conftest.py | 6 ++++++ test/test_syntax.py | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6651deb..b221942 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,9 +27,10 @@ RUN \ ; RUN pip3 install \ envtpl \ - pytest==3.6.4 \ - pylint==1.9.2 \ flake8==3.5.0 \ + pylint==1.9.2 \ + pytest==3.6.4 \ + yamllint==1.15.0 \ ; # Force GNUPG version 1 at path /usr/bin/gpg diff --git a/test/conftest.py b/test/conftest.py index 4fefabe..0b1f904 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -28,6 +28,12 @@ def flake8_version(): return '3.5.0' +@pytest.fixture(scope='session') +def yamllint_version(): + """Version of yamllint supported""" + return '1.15.0' + + @pytest.fixture(scope='session') def tst_user(): """Test session's user id""" diff --git a/test/test_syntax.py b/test/test_syntax.py index 5408885..5e39b3a 100644 --- a/test/test_syntax.py +++ b/test/test_syntax.py @@ -39,3 +39,14 @@ def test_flake8(runner, flake8_version): pytest.skip('Unsupported flake8 version') run = runner(command=['flake8', 'test']) assert run.success + + +def test_yamllint(runner, yamllint_version): + """Passes yamllint""" + run = runner(command=['yamllint', '--version'], report=False) + if not run.out.strip().endswith(yamllint_version): + pytest.skip('Unsupported yamllint version') + run = runner( + command=['yamllint', '-s', '$(find . -name \\*.yml)'], + shell=True) + assert run.success