Skip to content

Commit

Permalink
Fix Makefile coverage output dir for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-ebrown committed May 26, 2024
1 parent eaa7cad commit c677cb5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fmt:
.PHONY: test-all
test-all: build gotestsum ## Run all tests
$(touch .env)
gotestsum --format=pkgname-and-test-fails --format-hivis -- -coverprofile=coverage/cover.out ./... --tags="unit"
gotestsum --format=pkgname-and-test-fails --format-hivis -- -coverprofile=$(SRC_DIR)coverage/cover.out ./... --tags="unit"

.PHONY: common-deps
common-deps:
Expand Down Expand Up @@ -46,17 +46,17 @@ lint: golangci-lint

.PHONY: test-short
test-short: build gotestsum
gotestsum --format=pkgname-and-test-fails --format-hivis -- -coverprofile=coverage/cover.out ./... -short
gotestsum --format=pkgname-and-test-fails --format-hivis -- -coverprofile=$(SRC_DIR)coverage/cover.out ./... -short

.PHONY: test
test: fmt lint test-all

.PHONY: test-coverage
test-coverage: build ## Run all tests and generate a coverage report
$(touch .env)
gotestsum --format=pkgname-and-test-fails --format-hivis -- -covermode=count -coverpkg=./... -coverprofile=coverage/cover.out.tmp -v ./... --tags="unit"
gotestsum --format=pkgname-and-test-fails --format-hivis -- -covermode=count -coverpkg=./... -coverprofile=$(SRC_DIR)coverage/cover.out.tmp -v ./... --tags="unit"

# Stripping out API docs and internal/app/mocks from the coverage report
cat coverage/cover.out.tmp | grep -v "api/docs.go" | grep -v "mock_" > coverage/cover.out
cat $(SRC_DIR)coverage/cover.out.tmp | grep -v "api/docs.go" | grep -v "mock_" > $(SRC_DIR)coverage/cover.out

go tool cover -html coverage/cover.out -o coverage/cover.html
go tool cover -html $(SRC_DIR)coverage/cover.out -o $(SRC_DIR)coverage/cover.html

0 comments on commit c677cb5

Please sign in to comment.