Test Coverage Visualization in Changes tab on merge requests

Following up on Cobertura coverage not showing in diff or jobs - #5 by Btripp1986 & Code coverage visualisation in Merge Requests - #7 by jmkelm08


I am trying to get test coverage visualization for our repository as described here [Test Coverage Visualization ]
(Test coverage visualization | GitLab) for our merge requests on gitlab.com on the changes tab.


Our job publishing coverage information looks like:

  image: $CI_REGISTRY_IMAGE/test:latest
  stage: test
    - job: "image:test"
      optional: true
    - make ci-test
    when: always
      junit: report.xml
      cobertura: coverage.xml
      - ./htmlcov/

In the job we observe coverage.xml being published. The coverage.xml file has correct paths relative to the root of the repository, boloo/conftest.py exists at at the root:

<?xml version="1.0" ?>
<coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.6528" lines-covered="9472" lines-valid="14510" timestamp="1635320488212" version="6.0.2">
        <!-- Generated by coverage.py: https://coverage.readthedocs.io -->
        <!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
                <package branch-rate="0" complexity="0" line-rate="0.8974" name="boloo">
                                <class branch-rate="0" complexity="0" filename="boloo/conftest.py" line-rate="0.8974" name="conftest.py">
                                                <line hits="1" number="1"/>

The xml file is ‘tiny’ at 527kB.


There’s no page to to go to explicitly see the status of coverage processing; where this could show pending, processing, failed, absent.
There are no error messages to dig deeper.

Uploading artifacts...
coverage.xml: found 1 matching files and directories 
Uploading artifacts as "cobertura" to coordinator... ok  id=1738<id> responseStatus=201 Created token=<token?

What we see

We see no coverage on any of our MR’s, even hours later. Per the earlier mentioned ticket, we also see no HTTP requests mentioning coverage in their path.
HTML for the gutter includes <div class="diff-td line-coverage left-side has-tooltip"></div>

Any pointers into things we can try would be appreciated by our small dev team that cares about quality.

1 Like

It would be great to be able to fail a pipeline if the resulting coverage.xml file could not be processed.

I believe I’ve traced this down to refactoring of our virtualenv - with the omit rule nolonger matching; therefore the coverage report included all of site-packages.