forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.Common
91 lines (74 loc) · 2.65 KB
/
Makefile.Common
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
SHELL = /bin/bash
# ALL_PKGS is the list of all packages where ALL_SRC files reside.
ALL_PKGS := $(sort $(shell go list ./...))
# COVER_PKGS is the list of packages to include in the coverage
COVER_PKGS := $(shell go list ./... | tr "\n" ",")
GOTEST_OPT?= -race -timeout 120s
GOCMD?= go
GOTEST=$(GOCMD) test
GOOS := $(shell $(GOCMD) env GOOS)
GOARCH := $(shell $(GOCMD) env GOARCH)
TOOLS_MOD_DIR := $(PWD)/internal/tools
TOOLS_BIN_DIR := $(PWD)/.tools
TOOLS_MOD_REGEX := "\s+_\s+\".*\""
TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"" | grep -vE '/v[0-9]+$$')
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES))))
CHLOGGEN_CONFIG := .chloggen/config.yaml
ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense
APIDIFF := $(TOOLS_BIN_DIR)/apidiff
CHECKFILE := $(TOOLS_BIN_DIR)/checkfile
CHLOGGEN := $(TOOLS_BIN_DIR)/chloggen
CROSSLINK := $(TOOLS_BIN_DIR)/crosslink
ENVSUBST := $(TOOLS_BIN_DIR)/envsubst
GOIMPORTS := $(TOOLS_BIN_DIR)/goimports
GOJSONSCHEMA := $(TOOLS_BIN_DIR)/gojsonschema
GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
LINT := $(TOOLS_BIN_DIR)/golangci-lint
IMPI := $(TOOLS_BIN_DIR)/impi
MISSPELL := $(TOOLS_BIN_DIR)/misspell
MULTIMOD := $(TOOLS_BIN_DIR)/multimod
PORTO := $(TOOLS_BIN_DIR)/porto
SEMCONVGEN := $(TOOLS_BIN_DIR)/semconvgen
SEMCONVKIT := $(TOOLS_BIN_DIR)/semconvkit
YQ := $(TOOLS_BIN_DIR)/yq
.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES) $(YQ)
$(TOOLS_BIN_DIR):
mkdir -p $@
$(TOOLS_BIN_NAMES): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && $(GOCMD) build -o $@ -trimpath $(filter %/$(notdir $@),$(TOOLS_PKG_NAMES))
$(YQ): $(TOOLS_BIN_DIR) $(TOOLS_MOD_DIR)/go.mod
cd $(TOOLS_MOD_DIR) && $(GOCMD) build -o $@ -trimpath github.com/mikefarah/yq/v4
.PHONY: test
test:
$(GOTEST) $(GOTEST_OPT) ./...
.PHONY: test-with-cover
test-with-cover: $(GO_ACC)
mkdir -p $(PWD)/coverage/unit
$(GOTEST) $(GOTEST_OPT) -cover ./... -covermode=atomic -coverpkg $(COVER_PKGS) -args -test.gocoverdir="$(PWD)/coverage/unit"
.PHONY: benchmark
benchmark:
$(GOTEST) -bench=. -run=notests ./... | tee benchmark.txt
.PHONY: fmt
fmt: $(GOIMPORTS)
gofmt -w -s ./
$(GOIMPORTS) -w -local go.opentelemetry.io/collector ./
.PHONY: tidy
tidy:
rm -fr go.sum
$(GOCMD) mod tidy -compat=1.20
.PHONY: lint
lint: $(LINT)
$(LINT) run
.PHONY: govulncheck
govulncheck: $(GOVULNCHECK)
$(GOVULNCHECK) ./...
.PHONY: generate
generate:
$(GOCMD) generate ./...
.PHONY: impi
impi: $(IMPI)
@$(IMPI) --local go.opentelemetry.io/collector --scheme stdThirdPartyLocal ./...
.PHONY: moddownload
moddownload:
$(GOCMD) mod download