From 0ec233e7c55909467f5e39537d62ba679db82456 Mon Sep 17 00:00:00 2001 From: omicron Date: Sat, 10 May 2025 23:58:48 +0200 Subject: [PATCH] Add test coverage to the makefile --- .gitignore | 1 + Makefile | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5e56e04..b349d25 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /bin +/reports diff --git a/Makefile b/Makefile index c96713f..7a8d3f3 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ COMMIT_DATETIME := $(shell git log -1 --format=%cd --date=iso8601) LDFLAGS := -X git.omicron.one/omicron/linkshare/internal/version.Version=$(VERSION) \ -X git.omicron.one/omicron/linkshare/internal/version.GitCommit=$(COMMIT) \ -X "git.omicron.one/omicron/linkshare/internal/version.CommitDateTime=$(COMMIT_DATETIME)" +OPEN = xdg-open all: build @@ -25,7 +26,10 @@ $(BINARIES): %: $(BINARY_DIR) go build -ldflags '$(LDFLAGS)' -o $(BINARY_DIR)/$@ ./cmd/$@/ test: - go test ./... + mkdir -p reports/coverage/ + go test ./... -coverprofile=reports/coverage/coverage.out + go tool cover -html=reports/coverage/coverage.out -o reports/coverage/coverage.html && $(OPEN) reports/coverage/coverage.html + validate: @test -z "$(shell gofumpt -l .)" && echo "No files need formatting" || (echo "Incorrect formatting in:"; gofumpt -l .; exit 1) @@ -33,6 +37,7 @@ validate: clean: rm -rf $(BINARY_DIR) + rm -rf reports go clean run: $(LINKSERV)