diff --git a/.gitignore b/.gitignore index 768dd14..d4f44da 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ pip-log.txt # Unit test / coverage reports .coverage +.nox .tox nosetests.xml .testrepository diff --git a/.zuul.yaml b/.zuul.yaml index d9a1faf..9da4b17 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -49,7 +49,7 @@ vars: release_python: python3 templates: - - publish-opendev-tox-docs + - publish-opendev-nox-docs check: jobs: - bindep-centos-7 @@ -60,12 +60,15 @@ - bindep-ubuntu-bionic - bindep-ubuntu-focal - build-python-release - - tox-pep8 - - tox-py27 - - tox-py35: - nodeset: ubuntu-xenial - - tox-py39: - nodeset: ubuntu-focal + - nox-linters + - nox-py27 + - nox-py36: + nodeset: ubuntu-bionic + - nox-py310: + nodeset: ubuntu-jammy + - nox-py311: + nodeset: ubuntu-jammy + - nox-cover gate: jobs: - bindep-centos-7 @@ -76,12 +79,15 @@ - bindep-ubuntu-bionic - bindep-ubuntu-focal - build-python-release - - tox-pep8 - - tox-py27 - - tox-py35: - nodeset: ubuntu-xenial - - tox-py39: - nodeset: ubuntu-focal + - nox-linters + - nox-py27 + - nox-py36: + nodeset: ubuntu-bionic + - nox-py310: + nodeset: ubuntu-jammy + - nox-py311: + nodeset: ubuntu-jammy + - nox-cover promote: jobs: - opendev-promote-python diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..9177c4f --- /dev/null +++ b/noxfile.py @@ -0,0 +1,59 @@ +import nox + + +nox.options.error_on_external_run = True +nox.options.reuse_existing_virtualenvs = True +nox.options.sessions = ["tests-3", "tests-2.7", "linters"] + + +# Note setting python this way seems to give us a target name without +# python specific suffixes while still allowing us to force a specific +# version using --force-python. +@nox.session(python="3") +def linters(session): + session.install("hacking>=3.2.0,<3.3") + session.run("flake8") + + +@nox.session(python="3") +def docs(session): + session.install("-r", "requirements.txt") + session.install("-r", "doc/requirements.txt") + session.install(".") + session.run( + "sphinx-build", "-W", + "-d", "doc/build/doctrees", + "-b", "html", + "doc/source/", "doc/build/html" + ) + + +@nox.session(python="3") +def venv(session): + session.install("-r", "requirements.txt") + session.install("-r", "test-requirements.txt") + session.install("-e", ".") + session.run(*session.posargs) + + +# This will attempt to run python3 and 2.7 tests by default. +@nox.session(python=["3", "2.7"]) +def tests(session): + session.install("-r", "requirements.txt") + session.install("-r", "test-requirements.txt") + session.install("-e", ".") + session.run("stestr", "run", *session.posargs) + session.run("stestr", "slowest") + + +@nox.session(python="3") +def cover(session): + session.install("-r", "requirements.txt") + session.install("-r", "test-requirements.txt") + session.install("-e", ".") + session.env["PYTHON"] = "coverage run --source bindep --parallel-mode" + session.run("stestr", "run", *session.posargs) + session.run("stestr", "slowest") + session.run("coverage", "combine") + session.run("coverage", "html", "-d", "cover") + session.run("coverage", "xml", "-o", "cover/coverage.xml") diff --git a/requirements.txt b/requirements.txt index 2431d42..7a3dc49 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ distro<1.7.0 ; python_version < '3.6' distro>=1.7.0 ; python_version >= '3.6' pbr>=2.0.0 # Apache-2.0 Parsley -packaging ; python_version >= '3.6' +packaging<22.0 ; python_version >= '3.6' packaging<21.0 ; python_version < '3.6' diff --git a/setup.cfg b/setup.cfg index 40d2577..ef41290 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,3 +51,10 @@ console_scripts = [wheel] universal = 1 + +[flake8] +# E123, E125 skipped as they are invalid PEP-8. +show-source = True +ignore = E123,E125,E129,H,W503,W504 +builtins = _ +exclude=.venv,.git,.nox,.tox,dist,doc,*lib/python*,*egg,build diff --git a/tox.ini b/tox.ini index ef4d464..fab83ba 100644 --- a/tox.ini +++ b/tox.ini @@ -41,11 +41,3 @@ deps = -r{toxinidir}/doc/requirements.txt commands = sphinx-build -W -d doc/build/doctrees -b html doc/source/ doc/build/html - -[flake8] -# E123, E125 skipped as they are invalid PEP-8. - -show-source = True -ignore = E123,E125,E129,H,W503,W504 -builtins = _ -exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build