Skip to content

Commit

Permalink
Run tests with coverage on CI
Browse files Browse the repository at this point in the history
Combine 'make cover' and 'make acc-cover' into single command.
They still write coverage into different files -- it would be useful to see separate coverage numbers.
  • Loading branch information
denik committed Jan 14, 2025
1 parent a5e09ab commit 843ccf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
make vendor
pip3 install wheel
- name: Run tests
run: make test
- name: Run tests with coverage
run: make cover

golangci:
needs: cleanups
Expand Down
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ default: build
PACKAGES=./acceptance/... ./libs/... ./internal/... ./cmd/... ./bundle/... .

GOTESTSUM_FORMAT ?= pkgname-and-test-fails
GOTESTSUM_CMD ?= gotestsum --format ${GOTESTSUM_FORMAT} --no-summary=skipped


lint:
golangci-lint run --fix
Expand All @@ -17,22 +19,19 @@ fmt:
golangci-lint run --enable-only="gofmt,gofumpt,goimports" --fix ./...

test:
gotestsum --format ${GOTESTSUM_FORMAT} --no-summary=skipped -- ${PACKAGES}
${GOTESTSUM_CMD} -- ${PACKAGES}

cover:
gotestsum --format ${GOTESTSUM_FORMAT} --no-summary=skipped -- -coverprofile=coverage.txt ${PACKAGES}

showcover:
go tool cover -html=coverage.txt

acc-cover:
rm -fr ./acceptance/build/cover/
CLI_GOCOVERDIR=build/cover go test ./acceptance
CLI_GOCOVERDIR=build/cover ${GOTESTSUM_CMD} -- -coverprofile=coverage.txt ${PACKAGES}
rm -fr ./acceptance/build/cover-merged/
mkdir -p acceptance/build/cover-merged/
go tool covdata merge -i $$(printf '%s,' acceptance/build/cover/* | sed 's/,$$//') -o acceptance/build/cover-merged/
go tool covdata textfmt -i acceptance/build/cover-merged -o coverage-acceptance.txt

showcover:
go tool cover -html=coverage.txt

acc-showcover:
go tool cover -html=coverage-acceptance.txt

Expand Down

0 comments on commit 843ccf6

Please sign in to comment.