forked from evergreen-ci/cedar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
324 lines (297 loc) · 15.7 KB
/
makefile
File metadata and controls
324 lines (297 loc) · 15.7 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# start project configuration
name := cedar
buildDir := build
packages := $(name) rest rest-data rest-model units operations cost model depgraph perf rpc rpc-internal benchmarks
orgPath := github.com/evergreen-ci
projectPath := $(orgPath)/$(name)
# end project configuration
# start environment setup
ifneq (,$(GO_BIN_PATH))
gobin := $(GO_BIN_PATH)
else
gobin := $(shell if [ -x /opt/golang/go1.9/bin/go ]; then echo /opt/golang/go1.9/bin/go; fi)
ifeq (,$(gobin))
gobin := go
endif
endif
gocache := $(abspath $(buildDir)/.cache)
ifeq ($(OS),Windows_NT)
gocache := $(shell cygpath -m $(gocache))
gopath := $(shell cygpath -m $(gopath))
endif
gopath := $(GOPATH)
ifeq ($(OS),Windows_NT)
gopath := $(shell cygpath -m $(gopath))
gobin := $(shell cygpath -m $(gobin))
endif
goEnv := GOPATH=$(gopath) GOCACHE=$(gocache)$(if $(GO_BIN_PATH), PATH="$(shell dirname $(GO_BIN_PATH)):$(PATH)")
# end environment setup
# start lint setup targets
lintDeps := $(buildDir)/.lintSetup $(buildDir)/run-linter $(buildDir)/golangci-lint
$(buildDir)/.lintSetup:$(buildDir)/golangci-lint
@touch $@
$(buildDir)/golangci-lint:$(buildDir)
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/76a82c6ed19784036bbf2d4c84d0228ca12381a4/install.sh | sh -s -- -b $(buildDir) v1.23.8 >/dev/null 2>&1
$(buildDir)/run-linter:cmd/run-linter/run-linter.go $(buildDir)/.lintSetup $(buildDir)
@$(goEnv) $(gobin) build -o $@ $<
# end lint setup targets
# benchmark setup targets
$(buildDir)/run-benchmarks:cmd/run-benchmarks/run-benchmarks.go
@mkdir -p $(buildDir)
$(goEnv) $(gobin) build -o $@ $<
# end benchmark setup targets
# start dependency installation tools
# implementation details for being able to lazily install dependencies
distContents := $(buildDir)/$(name)
coverageOutput := $(foreach target,$(packages),$(buildDir)/output.$(target).coverage)
coverageHtmlOutput := $(foreach target,$(packages),$(buildDir)/output.$(target).coverage.html)
# end dependency installation tools
# implementation details for building the binary and creating a
# convienent link in the working directory
$(name):$(buildDir)/$(name)
@[ -e $@ ] || ln -s $<
$(buildDir)/$(name):
$(goEnv) $(gobin) build -ldflags "-w -X github.com/evergreen-ci/cedar.BuildRevision=`git rev-parse HEAD`" -o $@ cmd/$(name)/$(name).go
$(buildDir)/generate-points:cmd/generate-points/generate-points.go
$(goEnv) $(gobin) build -o $@ $<
generate-points:$(buildDir)/generate-points
./$<
$(buildDir)/make-tarball:cmd/make-tarball/make-tarball.go
@mkdir -p $(buildDir)
@$(goEnv) $(gobin) build -o $@ $<
# end dependency installation tools
# distribution targets and implementation
dist:$(buildDir)/dist.tar.gz
$(buildDir)/dist.tar.gz:$(buildDir)/make-tarball $(distContents)
./$< --name $@ --prefix $(name) $(foreach item,$(distContents),--item $(item)) --trim $(buildDir)
tar -tvf $@
# end deploy and distribution targets
# userfacing targets for basic build and development operations
proto:
@mkdir -p rpc/internal
protoc --go_out=plugins=grpc:rpc/internal *.proto
lint:$(foreach target,$(packages),$(buildDir)/output.$(target).lint)
test:build $(buildDir)/output.test
build:$(buildDir)/$(name)
.PHONY: benchmark
benchmark:$(buildDir)/run-benchmarks $(buildDir)/ .FORCE
./$(buildDir)/run-benchmarks $(run-benchmark)
coverage:build $(coverageOutput)
coverage-html:build $(coverageHtmlOutput)
list-tests:
@echo -e "test targets:" $(foreach target,$(packages),\\n\\ttest-$(target))
phony += lint lint-deps build build-race race test coverage coverage-html list-race list-tests
.PRECIOUS:$(coverageOutput) $(coverageHtmlOutput)
.PRECIOUS:$(foreach target,$(packages),$(buildDir)/output.$(target).test)
.PRECIOUS:$(foreach target,$(packages),$(buildDir)/output.$(target).lint)
.PRECIOUS:$(buildDir)/output.lint
# end front-ends
# start vendoring configuration
# begin with configuration of dependencies
vendor-clean:
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/github.com/evergreen-ci/gimlet/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/github.com/jpillora/backoff/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/github.com/stretchr/testify/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/google.golang.org/grpc/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/github.com/mongodb/anser/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/github.com/stretchr/testify/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/go.mongodb.org/mongo-driver/
rm -rf vendor/github.com/evergreen-ci/certdepot/vendor/gopkg.in/mgo.v2/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/github.com/davecgh/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/github.com/pmezard/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/github.com/stretchr/
rm -rf vendor/github.com/evergreen-ci/gimlet/vendor/gopkg.in/yaml.v2/
rm -rf vendor/github.com/evergreen-ci/pail/vendor/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/evergreen-ci/pail/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/golang/protobuf/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/mongodb/amboy/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/mongodb/ftdc/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/papertrail/go-tail/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/github.com/stretchr/testify/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/golang.org/x/net/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/golang.org/x/sys/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/golang.org/x/text/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/google.golang.org/genproto/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/google.golang.org/grpc/
rm -rf vendor/github.com/evergreen-ci/poplar/vendor/gopkg.in/yaml.v2/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/github.com/evergreen-ci/aviation/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/github.com/golang/protobuf/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/github.com/stretchr/testify/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/golang.org/x/net/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/golang.org/x/sys/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/golang.org/x/text/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/google.golang.org/genproto/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/google.golang.org/grpc/
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/aws/aws-sdk-go
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/davecgh/go-spew
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/evergreen-ci/gimlet
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/mongodb/mongo-go-driver
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/stretchr/testify
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/tychoish/gimlet/
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/urfave/cli/
rm -rf vendor/github.com/mongodb/amboy/vendor/go.mongodb.org/mongo-driver
rm -rf vendor/github.com/mongodb/amboy/vendor/golang.org/x/net/
rm -rf vendor/github.com/mongodb/amboy/vendor/gonum.org/v1/gonum
rm -rf vendor/github.com/mongodb/amboy/vendor/gopkg.in/mgo.v2
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/evergreen-ci/birch
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/mongodb/amboy
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/mongodb/ftdc
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/mongodb/grip
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/tychoish/tarjan
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/satori/go.uuid
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/pkg/errors
rm -rf vendor/github.com/mongodb/anser/vendor/github.com/stretchr
rm -rf vendor/github.com/mongodb/anser/vendor/go.mongodb.org/mongo-driver
rm -rf vendor/github.com/mongodb/anser/vendor/gopkg.in/mgo.v2
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/mongodb/grip/
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/mongodb/mongo-go-driver/
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/satori/go.uuid/
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/satori/go.uuid/gss
rm -rf vendor/github.com/mongodb/ftdc/vendor/github.com/stretchr/testify
rm -rf vendor/github.com/mongodb/ftdc/vendor/go.mongodb.org/mongo-driver/
rm -rf vendor/github.com/mongodb/ftdc/vendor/gopkg.in/
rm -rf vendor/github.com/mongodb/grip/vendor/github.com/davecgh/go-spew/
rm -rf vendor/github.com/mongodb/grip/vendor/github.com/pkg/
rm -rf vendor/github.com/mongodb/grip/vendor/github.com/pmezard/go-difflib/
rm -rf vendor/github.com/mongodb/grip/vendor/github.com/stretchr/
rm -rf vendor/github.com/mongodb/grip/vendor/golang.org/x/net/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/aviation/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/gimlet
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/golang/protobuf
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/mongodb/amboy
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/mongodb/ftdc/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/mongodb/grip
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/pkg/errors/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/satori/go.uuid
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/stretchr/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/urfave/cli
rm -rf vendor/github.com/mongodb/jasper/vendor/golang.org/x/net/
rm -rf vendor/github.com/mongodb/jasper/vendor/golang.org/x/sys/
rm -rf vendor/github.com/mongodb/jasper/vendor/golang.org/x/text/
rm -rf vendor/github.com/mongodb/jasper/vendor/google.golang.org/genproto/
rm -rf vendor/github.com/mongodb/jasper/vendor/google.golang.org/grpc/
rm -rf vendor/github.com/rs/cors/examples/
rm -rf vendor/github.com/rs/cors/wrapper
rm -rf vendor/github.com/stretchr/testify/vendor/
rm -rf vendor/go.mongodb.org/mongo-driver/data/
rm -rf vendor/go.mongodb.org/mongo-driver/vendor/github.com/davecgh/go-spew/
rm -rf vendor/go.mongodb.org/mongo-driver/vendor/github.com/stretchr/
rm -rf vendor/go.mongodb.org/mongo-driver/vendor/golang.org/x/net
rm -rf vendor/go.mongodb.org/mongo-driver/vendor/golang.org/x/text
rm -rf vendor/go.mongodb.org/mongo-driver/vendor/gopkg.in/yaml.v2/
rm -rf vendor/gopkg.in/mgo.v2/harness/
rm -rf vendor/github.com/mongodb/grip/vendor/github.com/google/uuid/
rm -rf vendor/github.com/mongodb/amboy/vendor/github.com/google/uuid
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/google/uuid/
rm -rf vendor/github.com/mongodb/jasper/vendor/gopkg.in/mgo.v2
rm -rf vendor/github.com/mongodb/jasper/vendor/go.mongodb.org/mongo-driver
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/birch/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/aviation/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/certdepot/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/timber/
rm -rf vendor/github.com/mongodb/jasper/vendor/github.com/evergreen-ci/poplar/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/go.mongodb.org/mongo-driver/
rm -rf vendor/github.com/evergreen-ci/timber/vendor/gopkg.in/yaml.v2/
rm -rf vendor/github.com/evergreen-ci/aviation/vendor/google.golang.org/grpc/
find vendor/ -name "*.gif" -o -name "*.gz" -o -name "*.png" -o -name "*.ico" -o -name "*testdata*" | xargs rm -rf
phony += vendor-clean
# end vendoring tooling configuration
# convenience targets for runing tests and coverage tasks on a
# specific package.
test-%:$(buildDir)/output.%.test
@grep -s -q -e "^PASS" $<
coverage-%:$(buildDir)/output.%.coverage
@grep -s -q -e "^PASS" $(buildDir)/output.$*.test
html-coverage-%:$(buildDir)/output.%.coverage.html
@grep -s -q -e "^PASS" $(buildDir)/output.$*.test
lint-%:$(buildDir)/output.%.lint
@grep -v -s -q "^--- FAIL" $<
# end convienence targets
# start test and coverage artifacts
# This varable includes everything that the tests actually need to
# run. (The "build" target is intentional and makes these targetsb
# rerun as expected.)
testTimeout := -timeout=20m
testArgs := -v $(testTimeout)
ifneq (,$(RUN_TEST))
testArgs += -run='$(RUN_TEST)'
endif
ifneq (,$(RUN_COUNT))
testArgs += -count=$(RUN_COUNT)
endif
ifneq (,$(SKIP_LONG))
testArgs += -short
endif
ifeq (,$(DISABLE_COVERAGE))
testArgs += -cover
endif
ifneq (,$(RACE_DETECTOR))
testArgs += -race
endif
# extra dependencies
# test execution and output handlers
$(buildDir)/:
mkdir -p $@
$(buildDir)/output.%.test:$(buildDir)/ .FORCE
$(goEnv) $(gobin) test $(testArgs) ./$(if $(subst $(name),,$*),$(subst -,/,$*),) | tee $@
@! grep -s -q -e "^FAIL" $@ && ! grep -s -q "^WARNING: DATA RACE" $@
$(buildDir)/output.test:$(buildDir)/ .FORCE
$(goEnv) $(gobin) test $(testArgs) ./... | tee $@
@! grep -s -q -e "^FAIL" $@ && ! grep -s -q "^WARNING: DATA RACE" $@
$(buildDir)/output.%.coverage:$(buildDir)/ .FORCE
$(goEnv) $(gobin) test $(testArgs) ./$(if $(subst $(name),,$*),$(subst -,/,$*),) -covermode=count -coverprofile $@ | tee $(buildDir)/output.$*.test
-[ -f $@ ] && $(goEnv) $(gobin) tool cover -func=$@ | sed 's%$(projectPath)/%%' | column -t
$(buildDir)/output.%.coverage.html:$(buildDir)/output.%.coverage
$(goEnv) $(gobin) tool cover -html=$< -o $@
# targets to generate gotest output from the linter.
$(buildDir)/output.%.lint:$(buildDir)/run-linter $(buildDir)/ .FORCE
@$(goEnv) ./$< --output=$@ --lintBin=$(buildDir)/golangci-lint --packages='$*'
$(buildDir)/output.lint:$(buildDir)/run-linter $(buildDir)/ .FORCE
@$(goEnv) ./$< --output=$@ --lintBin=$(buildDir)/golangci-lint --packages='$(packages)'
# targets to process and generate coverage reports
# end test and coverage artifacts
# mongodb utility targets
ifeq ($(OS),Windows_NT)
decompress := 7z.exe x
else
decompress := tar -zxvf
endif
mongodb/.get-mongodb:
rm -rf mongodb
mkdir -p mongodb
cd mongodb && curl "$(MONGODB_URL)" -o mongodb.tgz && $(decompress) mongodb.tgz && chmod +x ./mongodb-*/bin/*
cd mongodb && mv ./mongodb-*/bin/* . && rm -rf db_files && rm -rf db_logs && mkdir -p db_files && mkdir -p db_logs
get-mongodb:mongodb/.get-mongodb
@touch $<
start-mongod:mongodb/.get-mongodb
./mongodb/mongod --dbpath ./mongodb/db_files --port 27017 --replSet evg --smallfiles --oplogSize 10
@echo "waiting for mongod to start up"
init-rs:mongodb/.get-mongodb
./mongodb/mongo --eval 'rs.initiate()'
check-mongod:mongodb/.get-mongodb
./mongodb/mongo --nodb --eval "assert.soon(function(x){try{var d = new Mongo(\"localhost:27017\"); return true}catch(e){return false}}, \"timed out connecting\")"
@echo "mongod is up"
# end mongodb targets
# clean and other utility targets
clean:
rm -f *.pb.go
rm -rf $(lintDeps) $(buildDir)/coverage.* $(name) $(buildDir)/$(name)
clean-results:
rm -rf $(buildDir)/output.*
phony += clean
# end dependency targets
# configure phony targets
.FORCE:
.PHONY:$(phony) .FORCE