[tox]
envlist =
    {py27,py37}-lint,
    py{27}-Plone{43,51},
    py{27,37}-Plone{52},
    build_instance,
#    docs,
#    coverage-report,

skip_missing_interpreters = True

[testenv]
skip_install = true

extras =
    develop
    test

commands =
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot code-analysis
    coverage run {envbindir}/test -v1 --auto-color {posargs}
    # coverage run {envbindir}/test -v --all -t robot {posargs}
    {envbindir}/code-analysis

setenv =
    COVERAGE_FILE=.coverage.{envname}
    version_file=test_plone51.cfg
    Plone43: version_file=test_plone43.cfg
    Plone50: version_file=test_plone50.cfg
    Plone51: version_file=test_plone51.cfg
    Plone52: version_file=test_plone52.cfg

deps =
    -rrequirements.txt
    Plone43: -cconstraints_plone43.txt
    Plone50: -cconstraints_plone50.txt
    Plone51: -cconstraints_plone51.txt
    Plone52: -cconstraints_plone52.txt
    coverage

[testenv:coverage-report]
skip_install = true
usedevelop = True
basepython = python2.7

deps =
    coverage
    -cconstraints_plone51.txt

setenv =
    COVERAGE_FILE=.coverage

commands =
    coverage erase
    coverage combine
    coverage html
    coverage xml
    coverage report


[lint]
skip_install = true

deps =
    isort
    flake8
    # helper to generate HTML reports:
    flake8-html
    # Useful flake8 plugins that are Python and Plone specific:
    flake8-coding
    flake8-debugger
    flake8-deprecated
    flake8-print
    #flake8-pytest
    flake8-todo
    flake8-isort
    mccabe
    # Potential flake8 plugins that should be used:  # TBD
    #flake8-blind-except
    #flake8-commas
    #flake8-docstrings
    #flake8-mypy
    #flake8-pep3101
    #flake8-plone-hasattr
    #flake8-string-format
    #flake8_strict
    #flake8-quotes
    #flake8-polyfill

commands =
    mkdir -p {toxinidir}/reports/flake8
    - flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src setup.py
    flake8 --doctests src tests setup.py
    isort --check-only --recursive {toxinidir}/src

whitelist_externals =
    mkdir

[testenv:isort-apply]
skip_install = true

deps =
    isort

commands =
    isort --apply --recursive {toxinidir}/src

[testenv:py27-lint]
basepython = python2.7
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:py35-lint]
basepython = python3.5
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:py36-lint]
basepython = python3.6
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:py37-lint]
basepython = python3.7
skip_install = true
deps = {[lint]deps}
commands = {[lint]commands}
whitelist_externals = {[lint]whitelist_externals}

[testenv:docs]
skip_install = true

deps =
    Sphinx

commands =
    sphinx-build -b html -d _build/docs/doctrees docs _build/docs/html

[testenv:update_translation]
skip_install = true

deps =
    i18ndude

commands =
    i18ndude find-untranslated
    i18ndude rebuild-pot
    i18ndude merge
    i18ndude sync
    i18ndude list

[testenv:release]
skip_install = true

deps =
    zest.releaser[recommended]

commands =
    fullrelease --no-input -v

[testenv:build_instance]
basepython = python2.7
skip_install = true

commands =
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} bootstrap
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir} annotate
    {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={toxinidir}
