-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
59 lines (45 loc) · 1.61 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
SHELL=/bin/bash
CMD=elastic-etcd
GOBUILD=go build
REPOSITORY=sttts
VERSION=$(shell git describe --always --tags --dirty)
DOCKER_TAG=$$(grep "^FROM" Dockerfile | sed 's/.*etcd://')
default: all
all: check test build
.PHONY: $(CMD)
$(CMD):
$(GOBUILD) github.com/sttts/elastic-etcd/cmd/$@
build: $(CMD)
test:
for m in $$(go list ./... | grep -v /vendor/ | grep -v '/elastic-etcd$$'); do go test -v $$m -vmodule="*=6" --logtostderr; done
GFMT=find . -not \( \( -wholename "./vendor" \) -prune \) -name "*.go" | xargs gofmt -l
gofmt:
@UNFMT=$$($(GFMT)); if [ -n "$$UNFMT" ]; then echo "gofmt needed on" $$UNFMT && exit 1; fi
fix:
@UNFMT=$$($(GFMT)); if [ -n "$$UNFMT" ]; then echo "goimports -w" $$UNFMT; goimports -w $$UNFMT; fi
gometalinter:
gometalinter \
--vendor \
--cyclo-over=13 \
--tests \
--deadline=120s \
--dupl-threshold=53 \
--disable=gotype --disable=aligncheck --disable=unconvert --disable=structcheck --disable=interfacer --disable=deadcode --disable=gocyclo --disable=dupl \
./...
check: gofmt gometalinter
clean:
rm -f $(CMD) docker/elastic-etcd
.PHONY: release/elastic-etcd
release/elastic-etcd:
mkdir -p release
cd release && GOOS=linux go build github.com/sttts/elastic-etcd/cmd/elastic-etcd
.PHONY: release
release: release/elastic-etcd
go get github.com/aktau/github-release
github-release upload -u sttts --repo elastic-etcd --tag $(VERSION) --file release/elastic-etcd --name elastic-etcd
.PHONY: docker
docker: release/elastic-etcd
docker build -t $(REPOSITORY)/elastic-etcd:$(DOCKER_TAG) .
push: docker
docker push $(REPOSITORY)/elastic-etcd:$(DOCKER_TAG)
.PHONY: build test check