diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 25ab9e5..7d464cd 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -39,7 +39,7 @@ jobs: - name: Run unit tests with race detector if: runner.os != 'Windows' run: | - go test -race -v -coverprofile=coverage.out -coverpkg=./... ./... + make coverage-ci TEST_FLAGS="-race -v" mkdir coverage diff --git a/Makefile b/Makefile index bb731fa..278b664 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ MAKEFLAGS += --always-make +TEST_FLAGS ?= all: generate fmt lint test test-examples tidy @@ -34,6 +35,15 @@ coverage: go test -coverprofile=coverage.out -coverpkg=./... ./... go tool cover -func coverage.out +# get test coverage-ci +.PHONY: coverage-ci +coverage-ci: + go test $(TEST_FLAGS) -coverprofile=coverage.unit.out -coverpkg=./... ./... + go test $(TEST_FLAGS) -tags e2e -coverprofile=coverage.e2e.out -coverpkg=./... ./... || true + go run github.com/dlespiau/covertool@latest merge -o coverage.out coverage.unit.out coverage.e2e.out + go tool cover -func=coverage.out + rm -f coverage.unit.out coverage.e2e.out + # visualize test coverage coverage-html: coverage go tool cover -html coverage.out