diff --git a/.gitignore b/.gitignore index 66797e3..56a1f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .eggs/* .tox +.nox .stestr build/* *.pyc diff --git a/.zuul.yaml b/.zuul.yaml index e76591d..925fd86 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/README.rst b/README.rst index 7bebb71..aec6efd 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 7e92ab4..c92a022 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -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. diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..e9c190b --- /dev/null +++ b/noxfile.py @@ -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) diff --git a/setup.cfg b/setup.cfg index b44d1f2..e07b79c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 9ab2e34..0000000 --- a/tox.ini +++ /dev/null @@ -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