Add test coverage to the makefile
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/bin
|
/bin
|
||||||
|
/reports
|
||||||
|
7
Makefile
7
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) \
|
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.GitCommit=$(COMMIT) \
|
||||||
-X "git.omicron.one/omicron/linkshare/internal/version.CommitDateTime=$(COMMIT_DATETIME)"
|
-X "git.omicron.one/omicron/linkshare/internal/version.CommitDateTime=$(COMMIT_DATETIME)"
|
||||||
|
OPEN = xdg-open
|
||||||
|
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
@ -25,7 +26,10 @@ $(BINARIES): %: $(BINARY_DIR)
|
|||||||
go build -ldflags '$(LDFLAGS)' -o $(BINARY_DIR)/$@ ./cmd/$@/
|
go build -ldflags '$(LDFLAGS)' -o $(BINARY_DIR)/$@ ./cmd/$@/
|
||||||
|
|
||||||
test:
|
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:
|
validate:
|
||||||
@test -z "$(shell gofumpt -l .)" && echo "No files need formatting" || (echo "Incorrect formatting in:"; gofumpt -l .; exit 1)
|
@test -z "$(shell gofumpt -l .)" && echo "No files need formatting" || (echo "Incorrect formatting in:"; gofumpt -l .; exit 1)
|
||||||
@ -33,6 +37,7 @@ validate:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BINARY_DIR)
|
rm -rf $(BINARY_DIR)
|
||||||
|
rm -rf reports
|
||||||
go clean
|
go clean
|
||||||
|
|
||||||
run: $(LINKSERV)
|
run: $(LINKSERV)
|
||||||
|
Reference in New Issue
Block a user