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
This commit is contained in:
parent
052fd683c9
commit
f4e0164466
@ -41,8 +41,8 @@ DECKHAND_SCHEMAS = {
|
|||||||
def full(fail_on_missing_sub_src=False, exclude_lint=None, warn_lint=None):
|
def full(fail_on_missing_sub_src=False, exclude_lint=None, warn_lint=None):
|
||||||
messages = []
|
messages = []
|
||||||
# If policy is cleartext and error is added this will put
|
# If policy is cleartext and error is added this will put
|
||||||
# that particular message into the warns list and all other will
|
# that particular message into the warns list and all others will
|
||||||
# be added to the error list if SCHMEA_STORAGE_POLICY_MITCHMATCH_FLAG
|
# be added to the error list if SCHEMA_STORAGE_POLICY_MISMATCH_FLAG
|
||||||
messages.extend(_verify_file_contents())
|
messages.extend(_verify_file_contents())
|
||||||
|
|
||||||
# Deckhand Rendering completes without error
|
# 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):
|
def _verify_deckhand_render(fail_on_missing_sub_src=False):
|
||||||
|
|
||||||
documents = []
|
documents = []
|
||||||
|
|
||||||
for filename in util.files.all():
|
for filename in util.files.all():
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
documents.extend(list(yaml.safe_load_all(f)))
|
documents.extend(list(yaml.safe_load_all(f)))
|
||||||
|
|
||||||
rendered_documents, errors = util.deckhand.deckhand_render(
|
_, errors = util.deckhand.deckhand_render(
|
||||||
documents=documents,
|
documents=documents,
|
||||||
fail_on_missing_sub_src=fail_on_missing_sub_src,
|
fail_on_missing_sub_src=fail_on_missing_sub_src,
|
||||||
validate=True,
|
validate=True,
|
||||||
|
@ -16,6 +16,7 @@ import tempfile
|
|||||||
from pegleg import config
|
from pegleg import config
|
||||||
from pegleg.engine.util import files
|
from pegleg.engine.util import files
|
||||||
|
|
||||||
|
|
||||||
def test_no_non_yamls(tmpdir):
|
def test_no_non_yamls(tmpdir):
|
||||||
p = tmpdir.mkdir("site_yamls").mkdir("global")
|
p = tmpdir.mkdir("site_yamls").mkdir("global")
|
||||||
for x in range(3): # Create 3 YAML files
|
for x in range(3): # Create 3 YAML files
|
||||||
@ -25,6 +26,6 @@ def test_no_non_yamls(tmpdir):
|
|||||||
results = list(files.all())
|
results = list(files.all())
|
||||||
|
|
||||||
assert 3 == len(results)
|
assert 3 == len(results)
|
||||||
# make sure only YAML files are returned
|
# Make sure only YAML files are returned
|
||||||
for i in results:
|
for i in results:
|
||||||
assert i.endswith('.yaml')
|
assert i.endswith('.yaml')
|
||||||
|
12
tox.ini
12
tox.ini
@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py35, docs
|
envlist = py35, lint, docs
|
||||||
# Allows docs to be built without setup.py having to exist. Requires that
|
# Allows docs to be built without setup.py having to exist. Requires that
|
||||||
# usedevelop be False as well (which it is by default).
|
# usedevelop be False as well (which it is by default).
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
@ -15,6 +15,16 @@ commands =
|
|||||||
tox -c src/bin/pegleg/tox.ini -e py35
|
tox -c src/bin/pegleg/tox.ini -e py35
|
||||||
whitelist_externals = tox
|
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]
|
[testenv:docs]
|
||||||
deps = -r{toxinidir}/docs/requirements.txt
|
deps = -r{toxinidir}/docs/requirements.txt
|
||||||
commands =
|
commands =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user