refactoring makefile, also adding test (#71)

This commit is contained in:
Dimas Yudha P
2022-11-03 23:47:28 +07:00
committed by GitHub
parent f64fbd4a2e
commit ef31263797

View File

@@ -1,9 +1,24 @@
pull: DATE ?= $(shell date +%FT%T%z)
git pull VERSION ?= $(git describe --tags --always --dirty --match=v* 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo "v0")
build: .PHONY: test
go build -o bin/dashboard . test: ; $(info $(M) start unit testing...) @
@go test $$(go list ./... | grep -v /mocks/) --race -v -short -coverprofile=profile.cov
@echo "\n*****************************"
@echo "** TOTAL COVERAGE: $$(go tool cover -func profile.cov | grep total | grep -Eo '[0-9]+\.[0-9]+')% **"
@echo "*****************************\n"
.PHONY: pull
pull: ; $(info $(M) Pulling source...) @
@git pull
debug: .PHONY: build
DEBUG=1 ./bin/dashboard build: $(BIN) ; $(info $(M) Building executable...) @ ## Build program binary
$Q $(GO) build \
-ldflags '-X main.version=$(VERSION) -X main.buildDate=$(DATE)' \
-o bin/dashboard .
.PHONY: debug
debug: ; $(info $(M) Running dashboard in debug mode...) @
@DEBUG=1 ./bin/dashboard