-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (44 loc) · 1.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
GOCMD=GO111MODULE=on go
GOBUILD=$(GOCMD) build
GOBUILDRACE=$(GOCMD) build -race
GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOFMT=$(GOCMD) fmt
BIN_NAME=merkle-tree
ifeq ($(GIT_SHA),)
GIT_SHA:=$(shell git rev-parse HEAD)
endif
LDFLAGS = "-X 'main.GitSHA1=$(GIT_SHA)'"
.PHONY: all test coverage build checkfmt fmt
all: test coverage build checkfmt fmt
build:
$(GOBUILD) \
-ldflags=$(LDFLAGS) -o $(BIN_NAME) main.go
build-race:
$(GOBUILDRACE) \
-ldflags=$(LDFLAGS) .
install:
$(GOINSTALL)
checkfmt:
@echo 'Checking gofmt';\
bash -c "diff -u <(echo -n) <(go fmt .)";\
EXIT_CODE=$$?;\
if [ "$$EXIT_CODE" -ne 0 ]; then \
echo '$@: Go files must be formatted with gofmt'; \
fi && \
exit $$EXIT_CODE
lint:
$(GOGET) github.com/golangci/golangci-lint/cmd/golangci-lint
golangci-lint run
fmt:
$(GOFMT) .
test:
$(GOFMT) ./...
$(GOTEST) -race -covermode=atomic ./...
coverage: get test
$(GOTEST) -race -coverprofile=coverage.txt -covermode=atomic .
BENCH_COUNT ?= 5
bench:
$(GOGET) golang.org/x/perf/cmd/benchstat@latest
$(GOTEST) -bench=. ./... -benchtime=5s -benchmem -count=6 -run=^#