Use nox
This illustrates the use of nox in a simpler project. It can build docs, run linters, and execute unittests simply and effectively. Note we pin the packaging package as newer versions have changed behavior on rolling release distros that don't have proper version. This is necessary to fix gating. The followup change fixes it properly. Change-Id: I795e4d73f60d90b0f027df43a80ebda773ee9194
This commit is contained in:
parent
69c7262259
commit
697af0b17a
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,6 +23,7 @@ pip-log.txt
|
|||||||
|
|
||||||
# Unit test / coverage reports
|
# Unit test / coverage reports
|
||||||
.coverage
|
.coverage
|
||||||
|
.nox
|
||||||
.tox
|
.tox
|
||||||
nosetests.xml
|
nosetests.xml
|
||||||
.testrepository
|
.testrepository
|
||||||
|
32
.zuul.yaml
32
.zuul.yaml
@ -49,7 +49,7 @@
|
|||||||
vars:
|
vars:
|
||||||
release_python: python3
|
release_python: python3
|
||||||
templates:
|
templates:
|
||||||
- publish-opendev-tox-docs
|
- publish-opendev-nox-docs
|
||||||
check:
|
check:
|
||||||
jobs:
|
jobs:
|
||||||
- bindep-centos-7
|
- bindep-centos-7
|
||||||
@ -60,12 +60,15 @@
|
|||||||
- bindep-ubuntu-bionic
|
- bindep-ubuntu-bionic
|
||||||
- bindep-ubuntu-focal
|
- bindep-ubuntu-focal
|
||||||
- build-python-release
|
- build-python-release
|
||||||
- tox-pep8
|
- nox-linters
|
||||||
- tox-py27
|
- nox-py27
|
||||||
- tox-py35:
|
- nox-py36:
|
||||||
nodeset: ubuntu-xenial
|
nodeset: ubuntu-bionic
|
||||||
- tox-py39:
|
- nox-py310:
|
||||||
nodeset: ubuntu-focal
|
nodeset: ubuntu-jammy
|
||||||
|
- nox-py311:
|
||||||
|
nodeset: ubuntu-jammy
|
||||||
|
- nox-cover
|
||||||
gate:
|
gate:
|
||||||
jobs:
|
jobs:
|
||||||
- bindep-centos-7
|
- bindep-centos-7
|
||||||
@ -76,12 +79,15 @@
|
|||||||
- bindep-ubuntu-bionic
|
- bindep-ubuntu-bionic
|
||||||
- bindep-ubuntu-focal
|
- bindep-ubuntu-focal
|
||||||
- build-python-release
|
- build-python-release
|
||||||
- tox-pep8
|
- nox-linters
|
||||||
- tox-py27
|
- nox-py27
|
||||||
- tox-py35:
|
- nox-py36:
|
||||||
nodeset: ubuntu-xenial
|
nodeset: ubuntu-bionic
|
||||||
- tox-py39:
|
- nox-py310:
|
||||||
nodeset: ubuntu-focal
|
nodeset: ubuntu-jammy
|
||||||
|
- nox-py311:
|
||||||
|
nodeset: ubuntu-jammy
|
||||||
|
- nox-cover
|
||||||
promote:
|
promote:
|
||||||
jobs:
|
jobs:
|
||||||
- opendev-promote-python
|
- opendev-promote-python
|
||||||
|
59
noxfile.py
Normal file
59
noxfile.py
Normal file
@ -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")
|
@ -2,5 +2,5 @@ distro<1.7.0 ; python_version < '3.6'
|
|||||||
distro>=1.7.0 ; python_version >= '3.6'
|
distro>=1.7.0 ; python_version >= '3.6'
|
||||||
pbr>=2.0.0 # Apache-2.0
|
pbr>=2.0.0 # Apache-2.0
|
||||||
Parsley
|
Parsley
|
||||||
packaging ; python_version >= '3.6'
|
packaging<22.0 ; python_version >= '3.6'
|
||||||
packaging<21.0 ; python_version < '3.6'
|
packaging<21.0 ; python_version < '3.6'
|
||||||
|
@ -51,3 +51,10 @@ console_scripts =
|
|||||||
|
|
||||||
[wheel]
|
[wheel]
|
||||||
universal = 1
|
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
|
||||||
|
8
tox.ini
8
tox.ini
@ -41,11 +41,3 @@ deps =
|
|||||||
-r{toxinidir}/doc/requirements.txt
|
-r{toxinidir}/doc/requirements.txt
|
||||||
commands =
|
commands =
|
||||||
sphinx-build -W -d doc/build/doctrees -b html doc/source/ doc/build/html
|
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user