Update tox automation to work with new module structure

This commit is contained in:
Ethan Paul 2020-11-11 22:34:42 -05:00
parent 50f6e3d151
commit 8c4e596316
No known key found for this signature in database
GPG Key ID: D0E2CBF1245E92BF

44
tox.ini
View File

@ -10,31 +10,42 @@ deps =
pytest-cov pytest-cov
toml toml
commands = commands =
pytest --cov tox_poetry_installer --cov-config {toxinidir}/.coveragerc tests/ --cov-report term-missing pytest --cov {envsitepackagesdir}/tox_poetry_installer --cov-config {toxinidir}/.coveragerc --cov-report term-missing tests/
[testenv:static] [testenv:static]
description = Static formatting and quality enforcement description = Static formatting and quality enforcement
require_locked_deps = true
basepython = python3.8 basepython = python3.8
platform = linux
ignore_errors = true ignore_errors = true
require_locked_deps = true
deps = deps =
pylint pylint
mypy mypy
black black
reorder-python-imports reorder-python-imports
pre-commit pre-commit
allowlist_externals =
bash
commands = commands =
black {toxinidir}/tox_poetry_installer.py black {toxinidir}/tox_poetry_installer/
reorder-python-imports {toxinidir}/tox_poetry_installer.py # Oh man this is a doozy. If submodules are ever added to this plugin this will break, but I'm
# frustrated enough at this point that I'll need to take another look at it later to fix that.
# reorder-python-imports doesn't support handling directories on the CLI
# (https://github.com/asottile/reorder_python_imports/pull/76) and because the command is
# invoked directly (see comment below) we need file globbing to work around it.
# The "--unclassifiable-application-module" is a work around for reorder-python-imports not
# properly detecting the top-level module when run in a bash-wrapped command like this.
bash -c "reorder-python-imports {toxinidir}/tox_poetry_installer/*.py --unclassifiable-application-module tox_poetry_installer"
pre-commit run --all-files pre-commit run --all-files
pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tox_poetry_installer.py pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tox_poetry_installer/
mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tox_poetry_installer.py mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tox_poetry_installer/
[testenv:static-tests] [testenv:static-tests]
description = Static formatting and quality enforcement for the tests description = Static formatting and quality enforcement for the tests
require_locked_deps = true
basepython = python3.8 basepython = python3.8
platform = linux
ingore_errors = true ingore_errors = true
require_locked_deps = true
deps = deps =
pylint pylint
mypy mypy
@ -44,23 +55,26 @@ allowlist_externals =
bash bash
commands = commands =
black {toxinidir}/tests/ black {toxinidir}/tests/
# These bash-wrapped commands hurt my face, but these tools expect directories to be valid
# python modules, which the "tests/" directory is not. Since tox calls all commands directly
# (which is good) file globbing doesn't work. To make file globbing work they need to be wrapped
# in a bash call (which is bad).
bash -c "reorder-python-imports {toxinidir}/tests/*.py --unclassifiable-application-module tox_poetry_installer" bash -c "reorder-python-imports {toxinidir}/tests/*.py --unclassifiable-application-module tox_poetry_installer"
bash -c "pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tests/*.py" bash -c "pylint --rcfile {toxinidir}/.pylintrc {toxinidir}/tests/*.py"
bash -c "mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tests/*.py" bash -c "mypy --ignore-missing-imports --no-strict-optional {toxinidir}/tests/*.py"
[testenv:security] [testenv:security]
description = Security checks description = Security checks
require_locked_deps = true
basepython = python3.8 basepython = python3.8
ignore_errors = true platform = linux
skip_install = true ingore_errors = true
require_locked_deps = true
deps = deps =
bandit bandit
safety safety
poetry poetry
allowlist_externals =
bash
commands = commands =
bandit --quiet {toxinidir}/tox_poetry_installer.py bandit --recursive --quiet {toxinidir}/tox_poetry_installer/
bash -c "bandit --quiet --skip B101 {toxinidir}/tests/*.py" bandit --recursive --quiet --skip B101 {toxinidir}/tests/
bash -c "poetry export --format requirements.txt --without-hashes --dev | safety check --stdin --bare" poetry export --format requirements.txt --output {envtmpdir}/requirements.txt --without-hashes --dev
safety check --bare --file {envtmpdir}/requirements.txt