Refactor tox.ini to be more versatile.

This commit is contained in:
Andris Raugulis 2017-03-26 05:39:24 +03:00
parent 29d9e4270d
commit 6d9f5e6f2a
2 changed files with 34 additions and 47 deletions

View File

@ -1,4 +1,5 @@
language: python language: python
sudo: false
matrix: matrix:
include: include:
- python: 2.6 - python: 2.6
@ -33,19 +34,17 @@ install:
- pip install --upgrade tox coveralls codecov - pip install --upgrade tox coveralls codecov
script: script:
- if [ -z "${TOXENV##*py3*}" ]; then - if [ -z "${TOXENV##*py3*}" ]; then
export MYPYBASE=python;
if [ -z "${TOXENV##*pypy3*}" ]; then if [ -z "${TOXENV##*pypy3*}" ]; then
_pydir=$(dirname $(which python)); _pydir=$(dirname $(which python));
ln -s -- "${_pydir}/python" "${_pydir}/pypy3"; ln -s -- "${_pydir}/python" "${_pydir}/pypy3";
export TOXENV=${TOXENV},cov,lint; export TOXENV=${TOXENV}-test,${TOXENV}-lint;
else else
export TOXENV=${TOXENV},cov,type,lint; export TOXENV=${TOXENV}-test,${TOXENV}-type,${TOXENV}-lint;
fi fi
else else
export MYPYBASE=python-unknown; export TOXENV=${TOXENV}-test,${TOXENV}-lint;
export TOXENV=${TOXENV},cov,lint;
fi fi
- tox -e $TOXENV - tox -e $TOXENV,cov
after_success: after_success:
- coveralls - coveralls
- codecov - codecov

70
tox.ini
View File

@ -1,20 +1,36 @@
[tox] [tox]
envlist = py26,py27,py33,py34,py35,py36,py37,jython,pypy,pypy3,cov,type,lint envlist =
py{26,27,py,py3}-{test,pylint,flake8,vulture}
py{33,34,35,36,37}-{test,mypy,pylint,flake8,vulture}
cov
skipsdist = true skipsdist = true
skip_missing_interpreters = true skip_missing_interpreters = true
[testenv] [testenv]
deps = deps =
pytest==3.0.7 test: pytest==3.0.7
coverage==4.3.4 test,cov: {[testenv:cov]deps}
colorama==0.3.7 test,py{33,34,35,36,37}-{type,mypy}: colorama==0.3.7
py{33,34,35,36,37}-{type,mypy}: {[testenv:mypy]deps}
lint,pylint: {[testenv:pylint]deps}
lint,flake8: {[testenv:flake8]deps}
lint,vulture: {[testenv:vulture]deps}
setenv = setenv =
SSHAUDIT = {toxinidir}/ssh-audit.py SSHAUDIT = {toxinidir}/ssh-audit.py
COVERAGE_FILE = {toxinidir}/.coverage.{envname} test: COVERAGE_FILE = {toxinidir}/.coverage.{envname}
type,mypy: MYPYPATH = {toxinidir}/test/stubs
type,mypy: MYPYHTML = {toxinidir}/html/mypy
commands = commands =
coverage run --source ssh-audit -m -- pytest -v {posargs:test} test: coverage run --source ssh-audit -m -- pytest -v {posargs:test}
coverage report --show-missing test: coverage report --show-missing
coverage html -d {toxinidir}/html/coverage.{envname} test: - coverage html -d {toxinidir}/html/coverage.{envname}
py{33,34,35,36,37}-{type,mypy}: {[testenv:mypy]commands}
lint,pylint: {[testenv:pylint]commands}
lint,flake8: {[testenv:flake8]commands}
lint,vulture: {[testenv:vulture]commands}
ignore_outcome =
type: true
lint: true
[testenv:cov] [testenv:cov]
deps = deps =
@ -25,32 +41,25 @@ commands =
coverage erase coverage erase
coverage combine coverage combine
coverage report --show-missing coverage report --show-missing
coverage html -d {toxinidir}/html/coverage - coverage html -d {toxinidir}/html/coverage
ignore_outcome = true
[testenv:mypy] [testenv:mypy]
basepython =
{env:MYPYBASE:python3.5}
deps = deps =
colorama==0.3.7 colorama==0.3.7
mypy==0.501 mypy==0.501
lxml==3.7.3 lxml==3.7.3
setenv =
{[testenv]setenv}
MYPYPATH = {toxinidir}/test/stubs
MYPYHTML = {toxinidir}/html/mypy
commands = commands =
mypy \ mypy \
--show-error-context \ --show-error-context \
--config-file {toxinidir}/tox.ini \ --config-file {toxinidir}/tox.ini \
--html-report {env:MYPYHTML}.py3 \ --html-report {env:MYPYHTML}.py3.{envname} \
{posargs:{env:SSHAUDIT}} {posargs:{env:SSHAUDIT}}
mypy \ mypy \
-2 \ -2 \
--no-warn-incomplete-stub \ --no-warn-incomplete-stub \
--show-error-context \ --show-error-context \
--config-file {toxinidir}/tox.ini \ --config-file {toxinidir}/tox.ini \
--html-report {env:MYPYHTML}.py2 \ --html-report {env:MYPYHTML}.py2.{envname} \
{posargs:{env:SSHAUDIT}} {posargs:{env:SSHAUDIT}}
[testenv:pylint] [testenv:pylint]
@ -72,7 +81,8 @@ commands =
flake8 {posargs:{env:SSHAUDIT}} flake8 {posargs:{env:SSHAUDIT}}
[testenv:vulture] [testenv:vulture]
deps = vulture deps =
vulture
commands = commands =
python -c "import sys; from subprocess import Popen, PIPE; \ python -c "import sys; from subprocess import Popen, PIPE; \
a = ['vulture'] + r'{posargs:{env:SSHAUDIT}}'.split(' '); \ a = ['vulture'] + r'{posargs:{env:SSHAUDIT}}'.split(' '); \
@ -81,28 +91,6 @@ commands =
print(b'\n'.join(l).decode('utf-8')); \ print(b'\n'.join(l).decode('utf-8')); \
sys.exit(1 if len(l) > 0 else 0)" sys.exit(1 if len(l) > 0 else 0)"
[testenv:type]
basepython =
{[testenv:mypy]basepython}
deps =
{[testenv:mypy]deps}
setenv =
{[testenv:mypy]setenv}
commands =
{[testenv:mypy]commands}
ignore_outcome = true
[testenv:lint]
deps =
{[testenv:pylint]deps}
{[testenv:flake8]deps}
{[testenv:vulture]deps}
commands =
{[testenv:pylint]commands}
{[testenv:flake8]commands}
{[testenv:vulture]commands}
ignore_outcome = true
[mypy] [mypy]
ignore_missing_imports = False ignore_missing_imports = False