7

I have created a very simple example: https://gitlab.com/mvfwd/gitlab-coverage.

Unfortunately gitlab does not show Cobertura coverage visualisation.

Here is my .gitlab-ci.yml:

image: python:3

stages:
- test

coverage:
  stage: test
  script:
  - pip install coverage
  - coverage run ./main.py
  - coverage report -m
  - coverage xml
  artifacts:
    paths:
    - ./coverage.xml
    reports:
      cobertura: ./coverage.xml
  only:
  - master

In logs I can see that coverage report is uploaded (link):

$ coverage run ./main.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
$ coverage report -m
Name      Stmts   Miss  Cover   Missing
---------------------------------------
main.py      26     12    54%   9-14, 20-25
---------------------------------------
TOTAL        26     12    54%
$ coverage xml
Uploading artifacts for successful job
00:03
Uploading artifacts...
./coverage.xml: found 1 matching files and directories 
Uploading artifacts as "archive" to coordinator... ok  id=1450561054 responseStatus=201 Created token=eZqc9KYb
Uploading artifacts...
./coverage.xml: found 1 matching files and directories 
Uploading artifacts as "cobertura" to coordinator... ok  id=1450561054 responseStatus=201 Created token=eZqc9KYb
Cleaning up file based variables
00:00
Job succeeded

What am I doing wrong?

3 Answers 3

4

I have filed an issue and solution was found. Here is the recap:

  • I understood the feature wrong, it works only for MR changes, not on regular commits or in file explorer
  • I missed that recently there was a rename from master to main, documenation examples were not updated and I copied that to my .gitlab-ci.yml, which prevented autostarting pipelines on commit
3

I took a look at the sample project you created.

When looking at the diff for the open MR, I am able to see the coverage visualization. Here is a screenshot of the coverage visualization in sample project MR.

enter image description here

If you're still having issues, it would be great if you could open a bug report and share more details about your browser settings, etc so we can identify the cause of your issue.

2
  • 1
    I have filed an issue and we found the solution. Here is the recap: - I understood the feature wrong, it works only for MR, not on regular commits or file explorer - I missed that recently there was a rename from master to main, documenation examples were not updated and I copied that to my .gitlab-ci.yml, which prevented autostart on commit. - the link to MR you provided was exactly the point when it started working Sorry, I should have updated this stackoverflow question as well, my bad. Doing it now. Many thanks, John, for taking a look and trying to help!
    – mvfwd
    Commented Aug 25, 2021 at 7:01
  • Hi! I would expect that the Tests tab wouldn't be empty as in the case of junit format. Yours and in my case as well, are empty.
    – Erokos
    Commented Jan 18, 2023 at 12:52
-2

Shouldn't the test tab also show the tests like it does for the junit format? enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.