From 893ea9f4bb375815dc239614392b7ce6ef17b434 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Thu, 20 Sep 2018 17:33:54 +0100 Subject: [PATCH] Standardize Pegleg directory structure This patch set standardizes the Pegleg directory structure because of the following reasons: 1) src/bin/pegleg is not necessary and only makes building (e.g. documentation building) and running of tox targets unnecessarily difficult. 2) src/bin/pegleg is a Java-like standard that bears no relevance to Python. Change-Id: I37d39d3d6186b92f8fbfe234221c9e44da48cf10 --- .zuul.yaml | 2 +- Makefile | 14 +- doc/source/conf.py | 34 ++++- doc/source/developer-overview.rst | 4 +- images/pegleg/Dockerfile | 6 +- {src/bin/pegleg/pegleg => pegleg}/__init__.py | 0 {src/bin/pegleg/pegleg => pegleg}/cli.py | 0 {src/bin/pegleg/pegleg => pegleg}/config.py | 0 .../pegleg => pegleg}/engine/__init__.py | 0 .../pegleg => pegleg}/engine/errorcodes.py | 0 .../pegleg => pegleg}/engine/exceptions.py | 0 .../pegleg/pegleg => pegleg}/engine/lint.py | 0 .../pegleg => pegleg}/engine/repository.py | 0 pegleg/engine/site.py | 135 ++++++++++++++++++ .../pegleg/pegleg => pegleg}/engine/stub.py | 0 .../pegleg => pegleg}/engine/util/__init__.py | 0 .../pegleg => pegleg}/engine/util/deckhand.py | 0 .../engine/util/definition.py | 0 .../pegleg => pegleg}/engine/util/files.py | 0 .../pegleg => pegleg}/engine/util/git.py | 0 .../schemas/deckhand-metadata-control.yaml | 0 .../schemas/deckhand-metadata-document.yaml | 0 .../schemas/deckhand-root.yaml | 0 .../pegleg => pegleg}/schemas/manifest.yaml | 0 .../requirements.txt => requirements.txt | 0 src/bin/pegleg/setup.py => setup.py | 0 src/bin/pegleg/tox.ini | 37 ----- ...-requirements.txt => test-requirements.txt | 0 {src/bin/pegleg/tests => tests}/__init__.py | 0 .../pegleg/tests => tests}/unit/__init__.py | 0 .../pegleg/tests => tests}/unit/conftest.py | 0 .../tests => tests}/unit/engine/__init__.py | 0 .../tests => tests}/unit/engine/test_lint.py | 0 .../unit/engine/test_selectable_linting.py | 0 .../unit/engine/test_site_collect.py | 0 .../unit/engine/test_site_repository.py | 0 .../unit/engine/test_util_files.py | 0 .../unit/engine/util/__init__.py | 0 .../unit/engine/util/test_git.py | 0 .../pegleg/tests => tests}/unit/fixtures.py | 0 .../pegleg/tests => tests}/unit/test_utils.py | 0 tox.ini | 52 ++++--- 42 files changed, 208 insertions(+), 76 deletions(-) rename {src/bin/pegleg/pegleg => pegleg}/__init__.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/cli.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/config.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/__init__.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/errorcodes.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/exceptions.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/lint.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/repository.py (100%) create mode 100644 pegleg/engine/site.py rename {src/bin/pegleg/pegleg => pegleg}/engine/stub.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/util/__init__.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/util/deckhand.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/util/definition.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/util/files.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/engine/util/git.py (100%) rename {src/bin/pegleg/pegleg => pegleg}/schemas/deckhand-metadata-control.yaml (100%) rename {src/bin/pegleg/pegleg => pegleg}/schemas/deckhand-metadata-document.yaml (100%) rename {src/bin/pegleg/pegleg => pegleg}/schemas/deckhand-root.yaml (100%) rename {src/bin/pegleg/pegleg => pegleg}/schemas/manifest.yaml (100%) rename src/bin/pegleg/requirements.txt => requirements.txt (100%) rename src/bin/pegleg/setup.py => setup.py (100%) delete mode 100644 src/bin/pegleg/tox.ini rename src/bin/pegleg/test-requirements.txt => test-requirements.txt (100%) rename {src/bin/pegleg/tests => tests}/__init__.py (100%) rename {src/bin/pegleg/tests => tests}/unit/__init__.py (100%) rename {src/bin/pegleg/tests => tests}/unit/conftest.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/__init__.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/test_lint.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/test_selectable_linting.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/test_site_collect.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/test_site_repository.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/test_util_files.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/util/__init__.py (100%) rename {src/bin/pegleg/tests => tests}/unit/engine/util/test_git.py (100%) rename {src/bin/pegleg/tests => tests}/unit/fixtures.py (100%) rename {src/bin/pegleg/tests => tests}/unit/test_utils.py (100%) diff --git a/.zuul.yaml b/.zuul.yaml index 610ae93b..7a87520e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -66,7 +66,7 @@ timeout: 300 nodeset: airship-pegleg-single-node irrelevant-files: - - ^src/bin/pegleg/tests/.*$ + - ^tests/.*$ - ^setup.cfg$ - job: diff --git a/Makefile b/Makefile index 5cb62802..b51bdc0b 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -PEGLEG_BUILD_CTX ?= src/bin/pegleg +PEGLEG_BUILD_CTX ?= pegleg IMAGE_NAME ?= pegleg IMAGE_PREFIX ?= airshipit DOCKER_REGISTRY ?= quay.io @@ -45,12 +45,12 @@ tests: run_tests .PHONY: security security: - tox -c src/bin/pegleg/tox.ini -e bandit + tox -e bandit -# Run all unit tests under src/bin/pegleg +# Run all unit tests under pegleg .PHONY: run_tests run_tests: - tox -c src/bin/pegleg/tox.ini -e py35 + tox -e py35 # Perform Linting .PHONY: lint @@ -83,7 +83,7 @@ endif .PHONY: docs docs: clean - tox -edocs + tox -e docs .PHONY: clean clean: @@ -91,8 +91,8 @@ clean: .PHONY: py_lint py_lint: - cd src/bin/pegleg;tox -e pep8 + cd pegleg;tox -e pep8 .PHONY: py_format py_format: - cd src/bin/pegleg;tox -e fmt + cd pegleg;tox -e fmt diff --git a/doc/source/conf.py b/doc/source/conf.py index caa35783..654e0495 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -18,7 +18,8 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../../src/bin/pegleg')) +sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('../../')) import sphinx_rtd_theme @@ -105,7 +106,7 @@ html_static_path = [] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'ucpintdoc' +htmlhelp_basename = 'peglegdoc' # -- Options for LaTeX output --------------------------------------------- @@ -128,3 +129,32 @@ latex_elements = { # 'figure_align': 'htbp', } +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'pegleg.tex', u'Pegleg Documentation', + u'Pegleg Authors', 'manual'), +] + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'pegleg', u'Pegleg Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'pegleg', u'Pegleg Documentation', + author, 'pegleg', 'Document-based aggregation and linting service.', + 'Miscellaneous'), +] diff --git a/doc/source/developer-overview.rst b/doc/source/developer-overview.rst index 7db0eed6..2f85c80b 100644 --- a/doc/source/developer-overview.rst +++ b/doc/source/developer-overview.rst @@ -72,7 +72,7 @@ Pegleg strives to conform to the `Airship coding conventions`_. Python ------ -The Pegleg code base lives under ``/src/bin/pegleg``. Pegleg supports py35 +The Pegleg code base lives under ``pegleg``. Pegleg supports py35 and py36 interpreters. Docker @@ -91,7 +91,7 @@ target: ``run_pegleg``. Testing ======= -All Pegleg tests are nested under ``/src/bin/pegleg/tests``. +All Pegleg tests are nested under ``tests``. Pegleg comes equipped with a number of `tox`_ targets for running unit tests, as well as `pep8`_ and `Bandit`_ checks. diff --git a/images/pegleg/Dockerfile b/images/pegleg/Dockerfile index dfa450df..66966b23 100644 --- a/images/pegleg/Dockerfile +++ b/images/pegleg/Dockerfile @@ -4,10 +4,8 @@ FROM ${FROM} VOLUME /var/pegleg WORKDIR /var/pegleg -ARG ctx_base=src/bin/pegleg - -COPY ${ctx_base}/requirements.txt /opt/pegleg/requirements.txt +COPY requirements.txt /opt/pegleg/requirements.txt RUN pip3 install --no-cache-dir -r /opt/pegleg/requirements.txt -COPY ${ctx_base} /opt/pegleg +COPY . /opt/pegleg RUN pip3 install -e /opt/pegleg diff --git a/src/bin/pegleg/pegleg/__init__.py b/pegleg/__init__.py similarity index 100% rename from src/bin/pegleg/pegleg/__init__.py rename to pegleg/__init__.py diff --git a/src/bin/pegleg/pegleg/cli.py b/pegleg/cli.py similarity index 100% rename from src/bin/pegleg/pegleg/cli.py rename to pegleg/cli.py diff --git a/src/bin/pegleg/pegleg/config.py b/pegleg/config.py similarity index 100% rename from src/bin/pegleg/pegleg/config.py rename to pegleg/config.py diff --git a/src/bin/pegleg/pegleg/engine/__init__.py b/pegleg/engine/__init__.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/__init__.py rename to pegleg/engine/__init__.py diff --git a/src/bin/pegleg/pegleg/engine/errorcodes.py b/pegleg/engine/errorcodes.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/errorcodes.py rename to pegleg/engine/errorcodes.py diff --git a/src/bin/pegleg/pegleg/engine/exceptions.py b/pegleg/engine/exceptions.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/exceptions.py rename to pegleg/engine/exceptions.py diff --git a/src/bin/pegleg/pegleg/engine/lint.py b/pegleg/engine/lint.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/lint.py rename to pegleg/engine/lint.py diff --git a/src/bin/pegleg/pegleg/engine/repository.py b/pegleg/engine/repository.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/repository.py rename to pegleg/engine/repository.py diff --git a/pegleg/engine/site.py b/pegleg/engine/site.py new file mode 100644 index 00000000..b78accf3 --- /dev/null +++ b/pegleg/engine/site.py @@ -0,0 +1,135 @@ +# Copyright 2018 AT&T Intellectual Property. All other rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import csv +import json +import logging +import os + +import click +import yaml + +from pegleg.engine import util + +__all__ = ('collect', 'list_', 'show', 'render') + +LOG = logging.getLogger(__name__) + + +def _read_and_format_yaml(filename): + with open(filename) as f: + lines_to_write = f.readlines() + if lines_to_write[0] != '---\n': + lines_to_write = ['---\n'] + lines_to_write + if lines_to_write[-1] != '...\n': + lines_to_write.append('...\n') + return lines_to_write or [] + + +def _collect_to_stdout(site_name): + """Collects all documents related to ``site_name`` and outputs them to + stdout via ``output_stream``. + """ + try: + for repo_base, filename in util.definition.site_files_by_repo( + site_name): + for line in _read_and_format_yaml(filename): + # This code is a pattern to convert \r\n to \n. + click.echo("\n".join(line.splitlines())) + except Exception as ex: + raise click.ClickException("Error printing output: %s" % str(ex)) + + +def _collect_to_file(site_name, save_location): + """Collects all documents related to ``site_name`` and outputs them to + the file denoted by ``save_location``. + """ + if not os.path.exists(save_location): + LOG.debug("Collection save location %s does not exist. Creating " + "automatically.", save_location) + os.makedirs(save_location) + # In case save_location already exists and isn't a directory. + if not os.path.isdir(save_location): + raise click.ClickException('save_location %s already exists, but must ' + 'be a directory' % save_location) + + save_files = dict() + try: + for repo_base, filename in util.definition.site_files_by_repo( + site_name): + repo_name = os.path.normpath(repo_base).split(os.sep)[-1] + save_file = os.path.join(save_location, repo_name + '.yaml') + if repo_name not in save_files: + save_files[repo_name] = open(save_file, "w") + LOG.debug("Collecting file %s to file %s" % (filename, save_file)) + save_files[repo_name].writelines(_read_and_format_yaml(filename)) + except Exception as ex: + raise click.ClickException("Error saving output: %s" % str(ex)) + finally: + for f in save_files.values(): + f.close() + + +def collect(site_name, save_location): + if save_location: + _collect_to_file(site_name, save_location) + else: + _collect_to_stdout(site_name) + + +def render(site_name, output_stream): + documents = [] + for filename in util.definition.site_files(site_name): + with open(filename) as f: + documents.extend(list(yaml.safe_load_all(f))) + + rendered_documents, errors = util.deckhand.deckhand_render( + documents=documents) + err_msg = '' + if errors: + for err in errors: + if isinstance(err, tuple) and len(err) > 1: + err_msg += ': '.join(err) + '\n' + else: + err_msg += str(err) + '\n' + raise click.ClickException(err_msg) + yaml.dump_all(rendered_documents, output_stream, default_flow_style=False) + + +def list_(output_stream): + """List site names for a given repository.""" + + # TODO(felipemonteiro): This should output a formatted table, not rows of + # data without delimited columns. + fieldnames = ['site_name', 'site_type', 'repositories'] + writer = csv.DictWriter( + output_stream, fieldnames=fieldnames, delimiter=' ') + for site_name in util.files.list_sites(): + params = util.definition.load_as_params(site_name) + # TODO(felipemonteiro): This is a temporary hack around legacy manifest + # repositories containing the name of a directory that symbolizes a + # repository. Once all these manifest repositories migrate over to Git + # references instead, remove this hack. + # NOTE(felipemonteiro): The 'revision' information can instead be + # computed using :func:`process_site_repository` and storing into + # a configuration via a "set_site_revision" function, for example. + if 'revision' in params: + params.pop('revision') + writer.writerow(params) + + +def show(site_name, output_stream): + data = util.definition.load_as_params(site_name) + data['files'] = list(util.definition.site_files(site_name)) + json.dump(data, output_stream, indent=2, sort_keys=True) diff --git a/src/bin/pegleg/pegleg/engine/stub.py b/pegleg/engine/stub.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/stub.py rename to pegleg/engine/stub.py diff --git a/src/bin/pegleg/pegleg/engine/util/__init__.py b/pegleg/engine/util/__init__.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/util/__init__.py rename to pegleg/engine/util/__init__.py diff --git a/src/bin/pegleg/pegleg/engine/util/deckhand.py b/pegleg/engine/util/deckhand.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/util/deckhand.py rename to pegleg/engine/util/deckhand.py diff --git a/src/bin/pegleg/pegleg/engine/util/definition.py b/pegleg/engine/util/definition.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/util/definition.py rename to pegleg/engine/util/definition.py diff --git a/src/bin/pegleg/pegleg/engine/util/files.py b/pegleg/engine/util/files.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/util/files.py rename to pegleg/engine/util/files.py diff --git a/src/bin/pegleg/pegleg/engine/util/git.py b/pegleg/engine/util/git.py similarity index 100% rename from src/bin/pegleg/pegleg/engine/util/git.py rename to pegleg/engine/util/git.py diff --git a/src/bin/pegleg/pegleg/schemas/deckhand-metadata-control.yaml b/pegleg/schemas/deckhand-metadata-control.yaml similarity index 100% rename from src/bin/pegleg/pegleg/schemas/deckhand-metadata-control.yaml rename to pegleg/schemas/deckhand-metadata-control.yaml diff --git a/src/bin/pegleg/pegleg/schemas/deckhand-metadata-document.yaml b/pegleg/schemas/deckhand-metadata-document.yaml similarity index 100% rename from src/bin/pegleg/pegleg/schemas/deckhand-metadata-document.yaml rename to pegleg/schemas/deckhand-metadata-document.yaml diff --git a/src/bin/pegleg/pegleg/schemas/deckhand-root.yaml b/pegleg/schemas/deckhand-root.yaml similarity index 100% rename from src/bin/pegleg/pegleg/schemas/deckhand-root.yaml rename to pegleg/schemas/deckhand-root.yaml diff --git a/src/bin/pegleg/pegleg/schemas/manifest.yaml b/pegleg/schemas/manifest.yaml similarity index 100% rename from src/bin/pegleg/pegleg/schemas/manifest.yaml rename to pegleg/schemas/manifest.yaml diff --git a/src/bin/pegleg/requirements.txt b/requirements.txt similarity index 100% rename from src/bin/pegleg/requirements.txt rename to requirements.txt diff --git a/src/bin/pegleg/setup.py b/setup.py similarity index 100% rename from src/bin/pegleg/setup.py rename to setup.py diff --git a/src/bin/pegleg/tox.ini b/src/bin/pegleg/tox.ini deleted file mode 100644 index e4e135a6..00000000 --- a/src/bin/pegleg/tox.ini +++ /dev/null @@ -1,37 +0,0 @@ -[tox] -envlist = py35, py36, pep8 -skipsdist = True - -[testenv] -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -basepython=python3 -whitelist_externals = - find -commands = - find . -type f -name "*.pyc" -delete - pytest \ - {posargs} - -[testenv:fmt] -basepython=python3 -deps = - -r{toxinidir}/test-requirements.txt -commands = - yapf --style=pep8 -ir {toxinidir}/pegleg {toxinidir}/tests - -[testenv:pep8] -basepython=python3 -deps = - -r{toxinidir}/test-requirements.txt -commands = - flake8 {toxinidir}/pegleg - bandit -r pegleg -n 5 - -[testenv:bandit] -basepython=python3 -commands = bandit -r pegleg -n 5 - -[flake8] -ignore = E125,E251,W503 diff --git a/src/bin/pegleg/test-requirements.txt b/test-requirements.txt similarity index 100% rename from src/bin/pegleg/test-requirements.txt rename to test-requirements.txt diff --git a/src/bin/pegleg/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/bin/pegleg/tests/__init__.py rename to tests/__init__.py diff --git a/src/bin/pegleg/tests/unit/__init__.py b/tests/unit/__init__.py similarity index 100% rename from src/bin/pegleg/tests/unit/__init__.py rename to tests/unit/__init__.py diff --git a/src/bin/pegleg/tests/unit/conftest.py b/tests/unit/conftest.py similarity index 100% rename from src/bin/pegleg/tests/unit/conftest.py rename to tests/unit/conftest.py diff --git a/src/bin/pegleg/tests/unit/engine/__init__.py b/tests/unit/engine/__init__.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/__init__.py rename to tests/unit/engine/__init__.py diff --git a/src/bin/pegleg/tests/unit/engine/test_lint.py b/tests/unit/engine/test_lint.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/test_lint.py rename to tests/unit/engine/test_lint.py diff --git a/src/bin/pegleg/tests/unit/engine/test_selectable_linting.py b/tests/unit/engine/test_selectable_linting.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/test_selectable_linting.py rename to tests/unit/engine/test_selectable_linting.py diff --git a/src/bin/pegleg/tests/unit/engine/test_site_collect.py b/tests/unit/engine/test_site_collect.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/test_site_collect.py rename to tests/unit/engine/test_site_collect.py diff --git a/src/bin/pegleg/tests/unit/engine/test_site_repository.py b/tests/unit/engine/test_site_repository.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/test_site_repository.py rename to tests/unit/engine/test_site_repository.py diff --git a/src/bin/pegleg/tests/unit/engine/test_util_files.py b/tests/unit/engine/test_util_files.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/test_util_files.py rename to tests/unit/engine/test_util_files.py diff --git a/src/bin/pegleg/tests/unit/engine/util/__init__.py b/tests/unit/engine/util/__init__.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/util/__init__.py rename to tests/unit/engine/util/__init__.py diff --git a/src/bin/pegleg/tests/unit/engine/util/test_git.py b/tests/unit/engine/util/test_git.py similarity index 100% rename from src/bin/pegleg/tests/unit/engine/util/test_git.py rename to tests/unit/engine/util/test_git.py diff --git a/src/bin/pegleg/tests/unit/fixtures.py b/tests/unit/fixtures.py similarity index 100% rename from src/bin/pegleg/tests/unit/fixtures.py rename to tests/unit/fixtures.py diff --git a/src/bin/pegleg/tests/unit/test_utils.py b/tests/unit/test_utils.py similarity index 100% rename from src/bin/pegleg/tests/unit/test_utils.py rename to tests/unit/test_utils.py diff --git a/tox.ini b/tox.ini index 093a2bd8..da840ed2 100644 --- a/tox.ini +++ b/tox.ini @@ -10,40 +10,46 @@ setenv = VIRTUAL_ENV={envdir} LANGUAGE=en_US LC_ALL=en_US.utf-8 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY - -[testenv:venv] -commands = {posargs} - -[testenv:py35] -basepython = python3.5 +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +basepython=python3 +whitelist_externals = + find commands = - # Run all unit tests under src/bin/pegleg - tox -c src/bin/pegleg/tox.ini -e py35 -whitelist_externals = tox - -[testenv:py36] -basepython = python3.6 -commands = - # Run all unit tests under src/bin/pegleg - tox -c src/bin/pegleg/tox.ini -e py36 -whitelist_externals = tox + find . -type f -name "*.pyc" -delete + pytest \ + {posargs} [testenv:fmt] -basepython = python3 +basepython=python3 +deps = + -r{toxinidir}/test-requirements.txt commands = - tox -c src/bin/pegleg/tox.ini -e fmt -whitelist_externals = tox + yapf --style=pep8 -ir {toxinidir}/pegleg {toxinidir}/tests [testenv:pep8] -basepython = python3 +basepython=python3 +deps = + -r{toxinidir}/test-requirements.txt commands = - tox -c src/bin/pegleg/tox.ini -e pep8 -whitelist_externals = tox + flake8 {toxinidir}/pegleg + bandit -r pegleg -n 5 [testenv:docs] basepython = python3 deps = - -r{toxinidir}/src/bin/pegleg/requirements.txt + -r{toxinidir}/requirements.txt -r{toxinidir}/doc/requirements.txt commands = {toxinidir}/tools/gate/build-docs.sh + +[testenv:bandit] +basepython=python3 +commands = bandit -r pegleg -n 5 + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E125,E251,W503