forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (79 loc) · 2.51 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
include ./Makefile.Common
RUN_CONFIG=local/config.yaml
GIT_SHA=$(shell git rev-parse --short HEAD)
BUILD_INFO_IMPORT_PATH=github.com/open-telemetry/opentelemetry-collector-contrib/internal/version
BUILD_X1=-X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA)
ifdef VERSION
BUILD_X2=-X $(BUILD_INFO_IMPORT_PATH).Version=$(VERSION)
endif
BUILD_INFO=-ldflags "${BUILD_X1} ${BUILD_X2}"
.DEFAULT_GOAL := all
.PHONY: all
all: common otelcontribcol
.PHONY: e2e-test
e2e-test: otelcontribcol
$(MAKE) -C testbed runtests
.PHONY: ci
ci: all test-with-cover
$(MAKE) -C testbed install-tools
$(MAKE) -C testbed runtests
.PHONY: precommit
precommit:
$(MAKE) gotidy
$(MAKE) ci
.PHONY: test-with-cover
test-with-cover:
@echo Verifying that all packages have test files to count in coverage
@scripts/check-test-files.sh $(subst github.com/open-telemetry/opentelemetry-collector-contrib/,./,$(ALL_PKGS))
@echo pre-compiling tests
set -e; for dir in $(ALL_TEST_DIRS); do \
echo "go test ./... + coverage in $${dir}"; \
(cd "$${dir}" && \
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) ./... && \
go tool cover -html=coverage.txt -o coverage.html ); \
done
.PHONY: gotidy
gotidy:
go mod tidy
@set -e; for dir in $(ALL_TEST_DIRS); do \
(cd "$${dir}" && \
echo "tidying up $${dir}" && \
go mod tidy ); \
done
.PHONY: install-tools
install-tools:
GO111MODULE=on go install \
github.com/google/addlicense \
golang.org/x/lint/golint \
github.com/golangci/golangci-lint/cmd/golangci-lint \
golang.org/x/tools/cmd/goimports \
github.com/client9/misspell/cmd/misspell \
honnef.co/go/tools/cmd/staticcheck \
github.com/pavius/impi/cmd/impi
.PHONY: otelcontribcol
otelcontribcol:
GO111MODULE=on CGO_ENABLED=0 go build -o ./bin/$(GOOS)/otelcontribcol $(BUILD_INFO) ./cmd/otelcontribcol
.PHONY: run
run:
GO111MODULE=on go run --race ./cmd/otelcontribcol/... --config ${RUN_CONFIG}
.PHONY: docker-component # Not intended to be used directly
docker-component: check-component
GOOS=linux $(MAKE) $(COMPONENT)
cp ./bin/linux/$(COMPONENT) ./cmd/$(COMPONENT)/
docker build -t $(COMPONENT) ./cmd/$(COMPONENT)/
rm ./cmd/$(COMPONENT)/$(COMPONENT)
.PHONY: check-component
check-component:
ifndef COMPONENT
$(error COMPONENT variable was not defined)
endif
.PHONY: docker-otelcontribcol
docker-otelcontribcol:
COMPONENT=otelcontribcol $(MAKE) docker-component
.PHONY: binaries
binaries: otelcontribcol
.PHONY: binaries-all-sys
binaries-all-sys:
GOOS=darwin $(MAKE) binaries
GOOS=linux $(MAKE) binaries
GOOS=windows $(MAKE) binaries