forked from signalfx/signalfx-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
266 lines (219 loc) · 6.64 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
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
COLLECTD_VERSION := 5.8.0-sfx0
COLLECTD_COMMIT := 4da1c1cbbe83f881945088a41063fe86d1682ecb
BUILD_TIME ?= $$(date +%FT%T%z)
ifeq ($(OS),Windows_NT)
MONITOR_CODE_GEN := monitor-code-gen.exe
else
MONITOR_CODE_GEN := ./monitor-code-gen
endif
NUM_CORES ?= $(shell getconf _NPROCESSORS_ONLN)
.PHONY: clean
clean:
find internal -name "genmetadata.go" -delete
.PHONY: check
check: lint vet test
.PHONY: compileDeps
compileDeps: templates code-gen internal/core/common/constants/versions.go
.PHONY: code-gen
code-gen: $(MONITOR_CODE_GEN)
$(MONITOR_CODE_GEN)
$(MONITOR_CODE_GEN): $(wildcard cmd/monitorcodegen/*.go) cmd/monitorcodegen/genmetadata.tmpl
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 monitor-code-gen
else
go build -mod vendor -o $@ ./cmd/monitorcodegen
endif
.PHONY: test
test: compileDeps
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 test
else
bash -euo pipefail -c "CGO_ENABLED=0 go test -mod vendor -p $(NUM_CORES) ./... | grep -v '\[no test files\]'"
endif
.PHONY: vet
vet: compileDeps
# Only consider it a failure if issues are in non-test files
! CGO_ENABLED=0 go vet -mod vendor ./... 2>&1 | tee /dev/tty | grep '.go' | grep -v '_test.go'
.PHONY: vetall
vetall: compileDeps
CGO_ENABLED=0 go vet -mod vendor ./...
.PHONY: lint
lint:
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 lint
else
CGO_ENABLED=0 golint -set_exit_status ./cmd/... ./internal/...
endif
.PHONY: gofmt
gofmt:
CGO_ENABLED=0 go fmt ./...
templates:
ifneq ($(OS),Windows_NT)
scripts/make-templates
endif
.PHONY: image
image:
COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) ./scripts/build
.PHONY: vendor
vendor:
ifeq ($(OS), Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 vendor
else
go mod tidy && go mod vendor
endif
internal/core/common/constants/versions.go: FORCE
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 versions_go
else
AGENT_VERSION=$(AGENT_VERSION) COLLECTD_VERSION=$(COLLECTD_VERSION) BUILD_TIME=$(BUILD_TIME) scripts/make-versions
endif
signalfx-agent: compileDeps
echo "building SignalFx agent for operating system: $(GOOS)"
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 signalfx-agent $(AGENT_VERSION)
else
CGO_ENABLED=0 go build \
-mod vendor \
-o signalfx-agent \
./cmd/agent
endif
.PHONY: bundle
bundle:
ifeq ($(OS),Windows_NT)
powershell $(CURDIR)/scripts/windows/make.ps1 bundle $(COLLECTD_COMMIT)
else
BUILD_BUNDLE=true COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) scripts/build
endif
.PHONY: deb-package
deb-%-package:
COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) packaging/deb/build $*
.PHONY: rpm-package
rpm-%-package:
COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) packaging/rpm/build $*
.PHONY: dev-image
dev-image:
ifeq ($(OS),Windows_NT)
powershell -Command "& { . $(CURDIR)\scripts\windows\common.ps1; do_docker_build signalfx-agent-dev latest dev-extras }"
else
bash -ec "COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) && source scripts/common.sh && do_docker_build signalfx-agent-dev latest dev-extras"
endif
.PHONY: debug
debug:
dlv debug ./cmd/agent
ifdef dbus
dbus_run_flags = --privileged -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:ro
endif
ifneq ($(OS),Windows_NT)
extra_run_flags = -v /:/hostfs:ro -v /var/run/docker.sock:/var/run/docker.sock:ro -v /tmp/scratch:/tmp/scratch
docker_env = -e COLUMNS=`tput cols` -e LINES=`tput lines`
endif
.PHONY: run-dev-image
run-dev-image:
docker exec -it $(docker_env) signalfx-agent-dev /bin/bash -l -i || \
docker run --rm -it \
$(dbus_run_flags) $(extra_run_flags) \
--cap-add DAC_READ_SEARCH \
--cap-add SYS_PTRACE \
-p 6060:6060 \
-p 9080:9080 \
-p 8095:8095 \
--name signalfx-agent-dev \
-v $(CURDIR)/local-etc:/etc/signalfx \
-v $(CURDIR):/usr/src/signalfx-agent:delegated \
-v $(CURDIR)/collectd:/usr/src/collectd:delegated \
-v $(CURDIR)/tmp/pprof:/tmp/pprof \
signalfx-agent-dev /bin/bash
.PHONY: run-dev-image-commands
run-dev-image-commands:
docker exec -t $(docker_env) signalfx-agent-dev /bin/bash -c '$(RUN_DEV_COMMANDS)'
.PHONY: run-integration-tests
run-integration-tests: MARKERS ?= integration
run-integration-tests:
pytest \
-m "$(MARKERS)" \
-n auto \
--verbose \
--html=test_output/results.html \
--self-contained-html \
tests
.PHONY: run-k8s-tests
run-k8s-tests: MARKERS ?= (kubernetes or helm) and not collectd
run-k8s-tests: run-minikube push-minikube-agent
scripts/get-kubectl
pytest \
-m "$(MARKERS)" \
-n auto \
--verbose \
--html=test_output/k8s_results.html \
--self-contained-html \
tests
K8S_VERSION ?= latest
MINIKUBE_VERSION ?= $(shell scripts/determine-compatible-minikube.py $(K8S_VERSION))
.PHONY: run-minikube
run-minikube:
docker build \
-t minikube:$(MINIKUBE_VERSION) \
--build-arg 'MINIKUBE_VERSION=$(MINIKUBE_VERSION)' \
test-services/minikube
docker rm -fv minikube 2>/dev/null || true
docker run -d \
--name minikube \
--privileged \
-e K8S_VERSION=$(K8S_VERSION) \
-e TIMEOUT=$(MINIKUBE_TIMEOUT) \
-p 5000:5000 \
minikube:$(MINIKUBE_VERSION)
docker exec minikube start-minikube.sh
echo "Minikube is now running. Push up an agent image to localhost:5000/signalfx-agent:latest or run 'make push-minikube-agent'"
.PHONY: push-minikube-agent
push-minikube-agent:
PUSH_DOCKER_IMAGE=yes \
AGENT_IMAGE_NAME=localhost:5000/signalfx-agent \
AGENT_VERSION=latest \
SKIP_BUILD_PULL=yes \
$(MAKE) image
.PHONY: docs
docs:
bash -c "rm -f docs/{observers,monitors}/*"
scripts/docs/make-docs
.PHONY: stage-cache
stage-cache:
COLLECTD_VERSION=$(COLLECTD_VERSION) COLLECTD_COMMIT=$(COLLECTD_COMMIT) scripts/tag-and-push-targets
.PHONY: product-docs
product-docs:
scripts/docs/to-product-docs
.PHONY: integrations-repo
integrations-repo:
scripts/docs/to-integrations-repo
.PHONY: chef-%
chef-%:
$(MAKE) -C deployments/chef $*
.PHONY: puppet-%
puppet-%:
$(MAKE) -C deployments/puppet $*
.PHONY: collectd-version
collectd-version:
@echo ${COLLECTD_VERSION}
.PHONY: collectd-commit
collectd-commit:
@echo ${COLLECTD_COMMIT}
.PHONY: lint-pytest
lint-pytest:
scripts/lint-pytest
.PHONY: lint-python
lint-python:
scripts/lint-python
.PHONY: devstack
devstack:
scripts/make-devstack-image
.PHONY: run-devstack
run-devstack:
scripts/run-devstack-image
.PHONY: run-chef-tests
run-chef-tests:
pytest -v -n auto -m chef --html=test_output/chef_results.html --self-contained-html tests/deployments
.PHONY: check-links
check-links:
docker build -t check-links scripts/docs/check-links
docker run --rm -v $(CURDIR):/usr/src/signalfx-agent:ro check-links
FORCE: