1

I am trying to setup a coverage badge for a python project on GitLab. I was following this question but it is still not working.

Currently I see in "CI/CD"/jobs page this:

enter image description here

But when I go to Settings/"CI-CD"/General pipelines, the coverage report is still unknown:

enter image description here

This is how I defined coverage run in .gitlab-ci.yml file:

tests:
  stage: test
  only:
    - merge_requests
  script:
    - pip install poetry
    - poetry install
    - poetry run coverage run -m pytest
    - poetry run coverage report
    - poetry run coverage xml
  artifacts:
    paths: [coverage.xml]

Any ideas what might need to be set differently?

matt525252
  • 642
  • 1
  • 14
  • 21
  • Is your test coverage determined in the main branch? Your screenshot of the badge under "Settings / CI-CD / General pipelines" shows the main branch. – Jakob Liskow Dec 17 '21 at 12:57
  • 1
    I updated question so now it also includes the ci job with coverage step @JakobLiskow . But everything was merged to `main` branch – matt525252 Dec 17 '21 at 14:17

1 Answers1

0

Okay it looks like that I need to add also -main to only part of my .gitlab-ci.yml and then it works. I was just maybe hoping I can have it without running tests twice (before MR to main and after).

matt525252
  • 642
  • 1
  • 14
  • 21
  • I'm having the same issue. I see the coverage summary in the MR but I'm not able to make the badge work on any branch and I found the same issue about running tests twice. Did you solve it ? – RuBiCK Jun 27 '22 at 15:53
  • Hey, sorry but no. I was not looking for one anymore (now I am little bit more on GitHub). – matt525252 Jul 17 '22 at 20:10