Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
tox.ini 4.32 KiB
[tox]
minversion = 3.20
envlist = py3{7,8,9,10},pep8
skipsdist = True

[testenv]
usedevelop = True
; Module access is a bit of an ugly hack. This is due to testenv inheritance
; with sitepackages = True`, meaning that global packages can be accessed by the
; tox environment. Our tango images already have several dependencies system
; wide installed, however, the system wide installation will never look inside
; tox its virtualenv for packages. So accessing stestr and others fail.. We
; can't remove `sitepackages = True` either as we need access to tango and
; installing this package is non-trivial. The solution is to prevent calling
; binaries directly and utilizing python and tox variables to resolve the
; requested module.
; sitepackages = True
install_command = {envbindir}/pip3 install {opts} {packages}
passenv = HOME
setenv =
   VIRTUAL_ENV={envdir}
   PYTHONWARNINGS=default::DeprecationWarning
envdir = {toxworkdir}/testenv
deps =
    -r{toxinidir}/requirements.txt
    -r{toxinidir}/../docker-compose/lofar-device-base/lofar-requirements.txt
    -r{toxinidir}/test-requirements.txt
commands_pre =
    {envpython} --version
    pip install --no-cache pytango
commands =
    {envpython} -m stestr --version
    {envpython} -m stestr run {posargs}

[testenv:py37]
envdir = {toxworkdir}/testenvpy37

[testenv:py38]
envdir = {toxworkdir}/testenvpy38

[testenv:py39]
envdir = {toxworkdir}/testenvpy39

[testenv:py310]
envdir = {toxworkdir}/testenvpy310

[testenv:integration]
; Warning running integration tests will make changes to your docker system!
; These tests should only be run by the integration-test docker container.
allowlist_externals = echo
passenv = TANGO_HOST
setenv =
    VIRTUAL_ENV={envdir}
    TESTS_DIR=./tangostationcontrol/integration_test/{env:TEST_MODULE:default}
    PYTHON={envpython} -m coverage run --source tangostationcontrol --parallel-mode
commands =
    echo "Integration test directory configured for{env:TESTS_DIR} ({env:TEST_MODULE:default})"
    {envpython} -m stestr --version
    {envpython} -m coverage --version
    {envpython} -m stestr run --serial {posargs}
    {envpython} -m coverage combine
    {envpython} -m coverage html --omit='*test*' -d cover
    {envpython} -m coverage xml -o coverage.xml
    {envpython} -m coverage report --omit='*test*'

[testenv:cover]
; stestr does not natively support generating coverage reports use
; `PYTHON=python -m coverage run....` to overcome this.
setenv =
    VIRTUAL_ENV={envdir}
    PYTHON={envpython} -m coverage run --source tangostationcontrol --parallel-mode
commands =
    {envpython} -m stestr --version
    {envpython} -m coverage --version
    {envpython} -m coverage erase
    {envpython} -m stestr run {posargs}
    {envpython} -m coverage combine
    {envpython} -m coverage html --omit='*test*' -d cover
    {envpython} -m coverage xml -o coverage.xml
    {envpython} -m coverage report --omit='*test*'

; TODO(Corne): Integrate Hacking to customize pep8 rules
[testenv:pep8]
commands =
    {envpython} -m doc8 --version
    {envpython} -m flake8 --version
    {envpython} -m doc8 docs/source/ --ignore D001
    {envpython} -m flake8

[testenv:bandit];
; B104: hardcoded_bind_all_interfaces
;           - We disable this warning as Docker serves as our firewall.
;             It thus matters what interfaces Docker will bind our
;             containers to, not what our containers listen on.
commands =
    {envpython} -m bandit --version
    {envpython} -m bandit -r devices/ -n5 -ll -s B104

[testenv:xenon];
commands =
    {envpython} -m xenon --version
    {envpython} -m xenon tangostationcontrol -b B -m A -a A -i libhdbpp-python

[testenv:build]
usedevelop = False
commands = {envpython} -m build

[testenv:docs]
envdir = {toxworkdir}/docs
deps =
    -r{toxinidir}/../docker-compose/lofar-device-base/lofar-requirements.txt
    -r{toxinidir}/docs/docs-requirements.txt
commands =
    sphinx-build --version
    sphinx-build -W -b html docs/source docs/build/html

[flake8]
filename = *.py,.stestr.conf,.txt
ignore = B014, B019, W291, W293, W391, E111, E114, E121, E122, E123, E124, E126, E127, E128, E131, E201, E201, E202, E203, E221, E222, E225, E226, E231, E241, E251, E252, E261, E262, E265, E271, E301, E302, E303, E305, E306, E401, E402, E501, E502, E701, E712, E721, E731, F403, F523, F541, F841, H301, H306, H401, H403, H404, H405, W503
exclude=.tox,.egg-info,libhdbpp-python, SNMP_mib_loading