Skip to content

Commit

Permalink
ci: add coverpkg flag for testing (#815)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phm07 committed Aug 14, 2024
1 parent 129f51d commit 140c11e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 140c11e

Please sign in to comment.