From 5b480fd92a9d12e171bf759f5b4e164e75f3031c Mon Sep 17 00:00:00 2001
From: Klaas <kliffen@astron.nl>
Date: Tue, 19 Jul 2022 14:10:33 +0200
Subject: [PATCH] Start on tox

---
 MANIFEST.in            |  1 -
 tests/requirements.txt |  4 +++
 tox.ini                | 75 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 tests/requirements.txt
 create mode 100644 tox.ini

diff --git a/MANIFEST.in b/MANIFEST.in
index d79ea02..b13ed9c 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -3,5 +3,4 @@ include README.md
 include VERSION
 
 recursive-include docs *
-
 recursive-exclude tests *
diff --git a/tests/requirements.txt b/tests/requirements.txt
new file mode 100644
index 0000000..4a545b2
--- /dev/null
+++ b/tests/requirements.txt
@@ -0,0 +1,4 @@
+black
+build
+flake8
+pylint
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..31c19d9
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,75 @@
+[tox]
+# Generative environment list to test all supported Python versions
+envlist = py3{7,8,9,10},black,pep8,pylint
+minversion = 3.18.0
+# Source distributions are explicitly build using tox -e build
+skipsdist = True
+
+[testenv]
+usedevelop = True
+setenv =
+    LANGUAGE=en_US
+    LC_ALL=en_US.UTF-8
+    PYTHONWARNINGS=default::DeprecationWarning
+deps =
+    -r{toxinidir}/requirements.txt
+    -r{toxinidir}/tests/requirements.txt
+commands =
+    {envpython} --version
+    stestr run {posargs}
+
+# Use generative name and command prefixes to reuse the same virtualenv
+# for all linting jobs.
+[testenv:{pep8,black,pylint}]
+usedevelop = False
+envdir = {toxworkdir}/linting
+commands =
+    pep8: {envpython} -m flake8 --version
+    pep8: {envpython} -m flake8
+    black: {envpython} -m black --version
+    black: {envpython} -m black --check --diff .
+    pylint: {envpython} -m pylint --version
+    pylint: {envpython} -m pylint lofar_station_client
+
+[testenv:debug]
+commands = {envpython} -m testtools.run {posargs}
+
+[testenv:coverage]
+; stestr does not natively support generating coverage reports use
+; `PYTHON=python -m coverage run....` to overcome this.
+setenv =
+    PYTHON={envpython} -m coverage run --source lofar_station_client --omit='*tests*' --parallel-mode
+commands =
+  {envpython} -m coverage erase
+  {envpython} -m stestr run {posargs}
+  {envpython} -m coverage combine
+  {envpython} -m coverage html -d cover --omit='*tests*'
+  {envpython} -m coverage xml -o coverage.xml
+  {envpython} -m coverage report --omit='*tests*'
+
+[testenv:build]
+usedevelop = False
+commands = {envpython} -m build
+
+[testenv:docs]
+deps =
+  -r{toxinidir}/requirements.txt
+  -r{toxinidir}/docs/requirements.txt
+commands = sphinx-build -b html -W docs/source docs/build/html
+
+[testenv:integration]
+# Do no install the lofar station client package, force packaged version install
+skip_install = true
+# Intentionally break import paths if not installed from package
+changedir={toxinidir}/integration
+# Allow bash for wheel file substitution
+allowlist_external =
+    bash
+commands =
+    # We need the bash substitutions here
+    bash -ec 'pip install --force-reinstall {toxinidir}/dist/*.whl'
+    {envpython} -m stestr run --serial {posargs}
+
+[flake8]
+filename = *.py
+exclude=.tox,.egg-info
-- 
GitLab