-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (107 loc) · 3.33 KB
/
Copy pathMakefile
File metadata and controls
126 lines (107 loc) · 3.33 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
################################################################################
# Go build details #
################################################################################
BASE_PACKAGE_NAME := github.com/deis/async
################################################################################
# Containerized development environment #
################################################################################
DEV_IMAGE := quay.io/deis/lightweight-docker-go:v0.2.0
DOCKER_CMD_BASE := docker run \
--rm \
-v $$(pwd):/go/src/$(BASE_PACKAGE_NAME) \
-w /go/src/$(BASE_PACKAGE_NAME)
DOCKER_CMD := $(DOCKER_CMD_BASE) $(DEV_IMAGE)
DOCKER_CMD_INT := $(DOCKER_CMD_BASE) -it $(DEV_IMAGE)
################################################################################
# Utility targets #
################################################################################
# Destroys any running Docker compose containers
.PHONY: clean
clean:
ifndef SKIP_DOCKER
docker-compose down --rmi local &> /dev/null
endif
# Allow developers to step into the containerized development environment--
# unconditionally requires docker
.PHONY: dev
dev:
$(DOCKER_CMD_INT) bash
DEP_CMD := dep ensure -v
# Install/update dependencies
.PHONY: dep
dep:
ifdef SKIP_DOCKER
$(DEP_CMD)
else
$(DOCKER_CMD) $(DEP_CMD)
endif
# Running the tests starts a containerized Redis (if it isn't already running).
# It's left running afterwards (to speed up the next execution). It remains
# running unless explicitly shut down. This is a convenience task for stopping
# it.s
.PHONY: stop-test-redis
stop-test-redis:
docker-compose kill test-redis
docker-compose rm -f test-redis
################################################################################
# Tests #
################################################################################
VERIFY_CMD := bash -c ' \
PRJ_DIR=$$(pwd) \
&& cp -r --parent -L $$PRJ_DIR /tmp \
&& cd /tmp$$PRJ_DIR \
&& GOPATH=/tmp$$GOPATH dep ensure -v \
&& diff $$PRJ_DIR/Gopkg.lock Gopkg.lock \
&& diff -r $$PRJ_DIR/vendor vendor'
# Verifies there are no disrepancies between desired dependencies and the
# tracked, vendored dependencies
.PHONY: verify-vendored-code
verify-vendored-code:
ifdef SKIP_DOCKER
$(VERIFY_CMD)
else
$(DOCKER_CMD) $(VERIFY_CMD)
endif
# As of Go 1.9.0, testing ./... excludes tests on vendored code
TEST_CMD := go test ./...
# Executes tests
.PHONY: test
test:
ifdef SKIP_DOCKER
$(TEST_CMD)
else
docker-compose run --rm test $(TEST_CMD)
endif
LINT_CMD := gometalinter ./... \
--concurrency=1 \
--disable-all \
--enable gofmt \
--enable vet \
--enable vetshadow \
--enable gotype \
--enable deadcode \
--enable golint \
--enable varcheck \
--enable structcheck \
--enable errcheck \
--enable megacheck \
--enable ineffassign \
--enable interfacer \
--enable unconvert \
--enable goconst \
--enable gas \
--enable goimports \
--enable misspell \
--enable unparam \
--enable lll \
--line-length 80 \
--deadline 240s \
--vendor
# Executes an extensive series of lint checks against broker code
.PHONY: lint
lint:
ifdef SKIP_DOCKER
$(LINT_CMD)
else
$(DOCKER_CMD) $(LINT_CMD)
endif