[tox]
requires =
    tox>=4
envlist = 
    docs
    security
    flake8
    py{38,39,310,311,312}-scrapy{26,27,28,29,210,211}-redis{42,43,44,45,46,50}
minversion = 3.0.0

[base]
deps = 
    -r requirements-tests.txt
    -r requirements.txt
    setuptools

[testenv]
basepython =
    py38: python3.8
    py39: python3.9
    py310: python3.10
    py311: python3.11
    py312: python3.12
deps = 
    {[base]deps}
    scrapy26: scrapy~=2.6.0
    scrapy27: scrapy~=2.7.0
    scrapy28: scrapy~=2.8.0
    scrapy29: scrapy~=2.9.0
    scrapy210: scrapy~=2.10.0
    scrapy211: scrapy~=2.11.0
    redis42: redis~=4.2.0
    redis43: redis~=4.3.0
    redis44: redis~=4.4.0
    redis45: redis~=4.5.0
    redis46: redis~=4.6.0
    redis50: redis~=5.0.0
passenv =
    REDIS_HOST
    REDIS_PORT
commands = 
    python -m pytest # --cov-report term --cov=scrapy_redis

[testenv:flake8]
basepython =
    python3.12
deps =
    {[base]deps}
commands =
    flake8 --ignore=W503,E265,E731 docs src tests

[testenv:security]
basepython =
    python3.12
deps =
    bandit~=1.7.3
commands =
    bandit -r -c .bandit.yml src/ tests/

[testenv:pytest]
basepython =
    python3.12
deps = 
    {[testenv]deps}
passenv =
    REDIS_HOST
    REDIS_PORT
commands =
    python -m pytest --cov-report term --cov=scrapy_redis

[testenv:build]
basepython =
    python3.12
deps = 
    {[base]deps}
    build
commands =
    python -m build

[testenv:docs]
basepython =
    python3.12
deps = 
    {[base]deps}
    -r docs/requirements.txt
allowlist_externals =
    make
commands =
    # Same command as readthedocs
    make -C docs html SPHINXOPTS="-T -W --keep-going -D language=en"
