From 140c11eda579e8884b2192636c89dbe1f7a48e9e Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Wed, 14 Aug 2024 13:47:35 +0200 Subject: [PATCH] ci: add coverpkg flag for testing (#815) This PR adds the `-coverpkg=./...` flag so that coverage is not only restricted to lines in the same package as the running test. This flag is needed for end to end testing. Adding the flag now makes it easier for us to compare the coverage of e2e tests with the main branch. --- .github/workflows/ci.yml | 2 +- .gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 497eb872..6d239205 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: go-version-file: go.mod - name: Run tests - run: go test -coverprofile=coverage.txt -v -race ./... + run: go test -coverpkg=./... -coverprofile=coverage.txt -v -race ./... - name: Upload coverage reports to Codecov if: > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3f4f85a..e0f6c84f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,7 +47,7 @@ test:unit: stage: test image: golang:1.21 script: - - go test -v -coverprofile=coverage.txt -covermode count ./... + - go test -v -coverpkg=./... -coverprofile=coverage.txt -covermode count ./... - go get github.com/boumenot/gocover-cobertura - go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml artifacts: