From f4e01644664061f16971d680d9b9d80ddc43da84 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Wed, 25 Apr 2018 19:18:40 +0100 Subject: [PATCH] Add top-level lint/fmt tox jobs This is to add a top-level lint/fmt job to Pegleg so that tox -e lint is executed in CICD. lint is included under envlist to accomplish this. fmt is excluded from envlist as it doesn't need to be executed in CICD but is included nonetheless for convenience. Also fixes some typos. Change-Id: I76165704b32653c98e506ddde71c8240d5f28492 --- src/bin/pegleg/pegleg/engine/lint.py | 7 +++---- src/bin/pegleg/tests/unit/test_engine_util_files.py | 3 ++- tox.ini | 12 +++++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/bin/pegleg/pegleg/engine/lint.py b/src/bin/pegleg/pegleg/engine/lint.py index 7e299a23..b350008c 100644 --- a/src/bin/pegleg/pegleg/engine/lint.py +++ b/src/bin/pegleg/pegleg/engine/lint.py @@ -41,8 +41,8 @@ DECKHAND_SCHEMAS = { def full(fail_on_missing_sub_src=False, exclude_lint=None, warn_lint=None): messages = [] # If policy is cleartext and error is added this will put - # that particular message into the warns list and all other will - # be added to the error list if SCHMEA_STORAGE_POLICY_MITCHMATCH_FLAG + # that particular message into the warns list and all others will + # be added to the error list if SCHEMA_STORAGE_POLICY_MISMATCH_FLAG messages.extend(_verify_file_contents()) # Deckhand Rendering completes without error @@ -160,14 +160,13 @@ def _verify_document(document, schemas, filename): def _verify_deckhand_render(fail_on_missing_sub_src=False): - documents = [] for filename in util.files.all(): with open(filename) as f: documents.extend(list(yaml.safe_load_all(f))) - rendered_documents, errors = util.deckhand.deckhand_render( + _, errors = util.deckhand.deckhand_render( documents=documents, fail_on_missing_sub_src=fail_on_missing_sub_src, validate=True, diff --git a/src/bin/pegleg/tests/unit/test_engine_util_files.py b/src/bin/pegleg/tests/unit/test_engine_util_files.py index 4f1451a8..7a5b1ea8 100644 --- a/src/bin/pegleg/tests/unit/test_engine_util_files.py +++ b/src/bin/pegleg/tests/unit/test_engine_util_files.py @@ -16,6 +16,7 @@ import tempfile from pegleg import config from pegleg.engine.util import files + def test_no_non_yamls(tmpdir): p = tmpdir.mkdir("site_yamls").mkdir("global") for x in range(3): # Create 3 YAML files @@ -25,6 +26,6 @@ def test_no_non_yamls(tmpdir): results = list(files.all()) assert 3 == len(results) - # make sure only YAML files are returned + # Make sure only YAML files are returned for i in results: assert i.endswith('.yaml') diff --git a/tox.ini b/tox.ini index 968c3704..91069dd4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35, docs +envlist = py35, lint, docs # Allows docs to be built without setup.py having to exist. Requires that # usedevelop be False as well (which it is by default). skipsdist = True @@ -15,6 +15,16 @@ commands = tox -c src/bin/pegleg/tox.ini -e py35 whitelist_externals = tox +[testenv:fmt] +commands = + tox -c src/bin/pegleg/tox.ini -e fmt +whitelist_externals = tox + +[testenv:lint] +commands = + tox -c src/bin/pegleg/tox.ini -e lint +whitelist_externals = tox + [testenv:docs] deps = -r{toxinidir}/docs/requirements.txt commands =