Code coverage visualization not working for CI
I noticed that the code coverage visualization (https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization/) isn't working in merge requests.
For example, I see that the test coverage report
job is running in https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/7897806072:
splitic cover-merge .splitic/cover_1.profile .splitic/cover_2.profile .splitic/cover_3.profile .splitic/cover_4.profile > out/coverage/coverprofile.regular.source.txt
gocover-cobertura < out/coverage/coverprofile.regular.source.txt > out/cobertura/cobertura-coverage-raw.xml
sed 's;filename=\"gitlab.com/gitlab-org/gitlab-runner/;filename=\";g' out/cobertura/cobertura-coverage-raw.xml > \
out/cobertura/cobertura-coverage.xml
out/coverage/coverprofile.regular.source.txt
contains only data from gitlab.com/gitlab-org/gitlab-runner/main.go
.
I'd expect more coverage across more files. In the unit tests in https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/7897805894, I see that cover_1.profile
also only contains data from gitlab.com/gitlab-org/gitlab-runner/main.go
as well:
% cat coverprofile.regular.source.txt | tail
gitlab.com/gitlab-org/gitlab-runner/main.go:42.13,45.2 2 0
gitlab.com/gitlab-org/gitlab-runner/main.go:47.13,48.15 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:48.15,49.31 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:49.31,51.38 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:51.38,53.5 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:54.4,54.12 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:58.2,72.67 9 0
gitlab.com/gitlab-org/gitlab-runner/main.go:72.67,74.3 1 0
gitlab.com/gitlab-org/gitlab-runner/main.go:76.2,84.41 7 0
gitlab.com/gitlab-org/gitlab-runner/main.go:84.41,86.3 1 0
Something might be off with the -coverpkg
argument since if I run this, it works fine:
go test -v -covermode=count -coverprofile=/tmp/cover.out ./...
However, if I run:
go test -v -covermode=count -coverprofile=/tmp/cover.out -coverpkg gitlab.com/gitlab-org/gitlab-runner ./...
This I see the similar issue with gitlab.com/gitlab-org/gitlab-runner/main.go
being the only file in the code coverage.
I think we need to add ./...
:
go test -v -covermode=count -coverprofile=/tmp/cover.out -coverpkg gitlab.com/gitlab-org/gitlab-runner/... ./...