github.com/Laisky/zap@v1.27.0/Makefile (about) 1 # Directory containing the Makefile. 2 PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 3 4 export GOBIN ?= $(PROJECT_ROOT)/bin 5 export PATH := $(GOBIN):$(PATH) 6 7 GOVULNCHECK = $(GOBIN)/govulncheck 8 BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem 9 10 # Directories containing independent Go modules. 11 MODULE_DIRS = . ./exp ./benchmarks ./zapgrpc/internal/test 12 13 # Directories that we want to track coverage for. 14 COVER_DIRS = . ./exp 15 16 .PHONY: all 17 all: lint test 18 19 .PHONY: lint 20 lint: golangci-lint tidy-lint license-lint 21 22 .PHONY: golangci-lint 23 golangci-lint: 24 @$(foreach mod,$(MODULE_DIRS), \ 25 (cd $(mod) && \ 26 echo "[lint] golangci-lint: $(mod)" && \ 27 golangci-lint run --path-prefix $(mod)) &&) true 28 29 .PHONY: tidy 30 tidy: 31 @$(foreach dir,$(MODULE_DIRS), \ 32 (cd $(dir) && go mod tidy) &&) true 33 34 .PHONY: tidy-lint 35 tidy-lint: 36 @$(foreach mod,$(MODULE_DIRS), \ 37 (cd $(mod) && \ 38 echo "[lint] tidy: $(mod)" && \ 39 go mod tidy && \ 40 git diff --exit-code -- go.mod go.sum) &&) true 41 42 43 .PHONY: license-lint 44 license-lint: 45 ./checklicense.sh 46 47 $(GOVULNCHECK): 48 cd tools && go install golang.org/x/vuln/cmd/govulncheck 49 50 .PHONY: test 51 test: 52 @$(foreach dir,$(MODULE_DIRS),(cd $(dir) && go test -race ./...) &&) true 53 54 .PHONY: cover 55 cover: 56 @$(foreach dir,$(COVER_DIRS), ( \ 57 cd $(dir) && \ 58 go test -race -coverprofile=cover.out -coverpkg=./... ./... \ 59 && go tool cover -html=cover.out -o cover.html) &&) true 60 61 .PHONY: bench 62 BENCH ?= . 63 bench: 64 @$(foreach dir,$(MODULE_DIRS), ( \ 65 cd $(dir) && \ 66 go list ./... | xargs -n1 go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) \ 67 ) &&) true 68 69 .PHONY: updatereadme 70 updatereadme: 71 rm -f README.md 72 cat .readme.tmpl | go run internal/readme/readme.go > README.md 73 74 .PHONY: vulncheck 75 vulncheck: $(GOVULNCHECK) 76 $(GOVULNCHECK) ./...