-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathGNUmakefile
More file actions
287 lines (238 loc) · 12 KB
/
GNUmakefile
File metadata and controls
287 lines (238 loc) · 12 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
.DEFAULT_GOAL := chainlink
COMMIT_SHA ?= $(shell git rev-parse HEAD)
VERSION = $(shell jq -r '.version' package.json)
VERSION_TAG ?= $(shell git describe --always)
GO_LDFLAGS := $(shell tools/bin/ldflags)
GOFLAGS = -ldflags "$(GO_LDFLAGS)"
GCFLAGS = -gcflags "$(GO_GCFLAGS)"
# Set to true to install private plugins (will require GitHub auth).
CL_INSTALL_PRIVATE_PLUGINS ?= false
CL_INSTALL_TESTING_PLUGINS ?= false
CL_IS_PROD_BUILD ?= true
# Output directory for loopinstall plugin manifests (set by caller)
CL_LOOPINSTALL_OUTPUT_DIR ?=
# Conditionally define arsguments for loopinstall based on CL_LOOPINSTALL_OUTPUT_DIR
LOOPINSTALL_PUBLIC_ARGS := $(if $(strip $(CL_LOOPINSTALL_OUTPUT_DIR)),--output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/public.json)
LOOPINSTALL_PRIVATE_ARGS := $(if $(strip $(CL_LOOPINSTALL_OUTPUT_DIR)),--output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/private.json)
LOOPINSTALL_TESTING_ARGS := $(if $(strip $(CL_LOOPINSTALL_OUTPUT_DIR)),--output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/testing.json)
GOLANGCI_LINT_VERSION = "v2.11.4"
.PHONY: install
install: install-chainlink-autoinstall ## Install chainlink and all its dependencies.
.PHONY: install-git-hooks
install-git-hooks: ## Install git hooks.
git config core.hooksPath .githooks
.PHONY: install-chainlink-autoinstall
install-chainlink-autoinstall: | gomod install-chainlink ## Autoinstall chainlink.
.PHONY: gomod
gomod: ## Ensure chainlink's go dependencies are installed.
@if [ -z "`which gencodec`" ]; then \
go install github.com/smartcontractkit/gencodec@latest; \
fi || true
go mod download
.PHONY: gomodtidy
gomodtidy: gomods ## Run go mod tidy on all modules.
gomods tidy
go run ./tools/plugout --update
.PHONY: tidy
tidy: gomodtidy ## Tidy all modules and add to git.
git add '**go.*' 'plugins/plugins.public.yaml'
.PHONY: docs
docs: ## Install and run pkgsite to view Go docs
go install golang.org/x/pkgsite/cmd/pkgsite@latest
# http://localhost:8080/pkg/github.com/smartcontractkit/chainlink/v2/
pkgsite
.PHONY: install-chainlink
install-chainlink: operator-ui ## Install the chainlink binary.
go install $(GCFLAGS) $(GOFLAGS) .
.PHONY: install-chainlink-dev
install-chainlink-dev: operator-ui ## Install the chainlink binary.
go install -tags dev $(GCFLAGS) $(GOFLAGS) .
.PHONY: install-chainlink-cover
install-chainlink-cover: operator-ui ## Install the chainlink binary with cover flag.
go install -cover $(GOFLAGS) .
.PHONY: chainlink
chainlink: ## Build the chainlink binary.
go build $(GOFLAGS) .
.PHONY: chainlink-dev
chainlink-dev: ## Build a dev build of chainlink binary.
go build -tags dev $(GOFLAGS) .
.PHONY: chainlink-test
chainlink-test: ## Build a test build of chainlink binary.
go build $(GOFLAGS) .
.PHONY: install-loopinstall
install-loopinstall:
go install github.com/smartcontractkit/chainlink-common/pkg/loop/cmd/loopinstall
.PHONY: install-plugins-public
install-plugins-public: ## Build & install public remote LOOPP binaries (plugins).
@if [ -n "$(CL_LOOPINSTALL_OUTPUT_DIR)" ]; then \
go tool loopinstall --concurrency 5 $(LOOPINSTALL_PUBLIC_ARGS) --output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/public.json ./plugins/plugins.public.yaml; \
else \
go tool loopinstall --concurrency 5 $(LOOPINSTALL_PUBLIC_ARGS) ./plugins/plugins.public.yaml; \
fi
.PHONY: install-plugins-private
install-plugins-private: ## Build & install private remote LOOPP binaries (plugins).
if [ -n "$(CL_LOOPINSTALL_OUTPUT_DIR)" ]; then \
GOPRIVATE=github.com/smartcontractkit/* go tool loopinstall --concurrency 5 $(LOOPINSTALL_PRIVATE_ARGS) --output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/private.json ./plugins/plugins.private.yaml; \
else \
GOPRIVATE=github.com/smartcontractkit/* go tool loopinstall --concurrency 5 $(LOOPINSTALL_PRIVATE_ARGS) ./plugins/plugins.private.yaml; \
fi
.PHONY: install-plugins-testing
install-plugins-testing: ## Build & install testing only LOOPP binaries (plugins).
if [ -n "$(CL_LOOPINSTALL_OUTPUT_DIR)" ]; then \
GOPRIVATE=github.com/smartcontractkit/* go tool loopinstall --concurrency 5 $(LOOPINSTALL_TESTING_ARGS) --output-installation-artifacts $(CL_LOOPINSTALL_OUTPUT_DIR)/testing.json ./plugins/plugins.testing.yaml; \
else \
GOPRIVATE=github.com/smartcontractkit/* go tool loopinstall --concurrency 5 $(LOOPINSTALL_TESTING_ARGS) ./plugins/plugins.testing.yaml; \
fi
.PHONY: install-plugins-local
install-plugins-local: ## Build & install local plugins
go install -ldflags="-s" \
./plugins/cmd/chainlink-evm \
./plugins/cmd/chainlink-medianpoc \
./plugins/cmd/chainlink-ocr3-capability \
./plugins/cmd/capabilities/log-event-trigger
.PHONY: make install-plugins
install-plugins: install-plugins-local install-plugins-public ## Build and install local and public plugins via loopinstall
.PHONY: docker ## Build the chainlink docker image
docker: DOCKER_TAG=develop
docker:
@if ([ "$(CL_INSTALL_PRIVATE_PLUGINS)" = "true" ] || [ "$(CL_INSTALL_TESTING_PLUGINS)" = "true" ]) && [ -z "$(GITHUB_TOKEN)" ]; then \
echo "Error: GITHUB_TOKEN environment variable is required when CL_INSTALL_PRIVATE_PLUGINS=true or CL_INSTALL_TESTING_PLUGINS=true"; \
exit 1; \
fi
$(eval PRIVATE_PLUGIN_ARGS := $(if $(and $(or $(filter true,$(CL_INSTALL_PRIVATE_PLUGINS)),$(filter true,$(CL_INSTALL_TESTING_PLUGINS))),$(GITHUB_TOKEN)),--secret id=GIT_AUTH_TOKEN$(comma)env=GITHUB_TOKEN))
docker buildx build \
--build-arg COMMIT_SHA=$(COMMIT_SHA) \
--build-arg VERSION_TAG=$(VERSION_TAG) \
--build-arg CL_AUTO_DOCKER_TAG=$(DOCKER_TAG) \
--build-arg CL_INSTALL_PRIVATE_PLUGINS=$(CL_INSTALL_PRIVATE_PLUGINS) \
--build-arg CL_IS_PROD_BUILD=$(CL_IS_PROD_BUILD) \
$(PRIVATE_PLUGIN_ARGS) \
-f core/chainlink.Dockerfile . \
-t chainlink:$(DOCKER_TAG) \
--load
.PHONY: docker-ccip ## Build the chainlink docker image
docker-ccip: DOCKER_TAG=latest
docker-ccip:
docker buildx build \
--build-arg COMMIT_SHA=$(COMMIT_SHA) \
--build-arg VERSION_TAG=$(VERSION_TAG) \
--build-arg CL_AUTO_DOCKER_TAG=$(DOCKER_TAG) \
-f core/chainlink.Dockerfile . -t chainlink-ccip:$(DOCKER_TAG)
docker buildx build \
--build-arg COMMIT_SHA=$(COMMIT_SHA) \
--build-arg VERSION_TAG=$(VERSION_TAG) \
-f ccip/ccip.Dockerfile .
# Define a comma variable for use in $(eval) (needed for the PRIVATE_PLUGIN_ARGS)
comma := ,
.PHONY: docker-plugins ## Build the EXPERIMENTAL chainlink-plugins docker image
docker-plugins: DOCKER_TAG=latest
docker-plugins:
@if ([ "$(CL_INSTALL_PRIVATE_PLUGINS)" = "true" ] || [ "$(CL_INSTALL_TESTING_PLUGINS)" = "true" ]) && [ -z "$(GITHUB_TOKEN)" ]; then \
echo "Error: GITHUB_TOKEN environment variable is required when CL_INSTALL_PRIVATE_PLUGINS=true or CL_INSTALL_TESTING_PLUGINS=true"; \
exit 1; \
fi
$(eval PRIVATE_PLUGIN_ARGS := $(if $(and $(or $(filter true,$(CL_INSTALL_PRIVATE_PLUGINS)),$(filter true,$(CL_INSTALL_TESTING_PLUGINS))),$(GITHUB_TOKEN)),--secret id=GIT_AUTH_TOKEN$(comma)env=GITHUB_TOKEN))
docker buildx build \
--build-arg COMMIT_SHA=$(COMMIT_SHA) \
--build-arg VERSION_TAG=$(VERSION_TAG) \
--build-arg CL_AUTO_DOCKER_TAG=$(DOCKER_TAG) \
--build-arg CL_INSTALL_TESTING_PLUGINS=$(CL_INSTALL_TESTING_PLUGINS) \
--build-arg CL_INSTALL_PRIVATE_PLUGINS=$(CL_INSTALL_PRIVATE_PLUGINS) \
$(PRIVATE_PLUGIN_ARGS) \
-f plugins/chainlink.Dockerfile . \
-t chainlink-plugins:$(DOCKER_TAG)
.PHONY: operator-ui
operator-ui: ## Fetch the frontend
go run operator_ui/install.go .
.PHONY: generate
generate: codecgen mockery protoc gomods modgraph ## Execute all go:generate commands.
## Updating PATH makes sure that go:generate uses the version of protoc installed by the protoc make command.
export PATH="$(HOME)/.local/bin:$(PATH)"; gomods -w go generate -x ./...
find . -type f -name .mockery.yaml -execdir mockery \; ## Execute mockery for all .mockery.yaml files
.PHONY: rm-mocked
rm-mocked:
grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm
.PHONY: testscripts
testscripts: chainlink-test ## Install and run testscript against testdata/scripts/* files.
go install github.com/rogpeppe/go-internal/cmd/testscript@latest
go run ./tools/txtar/cmd/lstxtardirs -recurse=true | PATH="$(CURDIR):${PATH}" xargs -I % \
sh -c 'testscript -e COMMIT_SHA=$(COMMIT_SHA) -e HOME="$(TMPDIR)/home" -e VERSION=$(VERSION) -e VERSION_TAG=$(VERSION_TAG) $(TS_FLAGS) %/*.txtar'
.PHONY: testscripts-update
testscripts-update: ## Update testdata/scripts/* files via testscript.
make testscripts TS_FLAGS="-u"
.PHONY: start-testdb
start-testdb:
docker run --name test-db-core -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
.PHONY: setup-testdb
setup-testdb: ## Setup the test database.
./core/scripts/setup_testdb.sh
.PHONY: testdb
testdb: ## Prepares the test database.
go run ./core/store/cmd/preparetest
.PHONY: testdb-force
testdb-force: ## Prepares the test database, drops any pesky user connections that stand in the the way.
go run ./core/store/cmd/preparetest --force
.PHONY: testdb-user-only
testdb-user-only: ## Prepares the test database with user only.
go run ./core/store/cmd/preparetest --user-only
.PHONY: gomods
gomods: ## Install gomods
go install github.com/jmank88/gomods@v0.1.7
.PHONY: gomodslocalupdate
gomodslocalupdate: gomods ## Run gomod-local-update
go install ./tools/gomod-local-update/cmd/gomod-local-update
gomods -w gomod-local-update
gomods tidy
.PHONY: mockery
mockery: $(mockery) ## Install mockery.
go install github.com/vektra/mockery/v2@v2.53.0
.PHONY: codecgen
codecgen: $(codecgen) ## Install codecgen
go install github.com/ugorji/go/codec/codecgen@v1.2.10
.PHONY: protoc
protoc: ## Install protoc
core/scripts/install-protoc.sh 29.3 /
go install google.golang.org/protobuf/cmd/protoc-gen-go@`go list -m -json google.golang.org/protobuf | jq -r .Version`
go install github.com/smartcontractkit/wsrpc/cmd/protoc-gen-go-wsrpc@`go list -m -json github.com/smartcontractkit/wsrpc | jq -r .Version`
.PHONY: telemetry-protobuf
telemetry-protobuf: $(telemetry-protobuf) ## Generate telemetry protocol buffers.
protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-wsrpc_out=. \
--go-wsrpc_opt=paths=source_relative \
./core/services/synchronization/telem/*.proto
.PHONY: config-docs
config-docs: ## Generate core node configuration documentation
go run ./core/config/docs/cmd/generate -o ./docs/
.PHONY: golangci-lint
golangci-lint: ## Run golangci-lint for all issues.
[ -d "./golangci-lint" ] || mkdir ./golangci-lint && \
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 | tee ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt
.PHONY: lint-all
lint-all: gomods ## Run golangci-lint for all modules, both printing and creating issue files
gomods -u -go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --max-issues-per-linter 0 --max-same-issues 0 --output.text.path stdout --output.checkstyle.path ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).xml
.PHONY: lint-fix
lint-fix: gomods ## Run golangci-lint with --fix for all modules
gomods -u -go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --fix
.PHONY: modgraph
modgraph:
go install github.com/jmank88/modgraph@v0.1.1
./tools/bin/modgraph > go.md
.PHONY: test-short
test-short: ## Run 'go test -short' and suppress uninteresting output
go test -short ./... | grep -v "\[no test files\]" | grep -v "\(cached\)"
.PHONY: gocs
gocs: ## Run gocs to generate changeset markdown files.
go run github.com/smartcontractkit/gocs/cmd/gocs@v0.2.0
help:
@echo ""
@echo " .__ .__ .__ .__ __"
@echo " ____ | |__ _____ |__| ____ | | |__| ____ | | __"
@echo " _/ ___\| | \\\\\\__ \ | |/ \| | | |/ \| |/ /"
@echo " \ \___| Y \/ __ \| | | \ |_| | | \ <"
@echo " \___ >___| (____ /__|___| /____/__|___| /__|_ \\"
@echo " \/ \/ \/ \/ \/ \/"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'