I am trying to make test coverage work for a python project. And I simply cannot figure out why there is no percentage showing neither in the tests nor the badge.
coverage report is called produces this output in the log:
[...] tests/__init__.py 0 0 100% tests/test_ml_squarer.py 4 0 100% tests/test_squarer.py 4 0 100% ---------------------------------------------- TOTAL 17 2 88% test_service run-test: commands | coverage xml
and depending on the
regex-expression that is saved in General > CI/CD, it simply looks for the
88% next to
TOTAL. I used the recommended one for pytest-cov (Python) , i.e.
^TOTAL.+?(d+%)$ which works according to a regex checker.
I also run
coverage xml together with
artifacts: reports: cobertura: coverage.xml
which results in a successful upload of the file but I dont think this would be necessary for showing the basic percentages:
Uploading artifacts... Runtime platform arch=amd64 os=linux pid=29421 revision=05161b14 version=12.4.1 coverage.xml: found 1 matching files Uploading artifacts to coordinator... ok id=8996 responseStatus=201 Created token=DXpxsGiF
Either way, it is not working for me using: GitLab Community Edition 12.10.11. Any ideas anyone?
fortunately, a friend of mine was able to help, referencing:
So in the end the
regex didn’t fit even though it looks like it would. I guess what made it even more difficult was the other
regex was recommended by Gitlab itself.
The correct regex is:
As you can see, there is no (visual) differnce to the one above…