forked from Shopify/zk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (59 loc) · 1.79 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
REPO_ROOT = $(shell pwd -P)
TOOLS_BINDIR = $(REPO_ROOT)/tools/bin
GOTESTSUM_BIN = $(TOOLS_BINDIR)/gotestsum
GOLANGCI_LINT_BIN ?= $(TOOLS_BINDIR)/golangci-lint
PACKAGES := $(shell go list ./... | grep -v examples)
# make file to hold the logic of build and test setup
ZK_VERSION ?= 3.6.2
# Apache changed the name of the archive in version 3.5.x and seperated out src and binary packages
ZK_MINOR_VER=$(word 2, $(subst ., ,$(ZK_VERSION)))
ifeq ($(shell test $(ZK_MINOR_VER) -le 4; echo $$?),0)
ZK = zookeeper-$(ZK_VERSION)
else
ZK = apache-zookeeper-$(ZK_VERSION)-bin
endif
ZK_URL = "https://archive.apache.org/dist/zookeeper/zookeeper-$(ZK_VERSION)/$(ZK).tar.gz"
.DEFAULT_GOAL := test
$(ZK):
wget $(ZK_URL)
tar -zxf $(ZK).tar.gz
rm $(ZK).tar.gz
zookeeper: $(ZK)
# we link to a standard directory path so then the tests dont need to find based on version
# in the test code. this allows backward compatable testing.
ln -s $(ZK) zookeeper
.PHONY: setup
setup: zookeeper tools
.PHONY: tools
tools: tools/tools.go tools/go.mod
mkdir -p "$(TOOLS_BINDIR)"
cd tools && \
export GOBIN="${TOOLS_BINDIR}" && \
go install \
github.com/golangci/golangci-lint/cmd/golangci-lint \
gotest.tools/gotestsum && \
cd ..
.PHONY: lint
lint: tools
go vet ./...
$(GOLANGCI_LINT_BIN) run -v --deadline 10m
.PHONY: lint-fix
lint-fix: tools
go fmt ./...
go vet ./...
$(GOLANGCI_LINT_BIN) run -v --deadline 10m --fix
.PHONY: build
build:
go build ./...
.PHONY: test
test: tools build zookeeper
ZK_VERSION=$(ZK_VERSION) $(GOTESTSUM_BIN) --format dots -- -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES)
.PHONY: clean
clean:
rm -f apache-zookeeper-*.tar.gz
rm -f zookeeper-*.tar.gz
rm -rf apache-zookeeper-*/
rm -rf zookeeper-*/
rm -f zookeeper
rm -f profile.cov
rm -rf tools/bin