[tox]
minversion = 3.18.0
envlist = py3,pep8
skipsdist = True
# this allows tox to infer the base python from the environment name
# and override any basepython configured in this file
ignore_basepython_conflict=true

[testenv]
basepython = python3
usedevelop = True
install_command = pip install {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
         ZAQAR_TESTS_CONFIGS_DIR={toxinidir}/zaqar/tests/etc/
         ZAQAR_TEST_MONGODB=1
         ZAQAR_TEST_SLOW=1
         OS_STDOUT_CAPTURE=1
         OS_STDERR_CAPTURE=1
         OS_TEST_TIMEOUT=60
deps =
  -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
commands =
    stestr run --serial --slowest {posargs}

[testenv:integration]
setenv = {[testenv]setenv}
         ZAQAR_TEST_INTEGRATION=1
         OS_TEST_PATH=./zaqar/tests/functional
commands = stestr run --serial --slowest {posargs}

[testenv:pep8]
commands =
  doc8 doc/source
  flake8

[testenv:genconfig]
commands =
  oslo-config-generator --config-file etc/oslo-config-generator/zaqar.conf

[testenv:genpolicy]
commands =
  oslopolicy-sample-generator --config-file etc/zaqar-policy-generator.conf

[testenv:cover]
setenv =
    {[testenv]setenv}
    PYTHON=coverage run --source zaqar --parallel-mode
commands =
    {[testenv]commands}
    coverage combine
    coverage html -d cover
    coverage xml -o cover/coverage.xml

[testenv:venv]
commands = {posargs}

[testenv:docs]
deps =
    -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
    -r{toxinidir}/requirements.txt
    -r{toxinidir}/doc/requirements.txt
commands =
    sphinx-build -W -b html doc/source doc/build/html

[testenv:api-ref]
# This environment is called from CI scripts to test and publish
# the API Ref to docs.openstack.org.
#
allowlist_externals = bash
                      rm
deps =
    -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
    -r{toxinidir}/doc/requirements.txt
commands =
    rm -rf api-ref/build
    sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html

[testenv:debug]
commands = oslo_debug_helper {posargs}

[testenv:releasenotes]
deps =
    -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
    -r{toxinidir}/doc/requirements.txt
commands =
    doc8 releasenotes/source releasenotes/notes
    sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

[flake8]
exclude = .venv*,.git,.tox,dist,doc,*lib/python*,*.egg,.update-venv
# NOTE(flaper87): Our currently max-complexity is 20. Not sure what the ideal complexity
# for Zaqar should be but lets keep it to the minimum possible.
max-complexity = 20
# [H904] Delay string interpolations at logging calls.
enable-extensions=H904
# Ignored extensions, might be enabled again after review:
# E123 closing bracket does not match indentation of opening bracket's line
# E226 missing whitespace around arithmetic operator
# E241 multiple spaces after ','
# E402 module level import not at top of file
# E731 do not assign a lambda expression, use a def
# W503 line break before binary operator
# W504 line break after binary operator
ignore = E123,E226,E241,E402,E731,W503,W504

[doc8]
# File extensions to check
extensions = .rst, .yaml
# Maximal line length should be 80 but we have some overlong lines.
# Let's not get far more in.
max-line-length = 80

[flake8:local-plugins]
extension =
  N537 = checks:no_translate_logs
paths = ./zaqar/hacking