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
This commit is contained in:
Liam Young 2018-02-02 11:24:45 +00:00
parent 1f496a0b07
commit b8b4f43092
6 changed files with 57 additions and 0 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
*~
build/*
.tox/*
.stestr/*
__pycache__

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=./unit_tests
top_dir=./

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
# Requirements to build the charm
charm-tools

4
test-requirements.txt Normal file
View File

@ -0,0 +1,4 @@
flake8>=2.2.4,<=2.4.1
os-testr>=0.4.1
mock>=1.2
coverage>=3.6

44
tox.ini Normal file
View File

@ -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

0
unit_tests/__init__.py Normal file
View File