-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (91 loc) · 3.96 KB
/
Makefile
File metadata and controls
122 lines (91 loc) · 3.96 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
TEST_COUNT ?= 10
COVERAGE_FILE ?= coverage.out
# Detect the system architecture
ARCH := $(shell uname -m)
# Find 'protoc' download URL based on the architecture
ifeq ($(ARCH),x86_64)
PROTOC_ZIP := protoc-28.0-linux-x86_64.zip
else ifeq ($(ARCH),arm64)
PROTOC_ZIP := protoc-28.0-osx-aarch_64.zip
else
$(error Unsupported architecture: $(ARCH))
endif
PROTOC_URL := https://github.com/protocolbuffers/protobuf/releases/download/v28.0/$(PROTOC_ZIP)
PROTOC_BIN ?= /usr/local/bin/protoc
BUF_BIN := $(shell go env GOPATH)/bin/buf
COMPARE_AGAINST_BRANCH := main
build: ensure_go_version
go build -v ./...
# If you have a different version of protoc installed, you can use the following command to generate the protobuf files
# make generate PROTOC_BIN=/path/to/protoc
generate: ensure_go_version clean-generate proto-generate generate-mocks modgraph
generate-mocks: ensure_go_version
go install github.com/vektra/mockery/v2@v2.52.3
mockery
# If you have a different version of protoc installed, you can use the following command to generate the protobuf files
# make proto-generate PROTOC_BIN=/path/to/protoc
proto-generate: ensure_go_version ensure_protoc_28_0
$(PROTOC_BIN) --go_out=./pkg/ocrtypecodec/v1/ocrtypecodecpb ./pkg/ocrtypecodec/v1/ocrtypes.proto
proto-lint: ensure_go_version ensure_buf_version
$(BUF_BIN) lint
proto-check-breaking: ensure_go_version ensure_buf_version
$(BUF_BIN) breaking --against '.git#branch=$(COMPARE_AGAINST_BRANCH)'
clean-generate: ensure_go_version
rm -rf ./mocks/
test:
go test -race -fullpath -shuffle on -count $(TEST_COUNT) -coverprofile=$(COVERAGE_FILE) \
`go list ./... | grep -Ev 'chainlink-ccip/internal/mocks|chainlink-ccip/mocks|chainlink-ccip/pkg/ocrtypecodec/v1/ocrtypecodecpb|chainlink-ccip/chains'`
lint: ensure_go_version ensure_golangcilint
golangci-lint run -c .golangci.yml
lint-fix: ensure_go_version ensure_golangcilint
golangci-lint run -c .golangci.yml --fix
lint-safebigint: ensure_go_version
@echo "Running safebigint linter..."
@if command -v safebigint >/dev/null 2>&1; then \
safebigint ./... || echo "safebigint found issues. Review the output above."; \
else \
echo "safebigint not found. Run 'make install-safebigint' to install it."; \
exit 1; \
fi
lint-custom: ensure_go_version
@echo "Running custom linters in strict mode..."
@if command -v safebigint >/dev/null 2>&1; then safebigint ./...; fi
checks: test lint lint-custom
install-protoc:
@echo "Downloading and installing protoc for $(ARCH)..."
curl -OL $(PROTOC_URL)
sudo unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc
sudo unzip -o $(PROTOC_ZIP) -d /usr/local 'include/*'
rm -f $(PROTOC_ZIP)
sudo chmod +x $(PROTOC_BIN)
@echo "Installed protoc version:"
$(PROTOC_BIN) --version
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31
install-golangcilint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
install-safebigint:
go install github.com/winder/safebigint/cmd/safebigint@latest
install-custom-linters: install-safebigint
install-linters: install-golangcilint install-custom-linters
ensure_go_version:
@go version | grep -q 'go1.25' || (echo "Please use go1.25" && exit 1)
ensure_golangcilint:
@golangci-lint --version | grep -q '1.64.5' || (echo "Please use golangci-lint 1.64.5, make install-golangcilint" && exit 1)
ensure_protoc_28_0:
@$(PROTOC_BIN) --version | grep -q 'libprotoc 28.0' || (echo "Please use protoc 28.0, (make install-protoc)" && exit 1)
install_buf:
go install github.com/bufbuild/buf/cmd/buf@v1.50.0
ensure_buf_version:
@$(BUF_BIN) --version | grep -q '1.50.0' || (echo "Please use buf 1.50.0" && exit 1)
gomods: ## Install gomods
go install github.com/jmank88/gomods@v0.1.7
gomodtidy: gomods
gomods tidy
modgraph: gomods
go install github.com/jmank88/modgraph@v0.1.1
./modgraph > go.md
pin_deployment_dependencies:
@cd chains/evm/deployment && \
go get github.com/smartcontractkit/chainlink-ccip@$(SHA) && \
go get github.com/smartcontractkit/chainlink-ccip/deployment@$(SHA)
@$(MAKE) gomodtidy