[tox]
envlist = py36, py37, py38, py39

[gh-actions]
python =
    3.6: py36
    3.7: py37
    3.8: py38
    3.9: py39

[testenv-common]
deps =
    -rrequirements.txt
    elasticsearch
    pytesseract
    imgkit
    speakeasy-emulator
    codecov
    ElasticMock
    mock
    mongomock
    pre-commit
    safety
    pytest
    pytest-timeout
    pytest-cov
    tox

[testenv-py36]
deps =
    pygraphviz==1.6

[testenv-py37]
deps =
    pygraphviz

[testenv-py38]
deps =
    pygraphviz

[testenv-py39]
deps =
    pygraphviz

[stpyv8]
version =
	8.9.255.20

[testenv:py36]
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_TOKEN
whitelist_externals =
    sudo
    mkdir
    wget
    unzip
deps =
    {[testenv-common]deps}
    {[testenv-py36]deps}
commands =
    wget https://github.com/area1/stpyv8/releases/download/v{[stpyv8]version}/stpyv8-ubuntu-18.04-python-3.6.zip
    unzip stpyv8-ubuntu-18.04-python-3.6.zip
    pip install stpyv8-ubuntu-18.04-3.6/stpyv8-{[stpyv8]version}-cp36-cp36m-linux_x86_64.whl
    sudo mkdir -p /usr/share/stpyv8
    sudo mv stpyv8-ubuntu-18.04-3.6/icudtl.dat /usr/share/stpyv8
    thug --version
    pytest --timeout 60 --exitfirst --cov=thug
    codecov
    safety check
    pre-commit run --all-files

[testenv:py37]
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_TOKEN
whitelist_externals =
    sudo
    mkdir
    wget
    unzip
deps =
    {[testenv-common]deps}
    {[testenv-py37]deps}
commands =
    wget https://github.com/area1/stpyv8/releases/download/v{[stpyv8]version}/stpyv8-ubuntu-18.04-python-3.7.zip
    unzip stpyv8-ubuntu-18.04-python-3.7.zip
    pip install stpyv8-ubuntu-18.04-3.7/stpyv8-{[stpyv8]version}-cp37-cp37m-linux_x86_64.whl
    sudo mkdir -p /usr/share/stpyv8
    sudo mv stpyv8-ubuntu-18.04-3.7/icudtl.dat /usr/share/stpyv8
    thug --version
    pytest --timeout 60 --exitfirst --cov=thug
    codecov
    safety check
    pre-commit run --all-files

[testenv:py38]
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_TOKEN
whitelist_externals =
    sudo
    mkdir
    wget
    unzip
deps =
    {[testenv-common]deps}
    {[testenv-py38]deps}
commands =
    wget https://github.com/area1/stpyv8/releases/download/v{[stpyv8]version}/stpyv8-ubuntu-18.04-python-3.8.zip
    unzip stpyv8-ubuntu-18.04-python-3.8.zip
    pip install stpyv8-ubuntu-18.04-3.8/stpyv8-{[stpyv8]version}-cp38-cp38-linux_x86_64.whl
    sudo mkdir -p /usr/share/stpyv8
    sudo mv stpyv8-ubuntu-18.04-3.8/icudtl.dat /usr/share/stpyv8
    thug --version
    pytest --timeout 60 --exitfirst --cov=thug
    codecov
    safety check
    pre-commit run --all-files

[testenv:py39]
passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_TOKEN
whitelist_externals =
    sudo
    mkdir
    wget
    unzip
deps =
    {[testenv-common]deps}
    {[testenv-py39]deps}
commands =
    wget https://github.com/area1/stpyv8/releases/download/v{[stpyv8]version}/stpyv8-ubuntu-18.04-python-3.9.zip
    unzip stpyv8-ubuntu-18.04-python-3.9.zip
    pip install stpyv8-ubuntu-18.04-3.9/stpyv8-{[stpyv8]version}-cp39-cp39-linux_x86_64.whl
    sudo mkdir -p /usr/share/stpyv8
    sudo mv stpyv8-ubuntu-18.04-3.9/icudtl.dat /usr/share/stpyv8
    thug --version
    pytest --timeout 60 --exitfirst --cov=thug
    codecov
    safety check
    pre-commit run --all-files
