Add nox session to generate code coverage HTML reports

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-08-28 19:01:01 +01:00 committed by Megan Wilhite
parent 48bccb9e87
commit 142a6cb9e2
6 changed files with 40 additions and 0 deletions

View file

@ -1327,6 +1327,10 @@ jobs:
run: |
nox --force-color -e combine-coverage
- name: Create Code Coverage HTML Report
run: |
nox --force-color -e create-html-coverage-report
set-pipeline-exit-status:
# This step is just so we can make github require this step, to pass checks
# on a pull request instead of requiring all

View file

@ -1382,6 +1382,10 @@ jobs:
run: |
nox --force-color -e combine-coverage
- name: Create Code Coverage HTML Report
run: |
nox --force-color -e create-html-coverage-report
build-src-repo:
name: Build Source Repository
environment: nightly

View file

@ -1361,6 +1361,10 @@ jobs:
run: |
nox --force-color -e combine-coverage
- name: Create Code Coverage HTML Report
run: |
nox --force-color -e create-html-coverage-report
set-pipeline-exit-status:
# This step is just so we can make github require this step, to pass checks
# on a pull request instead of requiring all

View file

@ -1377,6 +1377,10 @@ jobs:
run: |
nox --force-color -e combine-coverage
- name: Create Code Coverage HTML Report
run: |
nox --force-color -e create-html-coverage-report
build-src-repo:
name: Build Source Repository
environment: staging

View file

@ -338,4 +338,8 @@
run: |
nox --force-color -e combine-coverage
- name: Create Code Coverage HTML Report
run: |
nox --force-color -e create-html-coverage-report
<%- endblock jobs %>

View file

@ -1345,6 +1345,26 @@ def combine_coverage(session):
pass
@nox.session(python="3", name="create-html-coverage-report")
def create_html_coverage_report(session):
_install_coverage_requirement(session)
env = {
# The full path to the .coverage data file. Makes sure we always write
# them to the same directory
"COVERAGE_FILE": str(COVERAGE_FILE),
}
# Generate html report for Salt and tests combined code coverage
session.run(
"coverage",
"html",
"-d",
str(COVERAGE_OUTPUT_DIR.joinpath("html").relative_to(REPO_ROOT)),
"--include=salt/*,tests/*",
env=env,
)
class Tee:
"""
Python class to mimic linux tee behaviour