Visualize test coverage on entire repo

Problem to solve

The test coverage visualization shows which parts of the code changed by a Merge Request are covered by automated tests:

This is very useful, but it would be great if this information could also be visualized on the entire Git repo (i.e. not just the portions of the codebase changed by a Merge Request).

A workaround is to use a test coverage library able to generate an HTML report for the entire repo and then publish that report on Gitlab Pages. For instance phpunit/php-code-coverage can generate reports like this (image taken from this article):

But it would be more convenient and intuitive to integrate this functionality directly into the Gitlab interface. Ideally I would want to visualize this information directly in the code repository browser.

Configuration

# .gitlab-ci.yml
phpunit:
  image: private-registry.example.net/php-with-xdebug-and-composer
  script:
    - composer install
    - phpunit --coverage-cobertura=${CI_PROJECT_DIR}/cobertura/cobertura.xml
  environment:
    XDEBUG_MODE: coverage
  artifacts:
    paths:
      - cobertura/*.xml
    reports:
      coverage_report:
        coverage_format: cobertura
        path: cobertura/*.xml

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Dedicated
  • Self-hosted Runners

Versions

  • GitLab Enterprise Edition v17.6.3-ee
  • GitLab Runner: unknown