From b8b4f430928f3ce86cd6916c0b622dc87eb74c7c Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 2 Feb 2018 11:24:45 +0000 Subject: [PATCH] Add tox.ini for building and flake8 tests Add a tox.ini for creating virtualenvs and then executing builds, flake8, unit tests and charm proof in those venvs. Example: tox -e pep8 tox -e build tox -e charm-proof tox -e unit-tests Partial-Bug: #1745966 --- .gitignore | 4 ++++ .stestr.conf | 3 +++ requirements.txt | 2 ++ test-requirements.txt | 4 ++++ tox.ini | 44 ++++++++++++++++++++++++++++++++++++++++++ unit_tests/__init__.py | 0 6 files changed, 57 insertions(+) create mode 100644 .stestr.conf create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini create mode 100644 unit_tests/__init__.py diff --git a/.gitignore b/.gitignore index b25c15b..17fa1cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ *~ +build/* +.tox/* +.stestr/* +__pycache__ diff --git a/.stestr.conf b/.stestr.conf new file mode 100644 index 0000000..5fcccac --- /dev/null +++ b/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./unit_tests +top_dir=./ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..11b099f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# Requirements to build the charm +charm-tools diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..667d3b9 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,4 @@ +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 +mock>=1.2 +coverage>=3.6 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..f94add4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,44 @@ +[tox] +skipsdist = True +envlist = pep8,unit-tests +skip_missing_interpreters = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 + TERM=linux + LAYER_PATH={toxinidir}/layers + INTERFACE_PATH={toxinidir}/interfaces + JUJU_REPOSITORY={toxinidir}/build +passenv = http_proxy https_proxy USER +install_command = + pip install {opts} {packages} +deps = + -r{toxinidir}/requirements.txt + +[testenv:build] +basepython = python2.7 +commands = + charm-build --log-level DEBUG -o {toxinidir}/build . {posargs} + +[testenv:pep8] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = flake8 --exclude build {posargs} . + +[testenv:unit-tests] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = ostestr {posargs} + +[testenv:venv] +commands = {posargs} + +[flake8] +# E402 ignore necessary for path append before sys module import in actions +ignore = E402 + +[testenv:charm-proof] +basepython = python2.7 +toxworkdir = {toxinidir}/build/builds/vault +commands = charm-proof diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py new file mode 100644 index 0000000..e69de29