| 1 |
# make file to hold the logic of build and test setup |
| 2 |
ZK_VERSION ?= 3.5.6 |
| 3 |
|
| 4 |
# Apache changed the name of the archive in version 3.5.x and seperated out |
| 5 |
# src and binary packages |
| 6 |
ZK_MINOR_VER=$(word 2, $(subst ., ,$(ZK_VERSION))) |
| 7 |
ifeq ($(shell test $(ZK_MINOR_VER) -le 4; echo $$?),0) |
| 8 |
ZK = zookeeper-$(ZK_VERSION) |
| 9 |
else |
| 10 |
ZK = apache-zookeeper-$(ZK_VERSION)-bin |
| 11 |
endif |
| 12 |
ZK_URL = "https://archive.apache.org/dist/zookeeper/zookeeper-$(ZK_VERSION)/$(ZK).tar.gz" |
| 13 |
|
| 14 |
PACKAGES := $(shell go list ./... | grep -v examples) |
| 15 |
|
| 16 |
.DEFAULT_GOAL := test |
| 17 |
|
| 18 |
$(ZK): |
| 19 |
wget $(ZK_URL) |
| 20 |
tar -zxf $(ZK).tar.gz |
| 21 |
rm $(ZK).tar.gz |
| 22 |
|
| 23 |
zookeeper: $(ZK) |
| 24 |
# we link to a standard directory path so then the tests dont need to find based on version |
| 25 |
# in the test code. this allows backward compatable testing. |
| 26 |
ln -s $(ZK) zookeeper |
| 27 |
|
| 28 |
.PHONY: setup |
| 29 |
setup: zookeeper |
| 30 |
|
| 31 |
.PHONY: lint |
| 32 |
lint: |
| 33 |
go fmt ./... |
| 34 |
go vet ./... |
| 35 |
|
| 36 |
.PHONY: build |
| 37 |
build: |
| 38 |
go build ./... |
| 39 |
|
| 40 |
.PHONY: unittest |
| 41 |
unittest: |
| 42 |
go test -timeout 500s -v -race -covermode atomic -skip=Integration ./... |
| 43 |
|
| 44 |
.PHONY: test |
| 45 |
test: build zookeeper |
| 46 |
go test -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES) |
| 47 |
|
| 48 |
.PHONY: clean |
| 49 |
clean: |
| 50 |
rm -f apache-zookeeper-*.tar.gz |
| 51 |
rm -f zookeeper-*.tar.gz |
| 52 |
rm -rf apache-zookeeper-*/ |
| 53 |
rm -rf zookeeper-*/ |
| 54 |
rm -f zookeeper |
| 55 |
rm -f profile.cov |