Skip to content

Code Coverage#4067

Open
dkalinowski wants to merge 3 commits intomainfrom
coverage
Open

Code Coverage#4067
dkalinowski wants to merge 3 commits intomainfrom
coverage

Conversation

@dkalinowski
Copy link
Collaborator

@dkalinowski dkalinowski commented Mar 18, 2026

🛠 Summary

CVS-183119

make ovms_builder_image BASE_OS=ubuntu24 CHECK_COVERAGE=1 RUN_TESTS=1 MEDIAPIPE_DISABLE=0 PYTHON_DISABLE=0 OV_USE_BINARY=1 OVMS_CPP_DOCKER_IMAGE=ovms_coverage
make get_coverage OVMS_CPP_DOCKER_IMAGE=ovms_coverage

@dkalinowski dkalinowski marked this pull request as ready for review March 18, 2026 09:48
Copilot AI review requested due to automatic review settings March 18, 2026 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the OVMS CI/build workflow to generate a filtered LCOV-based HTML coverage report (excluding tests/external code) and to support the make get_coverage flow that copies genhtml/ out of the -build image.

Changes:

  • Update run_unit_tests.sh coverage mode to post-process Bazel’s LCOV output with lcov --extract/--remove and generate HTML via genhtml.
  • Split Dockerfile test execution so model preparation and unit-test execution run in separate RUN steps when RUN_TESTS=1.
  • Ignore the generated genhtml/ coverage report directory in git.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
run_unit_tests.sh Filters Bazel LCOV output to src/* (excluding src/test/* and external/*) and generates genhtml/ HTML report; adjusts coverage error handling flow.
Dockerfile.ubuntu Splits model preparation and unit test execution into separate RUN steps for RUN_TESTS=1.
Dockerfile.redhat Same as Ubuntu Dockerfile: separates model preparation from running unit tests.
.gitignore Adds genhtml/ to ignored artifacts.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dtrawins
Copy link
Collaborator

how would we export coverage report? Using separate make targets and the build image as parameter?

ARG RUN_TESTS=0
RUN if [ "$RUN_TESTS" == "1" ] ; then mkdir -p demos/common/export_models/ && mv export_model.py demos/common/export_models/ && ./prepare_llm_models.sh /ovms/src/test/llm_testing docker && ./run_unit_tests.sh ; fi
RUN if [ "$RUN_TESTS" == "1" ] ; then mkdir -p demos/common/export_models/ && mv export_model.py demos/common/export_models/ && ./prepare_llm_models.sh /ovms/src/test/llm_testing docker ; fi
RUN if [ "$RUN_TESTS" == "1" ] ; then ./run_unit_tests.sh ; fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is separate command?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It made testing easier for me. Reverted if you like

genhtml --output genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat"
local coverage_dat="$(bazel info output_path)/_coverage/_coverage_report.dat"

if ! lcov --extract "$coverage_dat" 'src/*' --output-file filtered_coverage.dat --ignore-errors negative; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--instrumentation_filter="-src/test is not doing the same filtering?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it didnt work

@dkalinowski
Copy link
Collaborator Author

Added support for redhat as well.

@dkalinowski dkalinowski requested a review from dtrawins March 18, 2026 13:35
@dkalinowski
Copy link
Collaborator Author

how would we export coverage report? Using separate make targets and the build image as parameter?

it is literally in the PR description, please take a look

Comment on lines +61 to +82
# lcov 2.x supports --ignore-errors negative,unused; lcov 1.x does not
local lcov_ver
lcov_ver=$(lcov --version | grep -oP '\d+' | head -1)
local lcov_ignore=""
local genhtml_ignore=""
if [ "$lcov_ver" -ge 2 ] 2>/dev/null; then
lcov_ignore="--ignore-errors negative,unused"
genhtml_ignore="--ignore-errors negative"
fi

if ! lcov --extract "$coverage_dat" 'src/*' --output-file filtered_coverage.dat $lcov_ignore; then
echo "Error: lcov extraction failed" >&2
return 1
fi

if ! lcov --remove filtered_coverage.dat 'src/test/*' 'external/*' --output-file filtered_coverage.dat $lcov_ignore; then
echo "Error: lcov filtering failed" >&2
return 1
fi

if ! genhtml $genhtml_ignore --output genhtml filtered_coverage.dat; then
echo "Error: genhtml report generation failed" >&2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments why such fixes are required, beside that LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the repository’s code coverage generation and validation flow (CVS-183119) by filtering Bazel lcov output into a cleaner genhtml/ report and simplifying how coverage thresholds are checked.

Changes:

  • Enhance run_unit_tests.sh to post-process Bazel coverage output with lcov/genhtml, including version-specific ignore flags and source/test/external filtering.
  • Update the coverage threshold parsing/check script and make it print clearer diagnostics.
  • Adjust Makefile coverage check to run the script locally and ignore generated genhtml/ output in git.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
run_unit_tests.sh Adds lcov/genhtml-based filtering and report generation after bazel coverage.
ci/check_coverage.bat Updates thresholds and parsing logic; adds clearer output and parse failure handling.
Makefile Runs coverage threshold checks via the repo script after copying genhtml/ from the build image.
.gitignore Ignores generated genhtml/ directory.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 3 to +9
#Ubuntu
MIN_LINES_COV=76.8
MIN_FUNCTION_COV=87.6
MIN_LINES_COV=76.0
MIN_FUNCTION_COV=83.0

#Rhel
MIN_LINES_COV=75.6
MIN_FUNCTION_COV=73.0
MIN_LINES_COV=76.0
MIN_FUNCTION_COV=83.0
Comment on lines +76 to +81
if ! lcov --remove filtered_coverage.dat 'src/test/*' 'external/*' --output-file filtered_coverage.dat $lcov_ignore; then
echo "Error: lcov filtering failed" >&2
return 1
fi

if ! genhtml $genhtml_ignore --output genhtml filtered_coverage.dat; then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants