[tox]
envlist =
    {py36,py37,py38,py39}-django{210, 220, 300, 310}-sqlite
    py38-django{300, 310}-{mysql,mariadb,postgres}
    flake8
    docs
    ; This is not that jslint :)
    jslint

[testenv]
passenv = *
deps =
    py36: celery == 4.2.0
    django210: Django>=2.1,<2.2
    django220: Django>=2.2,<2.3
    django300: Django>=3.0,<3.1
    django310: Django>=3.1,<3.2
usedevelop = True
extras =
    async
    krbauth
    tests
commands = py.test -s src/tests/ {posargs}

[docker:mysql:8.0.22]
ports = 33061:3306/tcp

[docker:mariadb:10.4.14]
ports = 33061:3306/tcp

[testenv:py38-django{300,310}-{mysql,mariadb}]
docker =
    mysql: mysql:8.0.22
    mariadb: mariadb:10.4.14
dockerenv =
    MYSQL_ROOT_PASSWORD=pass
    MYSQL_DATABASE=nitrate
allowlist_externals =
    sleep
extras =
    {[testenv]extras}
    mysql
setenv =
    NITRATE_DB_ENGINE = mysql
    NITRATE_DB_NAME = nitrate
    NITRATE_DB_PORT = 33061
    NITRATE_DB_USER = root
    NITRATE_DB_PASSWORD = pass
commands_pre =
    sleep 2

[docker:postgres:12.4-alpine]
ports = 54321:5432/tcp

[testenv:py38-django{300,310}-postgres]
docker =
    postgres:12.4-alpine
dockerenv =
    POSTGRES_USER=postgres
    POSTGRES_PASSWORD=nitrate
    POSTGRES_DB=testdb
allowlist_externals =
    sleep
extras =
    {[testenv]extras}
    pgsql
setenv =
    NITRATE_DB_ENGINE = pgsql
    NITRATE_DB_PORT = 54321
    NITRATE_DB_USER = postgres
    NITRATE_DB_PASSWORD = nitrate
    NITRATE_DB_NAME = nitrate
commands_pre =
; Sleeping 2 is enough to for the container is started completely
    sleep 3

[testenv:flake8]
basepython = python3
skip_install = True
deps = flake8
commands = flake8 src/

[testenv:docs]
basepython = python3
whitelist_externals = make
usedevelop = True
extras =
    docs
    async
changedir = {toxinidir}/docs
commands = make html

[testenv:jslint]
basepython = python3
skip_install = true
whitelist_externals = eslint
commands =
    eslint \
        src/static/js/tcms_actions.js \
        src/static/js/testplan_actions.js \
        src/static/js/testcase_actions.js \
        src/static/js/testrun_actions.js \
        src/static/js/management_actions.js \
        src/static/js/advance_search.js \
        src/static/js/footer_at_the_end.js \
        src/static/js/index.js \
        src/static/js/profiles.js \
        src/static/js/report.js \
        src/static/js/nitrate.attachments.js \
        src/tests/js/test-tcms-actions.js \
        src/tests/js/test-testplan-actions.js

[flake8]
exclude =
    .tox,
    .git,
    .env,
    dist,
    build,
    src/tcms/settings/,
    *sqls.py,
    urls.py,
    wsgi.py,
    *settings.py,
    *raw_sql.py,
    *xml2dict*,
    ./docs/source/conf.py
ignore = E501,W504
max_line_length = 100
