diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c6137ad21b..15aabbe4c6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,7 +24,7 @@ jobs: go-version: ${{ env.GO_VERSION }} cache: true - name: Run unit tests - run: make test/go + run: make test/go COVERAGE=true - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: diff --git a/Makefile b/Makefile index 8637c3772a..b027b328df 100644 --- a/Makefile +++ b/Makefile @@ -73,8 +73,17 @@ push/chart: test: test/go test/web .PHONY: test/go +test/go: COVERAGE ?= false +test/go: COVERAGE_OPTS ?= -covermode=atomic +test/go: COVERAGE_OUTPUT ?= coverage.out test/go: - go test ./pkg/... ./cmd/... +ifeq ($(COVERAGE), true) + go test -failfast -race $(COVERAGE_OPTS) -coverprofile=$(COVERAGE_OUTPUT).tmp ./pkg/... ./cmd/... + cat $(COVERAGE_OUTPUT).tmp | grep -v ".pb.go\|.pb.validate.go" > $(COVERAGE_OUTPUT) + rm -rf $(COVERAGE_OUTPUT).tmp +else + go test -failfast -race ./pkg/... ./cmd/... +endif .PHONY: test/web test/web: