Switch from tox to nox

Recent tox releases have put us on a config treadmill. Avoid these
issues entirely by using nox. Nox is a tox alternative that uses
standard tools like pip and should be simpler to use for us.

Change-Id: I24277512cf542bac7a8852d50009c6f08db7fa37
This commit is contained in:
Clark Boylan 2023-01-26 11:37:07 -08:00 committed by Jeremy Stanley
parent 9ae9f7936e
commit 0b7c438455
7 changed files with 67 additions and 42 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
.eggs/*
.tox
.nox
.stestr
build/*
*.pyc

View File

@ -13,18 +13,18 @@
check:
jobs:
- gerritlib-jeepyb-integration
- tox-py38:
- nox-py38:
nodeset: ubuntu-focal
- tox-py39:
- nox-py39:
nodeset: ubuntu-focal
- tox-py310:
- nox-py310:
nodeset: ubuntu-jammy
gate:
jobs:
- gerritlib-jeepyb-integration
- tox-py38:
- nox-py38:
nodeset: ubuntu-focal
- tox-py39:
- nox-py39:
nodeset: ubuntu-focal
- tox-py310:
- nox-py310:
nodeset: ubuntu-jammy

View File

@ -42,7 +42,7 @@ Writing a patch
---------------
We ask that all code submissions be pep8_ and pyflakes_ clean. The
easiest way to do that is to run tox_ before submitting code for
easiest way to do that is to run nox_ before submitting code for
review in Gerrit. It will run ``pep8`` and ``pyflakes`` in the same
manner as the automated test suite that will run on proposed
patchsets.
@ -57,6 +57,6 @@ Then install the required python packages using pip_::
.. _Gerrit: https://www.gerritcodereview.com/
.. _pyflakes: https://pypi.python.org/pypi/pyflakes
.. _tox: https://testrun.org/tox
.. _nox: https://nox.thea.codes/en/stable/
.. _pip: https://pypi.python.org/pypi/pip
.. _pep8: https://pypi.python.org/pypi/pep8

View File

@ -33,7 +33,7 @@ Documentation
Documentation is included in the ``doc`` folder. To generate docs
locally execute the command::
tox -e docs
nox -s docs
The generated documentation is then available under
``doc/build/html/index.html``.
@ -44,7 +44,7 @@ Unit Tests
Unit tests are in the ``tests`` folder.
To run the unit tests, execute the command::
tox -e py27
nox -s tests
* Note: View ``tox.ini`` to run tests on other versions of Python.
* Note: Pass ``--force-python 3.x`` to run under other versions of python.

46
noxfile.py Normal file
View File

@ -0,0 +1,46 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import nox
nox.options.error_on_external_run = True
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["tests-3", "linters"]
@nox.session(python="3")
def linters(session):
session.install("hacking")
session.install("-e", ".")
session.run("flake8")
@nox.session(python="3")
def docs(session):
session.install("-r", "test-requirements.txt")
session.install("-e", ".")
session.run("python3", "setup.py", "build_sphinx")
@nox.session(python="3")
def venv(session):
session.install("-r", "test-requirements.txt")
session.install("-e", ".")
session.run(*session.posargs)
@nox.session(python="3")
def tests(session):
session.install("-r", "test-requirements.txt")
session.install("-e", ".")
session.run("stestr", "run", "--slowest", *session.posargs)

View File

@ -32,3 +32,12 @@ warnerrors = True
source-dir = doc/source
build-dir = doc/build
all_files = 1
[flake8]
show-source = True
# These are ignored intentionally in infra projects;
# please don't submit patches that solely correct them or enable them.
ignore =
E124,E125,E129,E252,E402,E741,H,W503,W504
N802 # N802 function name {} should be lowercase
exclude = .venv,.tox,.nox,dist,doc,build,*.egg

31
tox.ini
View File

@ -1,31 +0,0 @@
[tox]
minversion = 1.6
skip_missing_interpreters = false
# https://docs.python.org/devguide/#status-of-python-branches
envlist = pep8, py{310,39,38,py}
[testenv]
setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
commands =
stestr run --slowest {posargs}
[testenv:pep8]
deps =
hacking
commands = flake8
[testenv:docs]
commands = python setup.py build_sphinx
[testenv:venv]
commands = {posargs}
[flake8]
show-source = True
# These are ignored intentionally in infra projects;
# please don't submit patches that solely correct them or enable them.
ignore =
E124,E125,E129,E252,E402,E741,H,W503,W504
N802 # N802 function name {} should be lowercase
exclude = .venv,.tox,dist,doc,build,*.egg