forked from signalfx/signalfx-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
207 lines (170 loc) · 5.18 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
COLLECTD_VERSION := 5.8.0-sfx0
COLLECTD_COMMIT := 4da1c1cbbe83f881945088a41063fe86d1682ecb
BUILD_TIME ?= $$(date +%FT%T%z)
.PHONY: check
check: lint vet test
.PHONY: compileDeps
compileDeps: templates internal/core/common/constants/versions.go
.PHONY: test
test: compileDeps
ifeq ($(OS),Windows_NT)
powershell "& { . $(CURDIR)/scripts/windows/make.ps1; test }"
else
CGO_ENABLED=0 go test -mod vendor ./...
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
AGENT_VERSION=$(AGENT_VERSION) COLLECTD_VERSION=$(COLLECTD_VERSION) BUILD_TIME=$(BUILD_TIME) scripts/make-versions
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
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 \
$(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:cached \
-v $(CURDIR)/collectd:/usr/src/collectd:cached \
-v $(CURDIR)/tmp/pprof:/tmp/pprof \
signalfx-agent-dev /bin/bash
.PHONY: run-integration-tests
run-integration-tests: MARKERS ?= not packaging and not installer and not k8s and not windows_only and not deployment and not perf_test
run-integration-tests:
AGENT_BIN=/bundle/bin/signalfx-agent \
pytest \
-m "$(MARKERS)" \
-n auto \
--verbose \
--html=test_output/results.html \
--self-contained-html \
tests
.PHONY: run-k8s-tests
run-k8s-tests: MARKERS ?= (k8s or helm) and not collectd
run-k8s-tests:
pytest \
-m "$(MARKERS)" \
-n auto \
--verbose \
--exitfirst \
--html=test_output/k8s_results.html \
--self-contained-html \
tests || \
(docker ps | grep -q minikube && echo "minikube container is left running for debugging purposes"; return 1) && \
docker rm -fv minikube
.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
K8S_VERSION ?= latest
.PHONY: run-minikube
run-minikube:
python -c 'from tests.helpers.kubernetes.minikube import Minikube; mk = Minikube(); mk.deploy("$(K8S_VERSION)")' && \
docker exec -it $(docker_env) minikube /bin/bash
FORCE: