forked from tsuru/tsuru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
123 lines (94 loc) · 3.38 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
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
# Copyright 2014 tsuru authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
define check-service
@if [ "$(shell nc -z localhost $2 1>&2 2> /dev/null; echo $$?)" != "0" ]; \
then \
echo "\nFATAL: Expected to find $1 running on port $2\n"; \
exit 1; \
fi
endef
define HG_ERROR
FATAL: you need mercurial (hg) to download tsuru dependencies.
Check INSTALL.md for details
endef
define GIT_ERROR
FATAL: you need git to download tsuru dependencies.
Check INSTALL.md for details
endef
define BZR_ERROR
FATAL: you need bazaar (bzr) to download tsuru dependencies.
Check INSTALL.md for details
endef
.PHONY: all check-path get hg git bzr get-test get-prod test race client
all: check-path get test
# It does not support GOPATH with multiple paths.
check-path:
ifndef GOPATH
@echo "FATAL: you must declare GOPATH environment variable, for more"
@echo " details, please check INSTALL.md file and/or"
@echo " http://golang.org/cmd/go/#GOPATH_environment_variable"
@exit 1
endif
ifneq ($(subst ~,$(HOME),$(GOPATH))/src/github.com/tsuru/tsuru, $(PWD))
@echo "FATAL: you must clone tsuru inside your GOPATH To do so,"
@echo " you can run go get github.com/tsuru/tsuru/..."
@echo " or clone it manually to the dir $(GOPATH)/src/github.com/tsuru/tsuru"
@exit 1
endif
@exit 0 # in case everything is ok, without this
# it says nothing to be done for check-path.
get: hg git bzr get-prod get-test godep
hg:
$(if $(shell hg), , $(error $(HG_ERROR)))
git:
$(if $(shell git), , $(error $(GIT_ERROR)))
bzr:
$(if $(shell bzr), , $(error $(BZR_ERROR)))
get-test:
@/bin/echo -n "Installing test dependencies... "
@go list -f '{{range .TestImports}}{{.}} {{end}}' ./... | tr ' ' '\n' |\
grep '^.*\..*/.*$$' | grep -v 'github.com/tsuru/tsuru' |\
sort | uniq | xargs go get -u -d >/tmp/.get-test 2>&1 || (cat /tmp/.get-test && exit 1)
@go list -f '{{range .XTestImports}}{{.}} {{end}}' ./... | tr ' ' '\n' |\
grep '^.*\..*/.*$$' | grep -v 'github.com/tsuru/tsuru' |\
sort | uniq | xargs go get -u -d >/tmp/.get-test 2>&1 || (cat /tmp/.get-test && exit 1)
@/bin/echo "ok"
@rm -f /tmp/.get-test
get-prod:
@/bin/echo -n "Installing production dependencies... "
@go get -u -d ./... 1>/tmp/.get-prod 2>&1 || (cat /tmp/.get-prod && exit 1)
@/bin/echo "ok"
@rm -f /tmp/.get-prod
godep:
go get github.com/tools/godep
godep restore ./...
godep go clean ./...
check-test-services:
$(call check-service,MongoDB,27017)
$(call check-service,Redis,6379)
$(call check-service,Beanstalk,11300)
_go_test:
@go clean ./...
@godep go test ./...
_tsr_dry:
@godep go build -o tsr ./cmd/tsr
@./tsr api --dry --config ./etc/tsuru.conf
@./tsr collector --dry --config ./etc/tsuru.conf
@rm -f tsr
_sh_tests:
@cmd/term/test.sh
@misc/test-hooks.bash
test: _go_test _tsr_dry _sh_tests
_travis_go_test:
go clean ./...
/bin/bash -ec 'for pkg in `go list ./...`; do go test -v $$pkg; done'
travis_test: _travis_go_test _tsr_dry _sh_tests
_install_deadcode: git
@go get github.com/remyoudompheng/go-misc/deadcode
deadcode: _install_deadcode
@go list ./... | sed -e 's;github.com/tsuru/tsuru/;;' | xargs deadcode
race:
@/bin/bash -ec 'for pkg in `go list ./...`; do go test -race -i $$pkg; go test -race $$pkg; done'
doc:
@cd docs && make html SPHINXOPTS="-N -W"