-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
139 lines (111 loc) · 3.6 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
REPO = github.com/akaspin/soil
BIN = soil
TESTS = .
TEST_TAGS =
TEST_ARGS =
BENCH = .
TEST_PACKAGES ?= ./...
GO_IMAGE = golang:1.9.2
CWD = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
V = $(shell git describe --always --tags --dirty)
GOOPTS = -installsuffix cgo -ldflags '-s -w -X $(REPO)/proto.Version=$(V)'
GOBIN ?= $(GOPATH)/bin
sources: ## go fmt and vet
go fmt ./...
go vet ./...
deps: ## update vendor
dep ensure -v
###
### Test
###
test: test-unit test-cluster test-systemd ## run all tests
clean-test: clean-test-systemd ## clean test artifacts
-find . -name ".test_*" -exec rm -rf {} \;
-find /tmp -name ".test_*" -exec rm -rf {} \;
test-unit: ## run unit tests
go test -race -run=$(TESTS) $(TEST_ARGS) -tags="test_unit $(TEST_TAGS)" $(TEST_PACKAGES)
test-cluster:
go test -race -run=$(TESTS) -p=1 $(TEST_ARGS) -tags="test_cluster $(TEST_TAGS)" $(TEST_PACKAGES)
test-systemd: testdata/systemd/.vagrant-ok ## run SystemD tests
docker -H 127.0.0.1:2475 run --net=host --rm --name=test \
-v /run/soil:/run/soil \
-v /var/lib/soil:/var/lib/soil \
-v /run/systemd/system:/run/systemd/system \
-v /etc/systemd/system:/etc/systemd/system \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /vagrant:/go/src/github.com/akaspin/soil \
-v /tmp:/tmp \
$(GO_IMAGE) go test -race -run=$(TESTS) -p=1 $(TEST_ARGS) -tags="test_systemd $(TEST_TAGS)" $(TEST_PACKAGES)
testdata/systemd/.vagrant-ok: testdata/systemd/Vagrantfile
cd testdata/systemd && vagrant up --parallel
touch testdata/systemd/.vagrant-ok
clean-test-systemd: ## clean Systemd tests artifacts
-cd testdata/systemd && vagrant destroy -f
-rm -rf testdata/systemd/.vagrant*
coverage: testdata/systemd/.vagrant-ok ## run SystemD tests
docker -H 127.0.0.1:2475 run --net=host --rm --name=test \
-v /run/soil:/run/soil \
-v /var/lib/soil:/var/lib/soil \
-v /run/systemd/system:/run/systemd/system \
-v /etc/systemd/system:/etc/systemd/system \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /vagrant:/go/src/github.com/akaspin/soil \
-v /tmp:/tmp \
--workdir /go/src/github.com/akaspin/soil \
$(GO_IMAGE) ./testdata/ci/run-coverage.sh
###
### Dist
###
#dist: \
# dist/$(BIN)-$(V)-darwin-amd64.tar.gz \
# dist/$(BIN)-$(V)-linux-amd64.tar.gz
#
#dist/$(BIN)-$(V)-%-amd64.tar.gz: dist/%/$(BIN) dist/%/$(BIN)-debug
# tar -czf $@ -C ${<D} $(notdir $^)
#
#dist/%/$(BIN): $(SRC) $(ALL_SRC)
# @mkdir -p $(@D)
# GOPATH=$(GOPATH) CGO_ENABLED=0 GOOS=$* go build $(GOOPTS) -o $@ $(REPO)/command/$(BIN)
#
#dist/%/$(BIN)-debug: $(SRC) $(ALL_SRC)
# @mkdir -p $(@D)
# GOPATH=$(GOPATH) CGO_ENABLED=0 GOOS=$* go build $(GOOPTS) -tags debug -o $@ $(REPO)/command/$(BIN)
#
#docker-image: dist/$(BIN)-$(V)-linux-amd64.tar.gz
# docker build --build-arg V=$(V) -t soil-local:$(V) -f Dockerfile.local .
#
#clean-dist:
# rm -rf dist
###
### Install
###
#install: $(GOBIN)/$(BIN)
#install-debug: $(GOBIN)/$(BIN)-debug
#
#$(GOBIN)/$(BIN): $(SRC) $(ALL_SRC)
# GOPATH=$(GOPATH) CGO_ENABLED=0 go build $(GOOPTS) -o $@ $(REPO)/command/$(BIN)
#
#$(GOBIN)/$(BIN)-debug: $(SRC) $(ALL_SRC)
# GOPATH=$(GOPATH) CGO_ENABLED=0 go build $(GOOPTS) -tags debug -o $@ $(REPO)/command/$(BIN)
#
#uninstall:
# rm -rf $(GOBIN)/$(BIN)
# rm -rf $(GOBIN)/$(BIN)-debug
###
### clean
###
clean: clean-docs clean-test
###
### docs
###
docs:
docker run --rm -v $(CWD)/docs:/site -p 4000:4000 andredumas/github-pages serve --watch
clean-docs:
rm -rf docs/_site
.PHONY: \
docs \
test test-unit \
test-systemd \
clean