From 97c94787a375b3b4306ae132c0fa4116c552c361 Mon Sep 17 00:00:00 2001 From: Gustavo Herzmann Date: Tue, 13 Jan 2026 17:04:44 -0300 Subject: [PATCH] Create Zuul job for unit test coverage Creates a non-voting Zuul job that runs the tox coverage test. Current coverage is 75%, so it's configured to fail if less than 75%. This value should be updated whenever the coverage increases. The full coverage report is copied to the zuul logs folder, providing an easy way to view and share the results. Test plan: 1. PASS: Verify that Zuul runs the new job and that the reports are copied to the Zuul log output folder. Story: 2011149 Task: 53657 Co-Authored-By: Raphael Change-Id: I93b254a587a052e0f890799ed9d7f969915a91a2 Signed-off-by: Gustavo Herzmann --- .zuul.yaml | 14 ++++++++++++++ distributedcloud-client/tox.ini | 4 ++-- tools/gate/playbooks/fetch-coverage.yaml | 15 +++++++++++++++ tox.ini | 3 +++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tools/gate/playbooks/fetch-coverage.yaml diff --git a/.zuul.yaml b/.zuul.yaml index d2d0d3e6..50f68642 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -11,6 +11,7 @@ - stx-distcloud-client-tox-py39 - stx-distcloud-client-tox-pylint - stx-distcloud-client-tox-black + - stx-distcloud-client-tox-cover gate: jobs: - openstack-tox-linters @@ -18,6 +19,7 @@ - stx-distcloud-client-tox-py39 - stx-distcloud-client-tox-pylint - stx-distcloud-client-tox-black + - stx-distcloud-client-tox-cover post: jobs: - stx-distcloud-client-upload-git-mirror @@ -62,6 +64,18 @@ tox_envlist: black_check tox_extra_args: -c distributedcloud-client/tox.ini +- job: + name: stx-distcloud-client-tox-cover + parent: tox + description: Run coverage test for distcloud-client + nodeset: debian-bullseye + vars: + python_version: 3.9 + tox_envlist: cover + tox_extra_args: -c distributedcloud-client/tox.ini + post-run: tools/gate/playbooks/fetch-coverage.yaml + voting: false + - job: name: stx-distcloud-client-upload-git-mirror parent: upload-git-mirror diff --git a/distributedcloud-client/tox.ini b/distributedcloud-client/tox.ini index 8cfb2311..b641f7f3 100644 --- a/distributedcloud-client/tox.ini +++ b/distributedcloud-client/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py39,pep8,pylint,black_check +envlist = py39,pep8,pylint,black_check,cover minversion = 4.4.0 skipsdist = True toxworkdir = /tmp/{env:USER}_dc_client_tox @@ -76,7 +76,7 @@ commands = coverage combine coverage html -d cover coverage xml -o cover/coverage.xml - coverage report + coverage report --fail-under=75 [testenv:debug] commands = oslo_debug_helper {posargs} diff --git a/tools/gate/playbooks/fetch-coverage.yaml b/tools/gate/playbooks/fetch-coverage.yaml new file mode 100644 index 00000000..f79c390a --- /dev/null +++ b/tools/gate/playbooks/fetch-coverage.yaml @@ -0,0 +1,15 @@ +--- +- hosts: "{{ target_hosts | default('all') }}" + gather_facts: false + tasks: + - name: Collect coverage artifacts + synchronize: + src: "{{ zuul.project.src_dir }}/distributedcloud-client/{{ item }}" + dest: "{{ zuul.executor.log_root }}/{{ item }}" + mode: pull + copy_links: true + verify_host: true + loop: + - cover/ + - .coverage + ignore_errors: true diff --git a/tox.ini b/tox.ini index 2fa6b049..b98c27f9 100644 --- a/tox.ini +++ b/tox.ini @@ -33,6 +33,9 @@ description = Dummy environment to allow black to be run in subdir tox [testenv:black_check] description = Dummy environment to allow black_check to be run in subdir tox +[testenv:cover] +description = Dummy environment to allow cover to be run in subdir tox + [testenv:docs] deps = -r{toxinidir}/doc/requirements.txt commands =