matkapi/pysidetap

View on GitHub
tox.ini

Summary

Maintainability
Test Coverage
[tox]
minversion = 3.25.0
ignore_basepython_conflict = true
# these are the environments that will run when you
# execute `tox` in the command-line
# bellow you will find explanations for all environments
envlist =
    build
    docs
    test
    lint
    pr

# configures which environments run with each python version
# the current configuration has the 'test' enviroment. This will run the
# unit test for running python version. It is not needed to state the python
# version because the installation process already ensures only supported
# versions are installed
[testenv]
basepython =
    {pr,test,build,docs,lint,radon,safety}: {env:TOXPYTHON:python3}
passenv = *

# configures the unittest environment for python 3.6
[testenv:test]
setenv =
    PYTHONPATH={toxinidir}/tests
    PYTHONUNBUFFERED=yes
usedevelop = true
# installs dependencies we need for testing
# by using tox, developers don't need to manage project's dependencies
# for unit testing
deps =
    -r{toxinidir}/requirements.txt
    coverage
    pytest
    pytest-cov
    hypothesis
# before running the tests erases any prerecord of coverage
commands_pre =
    coverage erase
# execute pytest
commands =
    pytest --cov --cov-report=term-missing --cov-append --cov-config=.coveragerc --hypothesis-show-statistics {posargs}
# after executing the pytest assembles the coverage reports
commands_post = 
    coverage report
    coverage html
    coverage xml

# in previous verions, I had independent environments to manage the
# coverage reports. However, I found that doing such as pre and post
# commands facilitates many configuration details

[testenv:pr]
# these commands cannot be in the [testenv:build] because they will trigger
# after the versionbump which commit has different characteristics of the PR
skip_install = true
commands =
    python {toxinidir}/devtools/check_changelog.py


# separates lint from build env
[testenv:lint]
deps =
    flake8>=4
    flake8-print>=5
    flake8-docstrings
    flake8-bugbear
    pygments
    isort
skip_install = true
commands =
    flake8 {posargs:src tests setup.py docs}
    isort --verbose --check-only --diff {posargs:src tests setup.py docs/conf.py}

# asserts package build integrity
[testenv:build]
skip_install = true
# setenv here integrates with commit message in .bumpversion.cfg
# we can tests bump2version with an actual commit
setenv =
    COMMIT_MSG = Test commit message
# dependencies needed for code quality checks
# you need to add here any additional dependencies you might need
deps =
    setuptools
    wheel
    twine
    docutils
    check-manifest
    readme-renderer
    bump2version
commands_pre = python {toxinidir}/devtools/clean_dist_check.py
commands =
    python --version
    python setup.py sdist bdist_wheel
    twine check dist/*.whl
    twine check dist/*.tar.gz
    check-manifest {toxinidir}
    bump2version --dry-run --verbose --allow-dirty patch
    bump2version --dry-run --verbose --allow-dirty minor
    bump2version --dry-run --verbose --allow-dirty major
commands_post = python {toxinidir}/devtools/clean_dist_check.py

# code quality assessment. This is not a check in the CI, serves just
# as info for the developer
[testenv:radon]
deps = radon
skip_install = true
commands = 
    radon cc -s --total-average --no-assert {posargs:src/}
    radon mi -m -s {posargs:src/}

# Simulate docs building as it will occur on ReadTheDocs
# if this fails, most likely RTD build will fail
[testenv:docs]
usedevelop = true
deps =
    -r{toxinidir}/devtools/docs_requirements.txt
commands =
    sphinx-build {posargs:-E} -b html docs dist/docs
    #sphinx-build -b linkcheck docs dist/docs

# safety checks
[testenv:safety]
skip_install = true
deps = safety
commands = safety check

# my favourite configuration for flake8 styling
# https://flake8.pycqa.org/en/latest/#
[flake8]
max_line_length = 100
hang-closing = true
ignore = 
    W293
    W503
    D412
    D105
    E133
per-file-ignores = setup.py:E501
docstring-convention = numpy
# normally I exclude init because it is very hard to configure init
# without breaking many rules
exclude = src/pysidetap/__init__.py

# configuration for the isort module
# https://github.com/timothycrosley/isort
[isort]
skip = __init__.py
line_length = 80
indent = 4
multi_line_output = 8
include_trailing_comma = true
lines_after_imports = 2
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
#known_future_library=future,pies
#known_standard_library=std,std2
known_first_party = pysidetap
# you should add here your known thirdparties, it will facilitate
# the job to isort
known_third_party = 
    hypothesis
    matplotlib
    numpy
    pytest

[tool:pytest]
# If a pytest section is found in one of the possible config files
# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others,
# so if you add a pytest config section elsewhere,
# you will need to delete this section from setup.cfg.
#norecursedirs =
#migrations
addopts = -p pytest_cov
python_files =
    test_*.py
    *_test.py
    tests.py
#addopts =
#    -ra
#    --strict
#    --doctest-modules
#    --doctest-glob=\*.rst
#    --tb=short
testpaths =
    tests