@anton_akhmerov thanks for the post! I’m not certain if you are trying to see the coverage value and diff on the Merge Request page OR the test coverage visualization in the Merge Request Diff?
If it is the first one double check your regex in the CI/CD settings. If the latter I believe you’ve setup everything correctly and we’d be interested to get a glimpse of what you are seeing in the MR diff view.
@anton_akhmerov could you get add the cov.xml as an artifact in the .gitlab-ci.yml so we can download it and take a look? the current thinking is the format isn’t correct based on what we can see in the current setup but we’d like to confirm. thanks!
@anton_akhmerov - Thanks for the file it was helpful. We have run into some cases, like yours, in which the implementation for the code coverage doesn’t handle absolute paths well. We have an issue open and a documented workaround for coverlet is noted in there. I’m not sure if a similar workaround approach would work here for you or not.
You can follow along on the issue as we make progress here and we will use your case to validate the fix before shipping it.
These substitutions worked for me (this is with pytest-cov). I am not sure whether it’s the only choice, but since I couldn’t find documentation on what path structure gitlab expects, I tried until something worked.
Hi @anton_akhmerov, I’m struggling with the same setup (python with coverage/pytest-cov) but couldn’t find the proper strings to replace in the report file yet.
Tried to apply your substitutions but no luck. It would be nice to have the precise lines before and after your replacement, so that I would have a working reference to compare with.
In our case we are generating coverage in ephemeral containers with a path that GitLab couldn’t reference. So what Anton did is update the “source” to be the the root-level src dir of the code, and also insert this src dir into every “filename” in coverage.xml. With that in place, GitLab started showing the coverage inline in the MRs.
I’m also confronted with not seeing any visual indication of coverage (produced by jest) in Merge Request Diffs. The file is properly uploaded as artifacts:reports:junit and Feature.enable(:coverage_report_view) has been executed in the rails console.
In my case the root of the covered files is the repository itself (not a sub-directory like src). I’ve tried patching the cobertura xml to no avail:
@rodneyrehm did you mean artifacts:reports:cobertura?
I’m having the same problem. I tried different <source> and filename paths to no avail. How can we determine what path the code coverage parser is expecting?
Thanks for the workaround, never would have guessed that.
For me this seems to work directly in a new branch:
- sed -i "s=<source>.*</source>=<source>./</source>=g" coverage.$MODULENAME.xml
- sed -i "s;filename=\";filename=\"${SRC_DIR}/;g" /coverage.$MODULENAME.xml
variables:
SRC_DIR: backend/$MODULENAME/$MODULENAME # needed by MR test coverage