-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
90 lines (71 loc) · 1.87 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
include .env
BINARY := quack
VERSION := $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
RED := \033[31m
GREEN := \033[32m
NC := \033[0m
IMG ?= quay.io/pusher/quack
.NOTPARALLEL:
.PHONY: all
all: distclean test build
.PHONY: build
build: clean $(BINARY)
.PHONY: clean
clean:
rm -f $(BINARY)
.PHONY: distclean
distclean: clean
rm -rf vendor
rm -rf release
.PHONY: fmt
fmt:
$(GO) fmt ./cmd/... ./pkg/...
.PHONY: vet
vet: vendor
$(GO) vet ./cmd/... ./pkg/...
.PHONY: lint
lint: vendor
@ echo -e "$(GREEN)Linting code$(NC)"
$(LINTER) run --disable-all \
--exclude-use-default=false \
--enable=govet \
--enable=ineffassign \
--enable=deadcode \
--enable=golint \
--enable=goconst \
--enable=gofmt \
--enable=goimports \
--deadline=120s \
--tests ./...
@ echo
vendor:
@ echo -e "$(GREEN)Pulling dependencies$(NC)"
$(DEP) ensure -v --vendor-only
@ echo
.PHONY: test
test: vendor
@ echo -e "$(GREEN)Running test suite$(NC)"
$(GO) test ./...
@ echo
.PHONY: check
check: fmt lint vet test
.PHONY: build
build: clean $(BINARY)
$(BINARY): fmt vet
CGO_ENABLED=0 $(GO) build -o $(BINARY) github.com/pusher/quack/cmd/quack
.PHONY: docker-build
docker-build: check
docker build . -t ${IMG}:${VERSION}
@echo -e "$(GREEN)Built $(IMG):$(VERSION)$(NC)"
TAGS ?= latest
.PHONY: docker-tag
docker-tag: docker-build
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker tag ${IMG}:${VERSION} ${IMG}:$${tag}; echo -e "$(GREEN)Tagged $(IMG):$(VERSION) as $${tag}$(NC)"; done
PUSH_TAGS ?= ${VERSION}, latest
.PHONY: docker-push
docker-push: docker-build docker-tag
@IFS=","; tags=${PUSH_TAGS}; for tag in $${tags}; do docker push ${IMG}:$${tag}; echo -e "$(GREEN)Pushed $(IMG):$${tag}$(NC)"; done
TAGS ?= latest
.PHONY: docker-clean
docker-clean:
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker rmi -f ${IMG}:${VERSION} ${IMG}:$${tag}; done