Update tox and add coverage job to zuul

This commit updates the base tox configuration file as well as for nfv
and nova-api-proxy. It also updates the pylint.rc file to .pylintrc and
add the code coverage job to zuul, generating a non-voting -1
verification to the workflow in case the coverage is under 24%, which is
the current value for this change.

Note: black was added as a non-voting job due to the conflicting rules
with pylint and flake8.

Test plan:
1. PASS: Execute tox successfully.

Story: 2011777
Task: 54254

Change-Id: I40a056a128a9c31763701499ef60f6577923733e
Signed-off-by: Raphael <Raphael.Lima@windriver.com>
This commit is contained in:
Raphael committed 2026-05-05 08:49:34 -03:00
1 parent 5889b6c87a
commit 50c17f3eb0
7 files changed
+251 -164

No files matched your search

+56 -25
View File
@@ -4,22 +4,29 @@
- publish-stx-docs
- stx-api-ref-jobs
- stx-release-notes-jobs
- stx-bandit-jobs
check:
jobs:
- nfv-tox-linters
- nfv-tox-pep8
- nfv-tox-py39
- nfv-tox-pylint
- nfv-tox-black
- nfv-tox-py39
- nfv-tox-cover
- nova-api-proxy-tox-pep8
- nova-api-proxy-tox-pylint
- nova-api-proxy-tox-black
gate:
jobs:
- nfv-tox-linters
- nfv-tox-pep8
- nfv-tox-py39
- nfv-tox-pylint
- nfv-tox-black
- nfv-tox-py39
- nfv-tox-cover
- nova-api-proxy-tox-pep8
- nova-api-proxy-tox-pylint
- nova-api-proxy-tox-black
post:
jobs:
- stx-nfv-upload-git-mirror
@@ -33,9 +40,8 @@
tox_envlist: linters
- job:
name: nfv-tox-py39
name: nfv-tox-base
parent: tox
description: Run py39 for nfv
nodeset: debian-bullseye
required-projects:
- starlingx/config
@@ -43,40 +49,54 @@
- starlingx/update
- starlingx/utilities
vars:
tox_envlist: py39
tox_extra_args: -c nfv/tox.ini
- job:
name: nfv-tox-pep8
parent: tox
parent: nfv-tox-base
description: Run pep8 for nfv
nodeset: debian-bullseye
vars:
tox_envlist: pep8
tox_extra_args: -c nfv/tox.ini
- job:
name: nfv-tox-bandit
parent: tox
description: Run bandit for nfv
nodeset: debian-bullseye
vars:
tox_envlist: bandit
tox_extra_args: -c nfv/tox.ini
- job:
name: nfv-tox-pylint
parent: tox
parent: nfv-tox-base
description: Run pylint for nfv
nodeset: debian-bullseye
required-projects:
- starlingx/config
- starlingx/fault
- starlingx/update
- starlingx/utilities
vars:
tox_envlist: pylint
tox_extra_args: -c nfv/tox.ini
- job:
name: nfv-tox-black
parent: nfv-tox-base
description: Run black for nfv
voting: false
vars:
python_version: 3.9
tox_envlist: black
- job:
name: nfv-tox-py39
parent: nfv-tox-base
description: Run py39 for nfv
vars:
tox_envlist: py39
- job:
name: nfv-tox-cover
parent: nfv-tox-base
description: Run coverage test for nfv
post-run: tools/gate/playbooks/fetch-coverage.yaml
voting: false
vars:
python_version: 3.9
tox_envlist: cover
- job:
name: nfv-tox-bandit
parent: nfv-tox-base
description: Run bandit for nfv
vars:
tox_envlist: bandit
- job:
name: nova-api-proxy-tox-pep8
@@ -96,6 +116,17 @@
tox_envlist: pylint
tox_extra_args: -c nova-api-proxy/tox.ini
- job:
name: nova-api-proxy-tox-black
parent: tox
description: Run black for nova-api-proxy
nodeset: debian-bullseye
vars:
python_version: 3.9
tox_envlist: black
tox_extra_args: -c nova-api-proxy/tox.ini
voting: false
- job:
name: stx-nfv-upload-git-mirror
parent: upload-git-mirror
+37 -9
View File
@@ -1,9 +1,6 @@
[MASTER]
# Specify a configuration file.
rcfile=pylint.rc
# Python code to execute, usually for sys.path manipulation such as pygtk.require().
#init-hook=
rcfile=.pylintrc
# Add files or directories to the blacklist. They should be base names, not paths.
ignore=unit_test.py
@@ -17,10 +14,6 @@ load-plugins=
[MESSAGES CONTROL]
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
disable=
C0103, # invalid-name
C0114, # missing-module-docstring
@@ -98,6 +91,38 @@ disable=
W4905, # deprecated-decorator
E1121 # too-many-function-args
# TODO(rlima): enable these rules once the code formatting is updated
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once).
; disable=fixme,
; unnecessary-pass,
; arguments-differ,
; abstract-method,
; super-init-not-called,
; useless-super-delegation,
; global-statement,
; unused-variable,
; unused-argument,
; redefined-outer-name,
; redefined-builtin,
; broad-except,
; try-except-raise,
; raise-missing-from,
; anomalous-backslash-in-string,
; redundant-u-string-prefix,
; unspecified-encoding,
; missing-class-docstring,
; missing-function-docstring,
; missing-module-docstring,
; consider-using-f-string,
; invalid-name,
; import-outside-toplevel,
; too-many-lines,
; consider-iterating-dictionary,
; broad-exception-raised
[REPORTS]
# Set the output format. Available formats are text, parseable, colorized, msvs
# (visual studio) and html
@@ -127,7 +152,7 @@ ignore-docstrings=yes
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=85
max-line-length=88
# Maximum number of lines in a module
max-module-lines=1000
@@ -247,6 +272,9 @@ max-locals=15
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of branch for function / method body
max-branches=12
# Maximum number of statements in function / method body
max-statements=50
+90 -73
View File
@@ -1,5 +1,5 @@
#
# Copyright (c) 2018-2025 Wind River Systems, Inc.
# Copyright (c) 2018-2026 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -9,19 +9,10 @@
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
toxworkdir = /tmp/{env:USER}_nfvtox
envlist = pep8,py39,pylint
envlist = pep8,pylint,black,py39,cover
minversion = 4.4.0
skipsdist = True
stxdir = {toxinidir}/../..
[testenv]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
install_command = pip install \
-c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
allowlist_externals = cp
toxworkdir = /tmp/{env:USER}_nfvtox
[nfv]
nfv_base_dir = .
@@ -41,26 +32,32 @@ nfv_plugins_src_dir = {[nfv]nfv_plugins_dir}/nfv_plugins
nfv_vim_src_dir = {[nfv]nfv_vim_dir}/nfv_vim
nfv_test_src_dir = {[nfv]nfv_test_dir}
deps = -e{[nfv]nfv_client_dir}
-e{[nfv]nfv_common_dir}
-e{[nfv]nfv_plugins_dir}
-e{[nfv]nfv_vim_dir}
-e{[nfv]stx_fault_dir}/fm-api/source
-e{[nfv]stx_tsconfig_dir}
-e{[nfv]stx_software_dir}
-e{[nfv]stx_utilities_dir}
iso8601
keyring
kombu
kubernetes
oslo.log
passlib
pecan
pyparsing
PyYAML
sqlalchemy
stevedore
wsme
[testenv]
basepython = python3.9
sitepackages = False
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt}
-r{toxinidir}/test-requirements.txt
-e{[nfv]nfv_client_dir}
-e{[nfv]nfv_common_dir}
-e{[nfv]nfv_plugins_dir}
-e{[nfv]nfv_vim_dir}
-e{[nfv]stx_fault_dir}/fm-api/source
-e{[nfv]stx_tsconfig_dir}
-e{[nfv]stx_software_dir}
-e{[nfv]stx_utilities_dir}
iso8601
keyring
kombu
kubernetes
oslo.log
passlib
pecan
pyparsing
PyYAML
sqlalchemy
stevedore
wsme
[nosetests]
verbosity=2
@@ -93,17 +90,24 @@ enable-extensions = H106,H203
# rather than suppress E501 line too long, set max line length and reduce later
max-line-length = 185
# TODO(rlima): enable these rules once the code formatting is updated
# show-source = True
# max-line-length = 88
# Suppressed flake8 codes
# E203 whitespace before ':'; conflict with Black
# H301 one import per line; conflict with Black
# W503 line break before binary operator; conflict with Black
# W504 line break after binary operator
# ignore = E203,H301,W503,W504
# builtins = _
[testenv:pep8]
usedevelop = False
skip_install = True
deps = -r{toxinidir}/test-requirements.txt
commands =
flake8 {[nfv]nfv_base_dir}
[testenv:pylint]
deps = {[nfv]deps}
-r{toxinidir}/test-requirements.txt
deps = {[testenv]deps}
{[nfv]nfv_test_dir}/nfv_unit_tests
{[nfv]nfv_test_dir}/nfv_scenario_tests
jinja2
@@ -112,7 +116,51 @@ commands = pylint {[nfv]nfv_client_src_dir} \
{[nfv]nfv_plugins_src_dir} \
{[nfv]nfv_vim_src_dir} \
{[nfv]nfv_test_src_dir}/nfv_unit_tests \
--rcfile=./pylint.rc
--rcfile=./.pylintrc
[testenv:black]
# This environment checks and displays the recommended changes by Black for formatting
# Python files.
# To apply the format in a specific file, use the following command: black {posargs} .
deps =
black>=23.11.0 # MIT
commands =
black --check --diff .
[testenv:py39]
deps = {[testenv]deps}
coverage
fixtures
stestr
testtools
commands =
cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
stestr slowest
allowlist_externals =
cp
stestr
[testenv:cover]
deps =
{[testenv]deps}
coverage
fixtures
stestr
testtools
setenv =
PYTHON=coverage run --parallel-mode
commands =
cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
coverage erase
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report --fail-under=24
allowlist_externals =
cp
stestr
[bandit]
# These are the bandit codes that are failing for nfv
@@ -123,37 +171,6 @@ commands = pylint {[nfv]nfv_client_src_dir} \
skips = B104,B108,B110,B310
exclude = ./nfv-docs,./nfv-tests,./nfv-debug-tools,unit_test
[testenv:bandit]
deps = -r{toxinidir}/test-requirements.txt
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
[testenv:py39]
deps = {[nfv]deps}
-r{toxinidir}/test-requirements.txt
coverage
fixtures
stestr
testtools
setenv = PYTHONDONTWRITEBYTECODE=True
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
stestr slowest
[testenv:cover]
deps = {[nfv]deps}
coverage
fixtures
stestr
testtools
setenv =
PYTHON=coverage run --parallel-mode
PYTHONDONTWRITEBYTECODE=True
commands = cp -v {[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/test_data/nfv_vim_db_stx_25.09 {envdir}/
coverage erase
stestr --test-path={[nfv]nfv_base_dir}/nfv-tests/nfv_unit_tests/tests run '{posargs}'
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
deps = bandit
commands = bandit --ini tox.ini -f txt -r {[nfv]nfv_base_dir}
@@ -1,6 +1,6 @@
[MASTER]
# Specify a configuration file.
rcfile=pylint.rc
rcfile=.pylintrc
# Python code to execute, usually for sys.path manipulation such as pygtk.require().
#init-hook=
+22 -24
View File
@@ -1,26 +1,19 @@
[tox]
envlist = pep8,pylint
minversion = 2.9
envlist = pep8,pylint,black
minversion = 4.4.0
skipsdist = True
toxworkdir = /tmp/{env:USER}_novaapiproxytox
[novaapiproxy]
nova_api_proxy_base_dir = .
nova_api_proxy_dir = ./nova-api-proxy
[testenv]
basepython = python3
basepython = python3.9
sitepackages = False
install_command = pip install \
-c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
PYTHONDONTWRITEBYTECODE=True
commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete
allowlist_externals = find
deps=-r{toxinidir}/test-requirements.txt
[testenv:venv]
commands = {posargs}
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt}
-r{toxinidir}/test-requirements.txt
[flake8]
# - hacking codes -
@@ -37,14 +30,11 @@ enable-extensions = H106,H203
max-line-length=84
[testenv:pep8]
usedevelop = False
skip_install = True
commands =
flake8
flake8 {[novaapiproxy]nova_api_proxy_base_dir}
[testenv:pylint]
deps=
-r{toxinidir}/test-requirements.txt
deps = {[testenv]deps}
eventlet
oslo.config
oslo.log
@@ -52,5 +42,13 @@ deps=
PasteDeploy
routes
webob
commands = pylint nova-api-proxy/nova_api_proxy --rcfile=pylint.rc
commands = pylint {[novaapiproxy]nova_api_proxy_dir} --rcfile=.pylintrc
[testenv:black]
# This environment checks and displays the recommended changes by Black for formatting
# Python files.
# To apply the format in a specific file, use the following command: black {posargs} .
deps =
black>=23.11.0 # MIT
commands =
black --check --diff .
+16
View File
@@ -0,0 +1,16 @@
---
- hosts: "{{ target_hosts | default('all') }}"
gather_facts: false
tasks:
- name: Collect coverage artifacts
synchronize:
src: "{{ zuul.project.src_dir }}/nfv/{{ item }}"
dest: "{{ zuul.executor.log_root }}/{{ item }}"
mode: pull
copy_links: true
verify_host: true
loop:
- cover/
- coverage.xml
- .coverage
ignore_errors: true
+29 -32
View File
@@ -4,27 +4,19 @@ minversion = 2.9
skipsdist = True
[testenv]
allowlist_externals = find
basepython = python3
commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete
deps = -r{toxinidir}/test-requirements.txt
install_command = pip install -U \
-c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
install_command = pip install \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \
{opts} {packages}
setenv = VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
PYTHONDONTWRITEBYTECODE=True
[testenv:venv]
commands = {posargs}
[testenv:bandit]
description = Dummy environment to allow bandit to be run in subdir tox
[testenv:flake8]
description = Dummy environment to allow flake8 to be run in subdir tox
setenv =
VIRTUAL_ENV={envdir}
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
PYTHONDONTWRITEBYTECODE=True
commands = find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -not -path '*/__pycache__/*' -name '*.py[c|o]' -delete
allowlist_externals =
find
[testenv:pep8]
description = Dummy environment to allow pep8 to be run in subdir tox
@@ -32,19 +24,14 @@ description = Dummy environment to allow pep8 to be run in subdir tox
[testenv:pylint]
description = Dummy environment to allow pylint to be run in subdir tox
[testenv:yamllint]
allowlist_externals = bash
commands =
bash -c "find {toxinidir} \
-name .tox -prune \
-o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint -f parsable \
-c {toxinidir}/.yamllint"
[testenv:black]
description = Dummy environment to allow black to be run in subdir tox
[testenv:linters]
allowlist_externals = bash
commands =
{[testenv:yamllint]commands}
[testenv:cover]
description = Dummy environment to allow cover to be run in subdir tox
[testenv:bandit]
description = Dummy environment to allow bandit to be run in subdir tox
[testenv:docs]
deps = -r{toxinidir}/doc/requirements.txt
@@ -66,7 +53,7 @@ allowlist_externals =
# Re-use the releasenotes venv
envdir = {toxworkdir}/releasenotes
deps = -r{toxinidir}/doc/requirements.txt
commands = reno new {posargs}
commands = reno --rel-notes-dir {toxinidir}/releasenotes new {posargs}
[testenv:api-ref]
deps =
@@ -75,3 +62,13 @@ commands =
rm -rf api-ref/build
sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html
allowlist_externals = rm
[testenv:linters]
allowlist_externals = bash
deps = yamllint
commands =
bash -c "find {toxinidir} \
-name .tox -prune \
-o -type f -name '*.yaml' \
-print0 | xargs -0 yamllint -f parsable \
-c {toxinidir}/.yamllint"