forked from Netflix/titus-executor
/
Makefile
144 lines (107 loc) · 3.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
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
# Builds the Titus Executor
export
# variables for order-only dependencies
include hack/make/dependencies.mk
# configuration for docker run
include hack/make/docker.mk
# configuration for gometalinter
include hack/make/lint.mk
SHELL := /usr/bin/env bash -eu -o pipefail
GO_PKG := github.com/Netflix/titus-executor
LOCAL_DIRS = $(shell govendor list -p -no-status +local)
TEST_FLAGS ?= -v -parallel 32
TEST_OUTPUT ?= test.xml
TEST_DOCKER_OUTPUT ?= test-standalone-docker.xml
SHORT_CIRCUIT_QUITELITE := true
.PHONY: all
all: validate-docker test build
.PHONY: clean
clean:
go clean || true
rm -rf build/
rm -f $(TEST_OUTPUT) $(TEST_DOCKER_OUTPUT)
.PHONY: tini/src
tini/src:
git submodule update --init --recursive
.PHONY: build
build: tini/src | $(clean) $(builder)
mkdir -p $(PWD)/build/distributions
$(DOCKER_RUN) -v $(PWD):$(PWD) -u $(UID):$(GID) \
-e "BUILD_HOST=$(JENKINS_URL)" -e "BUILD_JOB=$(JOB_NAME)" -e BUILD_NUMBER -e BUILD_ID -e ITERATION -e BUILDKITE_BRANCH \
-e ENABLE_DEV -e GOPATH \
titusoss/titus-executor-builder
.PHONY: build-standalone
build-standalone: tini/src
hack/builder/titus-executor-builder.sh
.PHONY: test
test: test-local test-standalone
.PHONY: build-tests-darwin
build-tests-darwin: govendor | $(clean)
$(eval TESTS_BUILD_DIR:=$(shell mktemp -d -t "build-tests.XXXXXX"))
for p in $$(govendor list -no-status +local); do \
GOOS="darwin" govendor test -c $$p -o $(TESTS_BUILD_DIR)/$$p.test; \
done
$(RM) -r "$(TESTS_BUILD_DIR)"
.PHONY: test-local
test-local: govendor | $(clean)
govendor test $(TEST_FLAGS) -covermode=count -coverprofile=coverage-local.out -coverpkg=github.com/Netflix/... +local \
| tee /dev/stderr > test-local.log
# run standalone tests against the docker container runtime
.PHONY: test-standalone
test-standalone: titus-agent | $(clean) $(builder)
./hack/tests-with-dind.sh
## Source code
.PHONY: validate
validate: metalinter
.PHONY: validate-docker
validate-docker: | $(builder)
$(DOCKER_RUN) -v $(PWD):$(PWD) -e GOPATH -w $(PWD) titusoss/titus-executor-builder make -j validate
.PHONY: fmt
fmt: goimports govendor
govendor fmt +local
goimports -w $(LOCAL_DIRS)
.PHONY: metalinter
metalinter: testdeps
ifdef FAST
$(GOMETALINTER) $(shell git diff origin/master --name-only --diff-filter=AM | grep 'go$$' | egrep -v '(^|/)vendor/' | /usr/bin/xargs -L1 dirname|sort|uniq) \
| tee $(LINTER_OUTPUT)
else
$(GOMETALINTER) $(LOCAL_DIRS) | tee $(LINTER_OUTPUT)
endif
## Support docker images
.PHONY: builder
builder:
@echo '---> Building titusoss/titus-executor-builder'
$(DOCKER) build -t titusoss/titus-executor-builder hack/builder
.PHONY: push-builder
push-builder: builder
$(DOCKER) push titusoss/titus-executor-builder
.PHONY: titus-agent
titus-agent: build
@echo '---> Building Titus Agent Docker-in-Docker image'
@$(DOCKER_BUILD) -t titusoss/titus-agent -f hack/agent/Dockerfile .
.PHONY: push-titus-agent
push-titus-agent: titus-agent
$(DOCKER) push titusoss/titus-agent
## Protobuf and source code generation
PROTOS := vendor/github.com/Netflix/titus-api-definitions/src/main/proto/netflix/titus/titus_base.proto vendor/github.com/Netflix/titus-api-definitions/src/main/proto/netflix/titus/titus_agent_api.proto vendor/github.com/Netflix/titus-api-definitions/src/main/proto/netflix/titus/agent.proto
.PHONY: protogen
protogen: $(PROTOS) | $(clean) $(clean-proto-defs)
mkdir -p api
protoc -Ivendor/github.com/Netflix/titus-api-definitions/src/main/proto/ --go_out=api/ $(PROTOS)
.PHONY: clean-proto-defs
clean-proto-defs: | $(clean)
rm -rf api/netflix/titus
## Binary dependencies
.PHONY: goimports
goimports:
go get golang.org/x/tools/cmd/goimports
.PHONY: govendor
govendor:
go get github.com/kardianos/govendor
.PHONY: gometalinter
gometalinter:
go get github.com/alecthomas/gometalinter
.PHONY: testdeps
testdeps: govendor gometalinter
govendor install +local