Add test coverage to the makefile

This commit is contained in:
2025-05-10 23:58:48 +02:00
parent 925d588f71
commit 0ec233e7c5
2 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/bin
/reports

View File

@ -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)