[tox]
envlist =
    py{37,38,39,310}-dj32-{sqlite3,postgres,mysql,mariadb},
    py{38,39,310}-dj{40,main}-{sqlite3,postgres,mysql,mariadb},
    docs,
    lint

[gh-actions]
python =
    3.7: py37
    3.8: py38, docs, lint
    3.9: py39
    3.10: py310

[gh-actions:env]
DJANGO =
    3.2: dj32
    4.0: dj40
    main: djmain

[flake8]
ignore = N802,F401,W503
max-complexity = 10
max-line-length = 88
exclude = __init__.py,simple_history/registry_tests/migration_test_app/migrations/*

[testenv]
deps =
    -rrequirements/test.txt
    dj32: Django>=3.2,<3.3
    dj40: Django>=4.0,<4.1
    djmain: https://github.com/django/django/tarball/main
    postgres: -rrequirements/postgres.txt
    mysql: -rrequirements/mysql.txt
    mariadb: -rrequirements/mysql.txt

commands =
    sqlite3: coverage run -a runtests.py {posargs}
    postgres: coverage run -a runtests.py --database=postgres {posargs}
    mysql: coverage run -a runtests.py --database=mysql {posargs}
    mariadb: coverage run -a runtests.py --database=mariadb {posargs}
    coverage report

[testenv:format]
deps = -rrequirements/lint.txt
commands =
    isort docs simple_history runtests.py setup.py
    black docs simple_history runtests.py setup.py
    flake8 simple_history

[testenv:lint]
deps = pre-commit
commands =
    pre-commit run --all-files

[testenv:docs]
changedir = docs
deps = -rrequirements/docs.txt
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
