[tox]
envlist =
    black
    py37
    doctest
    regression
    fuzz
    pylint
    pydocstyle
    flake8
    mypy
    doc8
    docs
    sloccount
    badges
    build
# trick to enable pre-installation of Cython
indexserver =
    preinstall = https://pypi.python.org/simple

[testenv]
depends = black
deps =
    :preinstall: cython
    nose
    coverage <5.0
    -rrequirements-test.txt
commands = nosetests []

[testenv:doctest]
basepython = python3.7
setenv =
    NOSE_WITH_COVERAGE=0
    NOSE_WITH_DOCTEST=1
passenv =
    NOSE_WITH_COVERAGE
    NOSE_WITH_DOCTEST
commands = nosetests --where={toxinidir}/abydos []

[testenv:py36-doctest]
basepython = python3.6
setenv = {[testenv:doctest]setenv}
passenv = {[testenv:doctest]passenv}
commands = {[testenv:doctest]commands}

[testenv:regression]
basepython = python3.7
commands = nosetests {toxinidir}/tests/regression --processes=-1 \
               --process-timeout=1200 --process-restartworker -c=0 -v []

[testenv:py36-regression]
basepython = python3.6
deps =
    :preinstall: cython
commands = {[testenv:regression]commands}

[testenv:fuzz]
basepython = python3.7
commands = nosetests {toxinidir}/tests/fuzz --processes=-1 \
               --process-timeout=1200 --process-restartworker -c=0 -v []

[testenv:py36-fuzz]
basepython = python3.6
deps =
    :preinstall: cython
commands = {[testenv:fuzz]commands}

[testenv:black]
depends =
changedir = {toxinidir}
basepython = python3.7
skip_install = true
deps = black
commands = black .

[testenv:pylint]
basepython = python3.7
skip_install = true
deps = pylint
commands = {toxinidir}/helpers/call_and_write_log.py \
               "pylint --rcfile=setup.cfg abydos" 0

[testenv:pydocstyle]
basepython = python3.7
skip_install = true
deps = pydocstyle
commands = {toxinidir}/helpers/call_and_write_log.py "pydocstyle --count ." 0

[testenv:pycodestyle]
basepython = python3.7
skip_install = true
deps = pycodestyle
commands = {toxinidir}/helpers/call_and_write_log.py "pycodestyle ." 0

[testenv:flake8]
basepython = python3.7
skip_install = true
deps =
    flake8
    flake8-mutable
    flake8-bandit
    flake8-blind-except
    flake8-bugbear
    flake8-comprehensions
    flake8-docstrings
    pydocstyle
    flake8-print
    flake8-fixme
    flake8_builtins
    flake8_coding
    flake8_copyright
    flake8_deprecated
    flake8_pep3101
    flake8_quotes
    flake8_self
    flake8-import-order
    flake8-mypy
    mccabe
    pep8-naming
    pyflakes
    flake8-html
    radon
    flake8-2020
    flake8-breakpoint
    flake8-return
    flake8-rst
    flake8-logging-format
    flake8-pep3101
    flake8-pyi
    flake8-strict
setenv =
    MYPYPATH = {toxinidir}
commands = {toxinidir}/helpers/call_and_write_log.py \
               "flake8 {toxinidir} --htmldir={toxinidir}/flake8" 0

[testenv:mypy]
basepython = python3.7
deps =
    mypy
    lxml
setenv =
    MYPYPATH = {toxinidir}
mypy_paths =
    abydos
commands = mypy {posargs:{[testenv:mypy]mypy_paths}} --txt-report mypy --html-report mypy

[testenv:doc8]
basepython = python3.7
skip_install = true
deps = doc8
commands = {toxinidir}/helpers/call_and_write_log.py "doc8 {toxinidir}" 0

[testenv:docs]
changedir = docs
basepython = python3.7
whitelist_externals=make
deps =
    sphinx
    sphinxcontrib-bibtex
    sphinx_rtd_theme
commands =
    sphinx-apidoc -e -M -o . ../abydos
    sphinx-build -j 8 -b html -d {envtmpdir}/doctrees . _build/html
    sphinx-build -j 8 -b epub -d {envtmpdir}/doctrees . _build/epub
    sphinx-build -j 8 -b latex -d {envtmpdir}/doctrees \
        -D latex_elements.papersize=letter . _build/latex
    make PDFLATEX=xelatex -C _build/latex all-pdf
    make PDFLATEX=xelatex -C _build/latex all-pdf
    sphinx-build -j 8 -b coverage -d {envtmpdir}/doctrees . _build/coverage

[testenv:sloccount]
changedir = {toxinidir}
skip_install = true
deps =
commands = {toxinidir}/helpers/call_and_write_log.py \
                "sloccount --datadir .tox/sloccount/tmp ./abydos" 0

[testenv:badges]
basepython = python3.7
depends =
    pylint
    pydocstyle
    flake8
    doc8
    sloccount
skip_install = true
deps =
commands = python {toxinidir}/badge_update.py

[testenv:build]
basepython = python3.7
skip_install = true
deps =
    wheel
    setuptools
    twine
commands =
    python setup.py sdist bdist_wheel
    twine check dist/*

[testenv:release]
basepython = python3.7
skip_install = true
deps =
    {[testenv:build]deps}
commands =
    {[testenv:build]commands}
    twine upload --skip-existing --repository pypi dist/*

[testenv:release-test]
basepython = python3.7
skip_install = true
deps =
    {[testenv:build]deps}
commands =
    {[testenv:build]commands}
    twine upload --skip-existing --repository testpypi dist/*

[testenv:clean]
changedir = {toxinidir}
skip_install = true
deps =
whitelist_externals =
    rm
    find
commands =
    rm -rf ./cover
    rm -rf ./flake8
    rm -rf ./abydos.egg-info
    rm -rf ./dist
    rm -rf ./build
    rm -rf ./.tox
    rm -rf ./.mypy_cache
    rm -rf ./.coverage

    rm -rf ./docs/_build/*
    rm -rf ./docs/abydos.bib.bak

    find . -type f -name '*~' -delete
    find . -type f -name '.*~' -delete
    find . -type f -name '*.pyc' -delete
    find . -type f -name '*.log' -delete
    find . -type f -name '*.sav' -delete
    find . -type f -name '*.bak' -delete
    find . -type d -name '__pycache__' -delete
