2024-01-03 21:57:33 +00:00
|
|
|
# Directory containing the Makefile.
|
|
|
|
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
2019-07-24 07:58:01 +00:00
|
|
|
|
2024-01-03 21:57:33 +00:00
|
|
|
export GOBIN ?= $(PROJECT_ROOT)/bin
|
|
|
|
export PATH := $(GOBIN):$(PATH)
|
|
|
|
|
|
|
|
GOVULNCHECK = $(GOBIN)/govulncheck
|
2019-07-24 07:58:01 +00:00
|
|
|
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
|
|
|
|
|
2019-11-25 20:16:00 +00:00
|
|
|
# Directories containing independent Go modules.
|
2024-01-03 21:57:33 +00:00
|
|
|
MODULE_DIRS = . ./exp ./benchmarks ./zapgrpc/internal/test
|
2019-07-24 07:58:01 +00:00
|
|
|
|
2024-01-03 21:57:33 +00:00
|
|
|
# Directories that we want to track coverage for.
|
|
|
|
COVER_DIRS = . ./exp
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: lint test
|
|
|
|
|
|
|
|
.PHONY: lint
|
2024-01-03 21:57:33 +00:00
|
|
|
lint: golangci-lint tidy-lint license-lint
|
|
|
|
|
|
|
|
.PHONY: golangci-lint
|
|
|
|
golangci-lint:
|
|
|
|
@$(foreach mod,$(MODULE_DIRS), \
|
|
|
|
(cd $(mod) && \
|
|
|
|
echo "[lint] golangci-lint: $(mod)" && \
|
|
|
|
golangci-lint run --path-prefix $(mod)) &&) true
|
|
|
|
|
|
|
|
.PHONY: tidy
|
|
|
|
tidy:
|
|
|
|
@$(foreach dir,$(MODULE_DIRS), \
|
|
|
|
(cd $(dir) && go mod tidy) &&) true
|
|
|
|
|
|
|
|
.PHONY: tidy-lint
|
|
|
|
tidy-lint:
|
|
|
|
@$(foreach mod,$(MODULE_DIRS), \
|
|
|
|
(cd $(mod) && \
|
|
|
|
echo "[lint] tidy: $(mod)" && \
|
|
|
|
go mod tidy && \
|
|
|
|
git diff --exit-code -- go.mod go.sum) &&) true
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: license-lint
|
|
|
|
license-lint:
|
|
|
|
./checklicense.sh
|
|
|
|
|
|
|
|
$(GOVULNCHECK):
|
|
|
|
cd tools && go install golang.org/x/vuln/cmd/govulncheck
|
2021-06-16 20:19:45 +00:00
|
|
|
|
2019-07-24 07:58:01 +00:00
|
|
|
.PHONY: test
|
|
|
|
test:
|
2019-11-25 20:16:00 +00:00
|
|
|
@$(foreach dir,$(MODULE_DIRS),(cd $(dir) && go test -race ./...) &&) true
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: cover
|
|
|
|
cover:
|
2024-01-03 21:57:33 +00:00
|
|
|
@$(foreach dir,$(COVER_DIRS), ( \
|
|
|
|
cd $(dir) && \
|
|
|
|
go test -race -coverprofile=cover.out -coverpkg=./... ./... \
|
|
|
|
&& go tool cover -html=cover.out -o cover.html) &&) true
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: bench
|
|
|
|
BENCH ?= .
|
|
|
|
bench:
|
2019-11-25 20:16:00 +00:00
|
|
|
@$(foreach dir,$(MODULE_DIRS), ( \
|
|
|
|
cd $(dir) && \
|
|
|
|
go list ./... | xargs -n1 go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) \
|
|
|
|
) &&) true
|
2019-07-24 07:58:01 +00:00
|
|
|
|
|
|
|
.PHONY: updatereadme
|
|
|
|
updatereadme:
|
|
|
|
rm -f README.md
|
|
|
|
cat .readme.tmpl | go run internal/readme/readme.go > README.md
|
2021-10-19 13:43:41 +00:00
|
|
|
|
2024-01-03 21:57:33 +00:00
|
|
|
.PHONY: vulncheck
|
|
|
|
vulncheck: $(GOVULNCHECK)
|
|
|
|
$(GOVULNCHECK) ./...
|