From b638f521764fcb69f4efcf1c98e9371995e0e762 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 29 Jan 2021 11:46:18 +0000 Subject: [PATCH] Generate a single 'coverage' output line for tests The numbers reported by Gitlab should now be accurate. --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 30b50779..6a90ca0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,12 @@ test: stage: test image: golang:1.15 script: - - go test -v -cover -coverprofile=cover.out ./... + # The following monstruosity is required to generate a single coverage + # result statement for the entire package, but without generating build + # errors due to multiple definition of flags in cmd/ tools. + # See also https://github.com/golang/go/issues/27333 + - go test -v -cover -coverpkg=$(go list ./... | grep -v /cmd/) -coverprofile=cover.out ./... + # Convert coverage output to XML for Gitlab integration. - (cd /tmp && go get github.com/boumenot/gocover-cobertura) - gocover-cobertura < cover.out > cover.xml artifacts: -- GitLab