-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
Makefile
229 lines (189 loc) · 6.36 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
# Copyright (c) 2023 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0
SHELL := /bin/bash
JAEGER_IMPORT_PATH = github.com/jaegertracing/jaeger
# PLATFORMS is a list of all supported platforms
PLATFORMS="linux/amd64,linux/arm64,linux/s390x,linux/ppc64le,darwin/amd64,darwin/arm64,windows/amd64"
LINUX_PLATFORMS=$(shell echo "$(PLATFORMS)" | tr ',' '\n' | grep linux | tr '\n' ',' | sed 's/,$$/\n/')
# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)
ifeq ($(DEBUG_BINARY),)
DISABLE_OPTIMIZATIONS =
SUFFIX =
TARGET = release
else
DISABLE_OPTIMIZATIONS = -gcflags="all=-N -l"
SUFFIX = -debug
TARGET = debug
endif
# All .go files that are not auto-generated and should be auto-formatted and linted.
ALL_SRC = $(shell find . -name '*.go' \
-not -name '_*' \
-not -name '.*' \
-not -name 'mocks*' \
-not -name '*.pb.go' \
-not -path './vendor/*' \
-not -path './internal/tools/*' \
-not -path './docker/debug/*' \
-not -path '*/mocks/*' \
-not -path '*/*-gen/*' \
-not -path '*/thrift-0.9.2/*' \
-type f | \
sort)
# All .sh or .py or Makefile or .mk files that should be auto-formatted and linted.
SCRIPTS_SRC = $(shell find . \( -name '*.sh' -o -name '*.py' -o -name '*.mk' -o -name 'Makefile*' -o -name 'Dockerfile*' \) \
-not -path './.git/*' \
-not -path './idl/*' \
-not -path './jaeger-ui/*' \
-type f | \
sort)
# ALL_PKGS is used with 'nocover' and 'goleak'
ALL_PKGS = $(shell echo $(dir $(ALL_SRC)) | tr ' ' '\n' | sort -u)
UNAME := $(shell uname -m)
ifeq ($(UNAME), s390x)
# go test does not support -race flag on s390x architecture
RACE=
else
RACE=-race
endif
# sed on Mac does not support the same syntax for in-place updates as sed on Linux
# When running on MacOS it's best to install gsed and run Makefile with SED=gsed
SED=sed
GO=go
GOOS ?= $(shell $(GO) env GOOS)
GOARCH ?= $(shell $(GO) env GOARCH)
GOTEST_QUIET=$(GO) test $(RACE)
GOTEST=$(GOTEST_QUIET) -v
COVEROUT=cover.out
GOFMT=gofmt
FMT_LOG=.fmt.log
IMPORT_LOG=.import.log
COLORIZE ?= | $(SED) 's/PASS/✅ PASS/g' | $(SED) 's/FAIL/❌ FAIL/g' | $(SED) 's/SKIP/🔕 SKIP/g'
# import other Makefiles after the variables are defined
include Makefile.BuildBinaries.mk
include Makefile.BuildInfo.mk
include Makefile.Crossdock.mk
include Makefile.Docker.mk
include Makefile.IntegrationTests.mk
include Makefile.Protobuf.mk
include Makefile.Thrift.mk
include Makefile.Tools.mk
include Makefile.Windows.mk
.DEFAULT_GOAL := test-and-lint
.PHONY: test-and-lint
test-and-lint: test fmt lint
.PHONY: echo-v1
echo-v1:
@echo "$(GIT_CLOSEST_TAG_V1)"
.PHONY: echo-v2
echo-v2:
@echo "$(GIT_CLOSEST_TAG_V2)"
.PHONY: echo-platforms
echo-platforms:
@echo "$(PLATFORMS)"
.PHONY: echo-linux-platforms
echo-linux-platforms:
@echo "$(LINUX_PLATFORMS)"
.PHONY: echo-all-pkgs
echo-all-pkgs:
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
.PHONY: echo-all-srcs
echo-all-srcs:
@echo $(ALL_SRC) | tr ' ' '\n' | sort
.PHONY: clean
clean:
rm -rf cover*.out .cover/ cover.html $(FMT_LOG) $(IMPORT_LOG) \
jaeger-ui/packages/jaeger-ui/build
find ./cmd/query/app/ui/actual -type f -name '*.gz' -delete
GOCACHE=$(GOCACHE) go clean -cache -testcache
bash scripts/clean-binaries.sh
.PHONY: test
test:
bash -c "set -e; set -o pipefail; $(GOTEST) -tags=memory_storage_integration ./... $(COLORIZE)"
.PHONY: cover
cover: nocover
bash -c "set -e; set -o pipefail; STORAGE=memory $(GOTEST) -timeout 5m -coverprofile $(COVEROUT) ./... | tee test-results.json"
go tool cover -html=cover.out -o cover.html
.PHONY: nocover
nocover:
@echo Verifying that all packages have test files to count in coverage
@scripts/check-test-files.sh $(ALL_PKGS)
.PHONY: fmt
fmt: $(GOFUMPT)
@echo Running import-order-cleanup on ALL_SRC ...
@./scripts/import-order-cleanup.py -o inplace -t $(ALL_SRC)
@echo Running gofmt on ALL_SRC ...
@$(GOFMT) -e -s -l -w $(ALL_SRC)
@echo Running gofumpt on ALL_SRC ...
@$(GOFUMPT) -e -l -w $(ALL_SRC)
@echo Running updateLicense.py on ALL_SRC ...
@./scripts/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC)
.PHONY: lint
lint: lint-license lint-imports lint-semconv lint-goversion lint-goleak lint-go
.PHONY: lint-license
lint-license:
@echo Verifying that all files have license headers
@./scripts/updateLicense.py $(ALL_SRC) $(SCRIPTS_SRC) > $(FMT_LOG)
@[ ! -s "$(FMT_LOG)" ] || (echo "License check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
.PHONY: lint-nocommit
lint-nocommit:
@if git diff origin/main | grep '@no''commit' ; then \
echo "❌ Cannot merge PR that contains @no""commit string" ; \
GIT_PAGER=cat git diff -G '@no''commit' origin/main ; \
false ; \
else \
echo "✅ Changes do not contain @no""commit string" ; \
fi
.PHONY: lint-imports
lint-imports:
@echo Verifying that all Go files have correctly ordered imports
@./scripts/import-order-cleanup.py -o stdout -t $(ALL_SRC) > $(IMPORT_LOG)
@[ ! -s "$(IMPORT_LOG)" ] || (echo "Import ordering failures, run 'make fmt'" | cat - $(IMPORT_LOG) && false)
.PHONY: lint-semconv
lint-semconv:
./scripts/check-semconv-version.sh
.PHONY: lint-goversion
lint-goversion:
./scripts/check-go-version.sh
.PHONY: lint-goleak
lint-goleak:
@echo Verifying that all packages with tests have goleak in their TestMain
@scripts/check-goleak-files.sh $(ALL_PKGS)
.PHONY: lint-go
lint-go: $(LINT)
$(LINT) -v run
.PHONY: run-all-in-one
run-all-in-one: build-ui
go run ./cmd/all-in-one --log-level debug
.PHONY: changelog
changelog:
./scripts/release-notes.py --exclude-dependabot --verbose
.PHONY: draft-release
draft-release:
./scripts/draft-release.py
.PHONY: test-ci
test-ci: GOTEST := $(GOTEST_QUIET)
test-ci: build-examples cover
.PHONY: init-submodules
init-submodules:
git submodule update --init --recursive
MOCKERY_FLAGS := --all --disable-version-string
.PHONY: generate-mocks
generate-mocks: $(MOCKERY)
$(MOCKERY)
.PHONY: certs
certs:
cd pkg/config/tlscfg/testdata && ./gen-certs.sh
.PHONY: certs-dryrun
certs-dryrun:
cd pkg/config/tlscfg/testdata && ./gen-certs.sh -d
.PHONY: repro-check
repro-check:
# Check local reproducibility of generated executables.
$(MAKE) clean
$(MAKE) build-all-platforms
# Generate checksum for all executables under ./cmd
find cmd -type f -executable -exec shasum -b -a 256 {} \; | sort -k2 | tee sha256sum.combined.txt
$(MAKE) clean
$(MAKE) build-all-platforms
shasum -b -a 256 --strict --check ./sha256sum.combined.txt