github.com/jurelou/go-magic@v0.0.0-20230518182705-f2995a311800/Makefile (about) 1 SHELL := /bin/bash 2 VERBOSE := $(or $(VERBOSE),$(V)) 3 4 .SUFFIXES: 5 6 .PHONY: \ 7 help \ 8 default \ 9 clean \ 10 tools \ 11 test \ 12 lint \ 13 coverage \ 14 env \ 15 build \ 16 doc \ 17 version 18 19 ifneq ($(VERBOSE), 1) 20 .SILENT: 21 endif 22 23 default: all 24 25 all: lint build 26 27 help: ## Show this help screen. 28 @echo 'Usage: make <OPTIONS> ... <TARGETS>' 29 @echo '' 30 @echo 'Available targets are:' 31 @echo '' 32 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ 33 awk 'BEGIN { FS = ":.*?## " }; { printf "%-30s %s\n", $$1, $$2 }' 34 @echo '' 35 @echo 'Targets run by default are lint and build.' 36 @echo '' 37 38 print-%: 39 @echo $* = $($*) 40 41 clean: ## Remove binaries, artifacts and releases. 42 go clean -i ./... 43 rm -f $(CURDIR)/coverage.* 44 45 tools: ## Install tools needed by the project. 46 GO111MODULE=off go get github.com/alecthomas/gometalinter 47 GO111MODULE=off go get github.com/axw/gocov/gocov 48 GO111MODULE=off go get github.com/matm/gocov-html 49 GO111MODULE=off GOPATH=$(shell go env GOPATH) gometalinter --install 50 51 test: ## Run unit tests. 52 go test -v ./... 53 54 lint: ## Run lint tests suite. 55 $(eval QUIET := $(shell test "$(MAKECMDGOALS)" == "lint" || echo 1)) 56 gometalinter ./... $(shell test -z "$(QUIET)" || echo '&>/dev/null'); \ 57 if (( $$? > 0 )); then \ 58 if [[ -n "$(QUIET)" ]]; then \ 59 echo "Found number of issues when running lint tests suite. Run 'make lint' to check directly."; \ 60 else \ 61 test -z "$(VERBOSE)" || exit $$?; \ 62 fi; \ 63 fi 64 65 coverage: ## Report code tests coverage. 66 gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null 67 gocov report $(CURDIR)/coverage.out 68 if [[ -z "$$CI" ]]; then \ 69 gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \ 70 if which open &>/dev/null; then \ 71 open $(CURDIR)/coverage.html; \ 72 fi; \ 73 fi 74 75 env: ## Display Go environment. 76 @go env 77 78 build: ## Build project for current platform. 79 go build ./... 80 81 doc: ## Start Go documentation server on port 8080. 82 godoc -http=:8080 -index 83 84 version: ## Display Go version. 85 @go version