[tox] envlist = py{27,35,36,37,38,39,310}, bandit, doc8, readme, mypy-py{2,3}, flake8, pylint, flake8-tests, pylint-tests, # prone to false positives vulture # Additional environments: # linters :: Runs all linters over all source code. # linters-tests :: Runs all linters over all tests. [testenv:default-python] basepython = python3 [testenv:base-command] commands = pytest --basetemp={envtmpdir} -l --cov base64io {posargs} [testenv] sitepackages = False passenv = # Pass through PyPI variables to tell secrets-helper where to look PYPI_SECRET_ARN TEST_PYPI_SECRET_ARN \ # Pass through twine password -- remove this once secrets-helper is fixed # https://github.com/awslabs/secrets-helper/issues/15 TWINE_PASSWORD deps = -rtest/requirements.txt commands = pytest --basetemp={envtmpdir} -l --cov base64io {posargs} # mypy [testenv:mypy-common] basepython = {[testenv:default-python]basepython} deps = # mypy outputs coverage data in a coverage 4.x format coverage==4.5.4 mypy mypy_extensions typing commands = python -m mypy \ --linecoverage-report build \ src/base64io/ [testenv:mypy-coverage] commands = # Make mypy linecoverage report readable by coverage python -c \ "t = open('.coverage', 'w');\ c = open('build/coverage.json').read();\ t.write('!coverage.py: This is a private format, don\'t read it directly!\n');\ t.write(c);\ t.close()" coverage report -m [testenv:mypy-py3] basepython = {[testenv:mypy-common]basepython} deps = {[testenv:mypy-common]deps} commands = {[testenv:mypy-common]commands} {[testenv:mypy-coverage]commands} [testenv:mypy-py2] ignore_basepython_conflict=True basepython = {[testenv:mypy-common]basepython} deps = coverage==4.5.4 # mypy dropped py2 support mypy[python2]<0.980 mypy_extensions typing commands = {[testenv:mypy-common]commands} --py2 {[testenv:mypy-coverage]commands} # Linters [testenv:flake8] basepython = {[testenv:default-python]basepython} deps = flake8 flake8-docstrings flake8-isort # https://github.com/JBKahn/flake8-print/pull/30 flake8-print>=3.1.0 commands = flake8 \ src/base64io/ \ setup.py \ doc/conf.py [testenv:flake8-tests] basepython = {[testenv:flake8]basepython} deps = {[testenv:flake8]deps} commands = flake8 \ # Ignore F811 redefinition errors in tests (breaks with pytest-mock use) # Ignore D103 docstring requirements for tests --ignore F811,D103 \ test/ [testenv:blacken-src] basepython = python3 deps = black commands = black --line-length 120 \ src/base64io/ \ setup.py \ doc/conf.py \ test/ [testenv:blacken-docs] basepython = python3 deps = blacken-docs commands = blacken-docs --line-length 90 \ README.rst [testenv:blacken] basepython = python3 deps = {[testenv:blacken-src]deps} {[testenv:blacken-docs]deps} commands = {[testenv:blacken-src]commands} {[testenv:blacken-docs]commands} [testenv:black-check] basepython = python3 deps = {[testenv:blacken]deps} commands = {[testenv:blacken-src]commands} --diff [testenv:isort-seed] basepython = python3 deps = seed-isort-config commands = seed-isort-config [testenv:isort] basepython = python3 # We need >=5.0.0 because # several configuration settings changed with 5.0.0 deps = isort>=5.0.0 commands = isort \ src \ test \ doc \ setup.py \ {posargs} [testenv:isort-check] basepython = python3 deps = {[testenv:isort]deps} commands = {[testenv:isort]commands} -c [testenv:autoformat] basepython = python3 deps = {[testenv:blacken]deps} {[testenv:isort]deps} commands = {[testenv:blacken]commands} {[testenv:isort]commands} [testenv:pylint] basepython = {[testenv:default-python]basepython} deps = -rtest/requirements/modern pyflakes pylint commands = pylint \ --rcfile=src/pylintrc \ src/base64io/ \ setup.py \ doc/conf.py [testenv:pylint-tests] basepython = {[testenv:pylint]basepython} deps = {[testenv:pylint]deps} commands = pylint \ --rcfile=test/pylintrc \ test/unit/ [testenv:doc8] basepython = {[testenv:default-python]basepython} deps = sphinx doc8 commands = doc8 doc/index.rst README.rst CHANGELOG.rst [testenv:readme] basepython = {[testenv:default-python]basepython} deps = readme_renderer commands = python setup.py check -r -s [testenv:bandit] basepython = {[testenv:default-python]basepython} deps = bandit commands = bandit -r src/base64io/ # Prone to false positives: only run independently [testenv:vulture] basepython = {[testenv:default-python]basepython} deps = vulture commands = vulture src/base64io/ [testenv:linters] basepython = {[testenv:default-python]basepython} deps = {[testenv:flake8]deps} {[testenv:pylint]deps} {[testenv:doc8]deps} {[testenv:readme]deps} {[testenv:bandit]deps} commands = {[testenv:flake8]commands} {[testenv:pylint]commands} {[testenv:doc8]commands} {[testenv:readme]commands} {[testenv:bandit]commands} [testenv:linters-tests] basepython = {[testenv:default-python]basepython} deps = {[testenv:flake8-tests]deps} {[testenv:pylint-tests]deps} commands = {[testenv:flake8-tests]commands} {[testenv:pylint-tests]commands} # Documentation [testenv:docs] basepython = {[testenv:default-python]basepython} deps = -rdoc/requirements.txt commands = sphinx-build -E -c doc/ -b html doc/ doc/build/html [testenv:docs-autobuild] basepython = {[testenv:default-python]basepython} deps = {[testenv:docs]deps} sphinx-autobuild commands = sphinx-autobuild -E -c {toxinidir}/doc/ -b html {toxinidir}/doc/ {toxinidir}/doc/build/html [testenv:serve-docs] basepython = {[testenv:default-python]basepython} skip_install = true changedir = doc/build/html deps = commands = python -m http.server {posargs} # Release tooling [testenv:build] basepython = {[testenv:default-python]basepython} skip_install = true deps = wheel setuptools commands = python setup.py sdist bdist_wheel [testenv:test-release] basepython = {[testenv:default-python]basepython} skip_install = true setenv = TWINE_USERNAME = __token__ deps = {[testenv:build]deps} twine commands = {[testenv:build]commands} twine upload --skip-existing dist/* [testenv:release] basepython = {[testenv:default-python]basepython} skip_install = true setenv = TWINE_REPOSITORY_URL = https://test.pypi.org/legacy/ TWINE_USERNAME = __token__ deps = {[testenv:build]deps} twine commands = {[testenv:build]commands} twine upload --skip-existing dist/*