CI: Use latest actions and reusable workflows
[releng/lftools.git] / tox.ini
diff --git a/tox.ini b/tox.ini
index b7ece3b..c935027 100644 (file)
--- a/tox.ini
+++ b/tox.ini
 [tox]
-minversion = 2.0
 envlist =
-    check-hooks,
-    coala,
     docs,
     docs-linkcheck,
     license,
-    py27,
-    py35,
-    py36,
-    py37
+    pre-commit,
+    py38
+    py39
+minversion = 3.8
 skip_missing_interpreters = true
+ignore_basepython_conflict = true
+
+[pytest]
+markers = datafiles
+addopts =
+    -p no:warnings
+    --cov=lftools
+    --cov-report=term-missing
 
 [testenv]
-deps = -r{toxinidir}/requirements-test.txt
+basepython = python3
+# This needs to mirror the test section of pyproject.toml
+deps =
+    pytest==5.3.5
+    pytest-click==0.3
+    pytest-cov
+    pytest-datafiles==2.0
+    pytest-mock==2.0.0
+    pytest-responses==0.4.0
+
 commands = pytest
+usedevelop = true
 
-[testenv:check-hooks]
-deps = pre-commit==1.11.2
-commands =
-    pre-commit install
-    pre-commit run --all-files
 
-[testenv:coala]
-basepython = python3
+[testenv:{build,clean}]
+description =
+    build: Build the package in isolation according to PEP517, see https://github.com/pypa/build
+    clean: Remove old distribution files and temporary build artifacts (./build and ./dist)
+# https://setuptools.pypa.io/en/stable/build_meta.html#how-to-use-it
+skip_install = True
+changedir = {toxinidir}
 deps =
-    coala
-    coala-bears
-    nodeenv==1.1.2
+    build: build[virtualenv]
+passenv =
+    SETUPTOOLS_*
 commands =
-    nodeenv -p
-    npm install --global remark-cli remark-lint write-good
-    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
-    coala --non-interactive
+    clean: python -c 'import shutil; [shutil.rmtree(p, True) for p in ("build", "dist", "docs/_build")]'
+    clean: python -c 'import pathlib, shutil; [shutil.rmtree(p, True) for p in pathlib.Path("src").glob("*.egg-info")]'
+    build: python -m build {posargs}
+# By default, both `sdist` and `wheel` are built. If your sdist is too big or you don't want
+# to make it available, consider running: `tox -e build -- --wheel`
+
 
 [testenv:docs]
-deps = -rrequirements-docs.txt
+description = Build the documentation with sphinx
+basepython = python3.8
+# This needs to mirror the docs section of pyproject.toml plus the testenv
+deps =
+    {[testenv]deps}
+    lfdocs-conf
+    reno
+    sphinxcontrib-programoutput
+
 extras = openstack
-commands =
-    sphinx-build -W -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
+commands = sphinx-build -W -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
 
 [testenv:docs-linkcheck]
-deps = -rrequirements-docs.txt
+description = Check the documentation links with sphinx
+basepython = python3.8
+deps =
+    {[testenv:docs]deps}
 extras = openstack
 commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck
 
 [testenv:latest-upstream]
-deps = -r{toxinidir}/requirements-test.txt
+description = Latest upstream test. Used for what exactly?
+basepython = python3
+deps =
+    {[testenv:docs]deps}
 commands =
-    pip install -U python-jenkins requests shade
+    pip install -U python-jenkins requests
     pytest
 
 [testenv:license]
-deps =
-    lftools
+description = Check all files for license header
+basepython = python3.8
+deps = lftools
 commands =
     lftools license check-dir lftools
     lftools license check-dir -r '.+' shell
 
+[testenv:pre-commit]
+description = Precommit checks for black, gitlint, etc.
+basepython = python3.8
+allowlist_externals =
+    /bin/sh
+deps =
+    pre-commit
+passenv = HOME
+commands =
+    pre-commit run --all-files --show-diff-on-failure
+    /bin/sh -c 'if ! git config --get user.name > /dev/null; then \
+        git config --global --add user.name "CI"; \
+        touch .git/REMOVE_USERNAME; fi'
+    /bin/sh -c 'if ! git config --get user.email > /dev/null; then \
+        git config --global --add user.email "ci@example.org"; \
+        touch .git/REMOVE_USEREMAIL; fi'
+    /bin/sh -c "if [ -f .git/COMMIT_EDITMSG ]; then \
+        cp .git/COMMIT_EDITMSG .git/COMMIT_MSGTOX; else \
+        git log HEAD -n1 --pretty=%B > .git/COMMIT_MSGTOX; fi"
+    pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_MSGTOX
+    /bin/sh -c "rm -f .git/COMMIT_MSGTOX"
+    /bin/sh -c "if [ -f .git/REMOVE_USERNAME ]; then \
+        git config --global --unset user.name; \
+        rm -f .git/REMOVE_USERNAME; fi"
+    /bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \
+        git config --global --unset user.email; \
+        rm -f .git/REMOVE_USEREMAIL; fi"
+
+
+[testenv:publish]
+description =
+    Publish the package you have been developing to a package index server.
+    By default, it uses testpypi. If you really want to publish your package
+    to be publicly accessible in PyPI, use the `-- --repository pypi` option.
+skip_install = True
+changedir = {toxinidir}
+passenv =
+    # See: https://twine.readthedocs.io/en/latest/
+    TWINE_USERNAME
+    TWINE_PASSWORD
+    TWINE_REPOSITORY
+    TWINE_REPOSITORY_URL
+deps = twine
+commands =
+    python -m twine check dist/*
+    python -m twine upload {posargs:--repository {env:TWINE_REPOSITORY:testpypi}} dist/*
+
+
 [testenv:reno]
+description = OpenStack Reno checks
+basepython = python3
 deps = reno
 commands = reno {posargs:--help}