forked from smartcontractkit/chainlink-starknet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
275 lines (230 loc) · 7.5 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
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
BIN_DIR = $(abspath bin)
export GOPATH ?= $(shell go env GOPATH)
export GO111MODULE ?= on
LINUX=LINUX
OSX=OSX
WINDOWS=WIN32
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG = $(WINDOWS)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAG = $(LINUX)
endif
ifeq ($(UNAME_S),Darwin)
OSFLAG = $(OSX)
endif
endif
.PHONY: install
install:
ifeq ($(OSFLAG),$(WINDOWS))
@echo "Windows system detected - no automated setup available."
@echo "Please install your developer enviroment manually (@see .tool-versions)."
@echo
exit 1
endif
ifeq ($(OSFLAG),$(OSX))
@echo "MacOS system detected - installing the required toolchain via asdf (@see .tool-versions)."
@echo
brew install asdf
asdf plugin add golang || true
asdf plugin add nodejs || true
asdf plugin add python || true
asdf plugin add mockery || true
asdf plugin add golangci-lint || true
asdf plugin add actionlint || true
asdf plugin add shellcheck || true
asdf plugin add k3d || true
asdf plugin add kubectl || true
asdf plugin add k9s || true
asdf plugin add helm || true
asdf plugin add helmenv https://github.com/smartcontractkit/asdf-helmenv.git || true
@echo
asdf install
endif
ifeq ($(OSFLAG),$(LINUX))
@echo "Linux system detected - please install and use NIX (@see shell.nix)."
@echo
ifneq ($(CI),true)
# install nix
sh <(curl -L https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install) --daemon --tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve --nix-extra-conf-file ./nix.conf
endif
endif
.PHONY: nix-container
nix-container:
docker run -it --rm -v $(shell pwd):/repo -e NIX_USER_CONF_FILES=/repo/nix.conf --workdir /repo nixos/nix:latest /bin/sh
.PHONY: nix-flake-update
nix-flake-update:
docker run -it --rm -v $(shell pwd):/repo -e NIX_USER_CONF_FILES=/repo/nix.conf --workdir /repo nixos/nix:latest /bin/sh -c "nix flake update"
.PHONY: build
build: build-go build-ts
.PHONY: build-go
build-go: build-go-relayer build-go-ops build-go-integration-tests
.PHONY: build-go-relayer
build-go-relayer:
cd relayer/ && go build ./...
.PHONY: build-go-ops
build-go-ops:
cd ops/ && go build ./...
.PHONY: build-go-integration-tests
build-go-integration-tests:
cd integration-tests/ && go build ./...
# TODO: fix and readd build-ts-examples
.PHONY: build-ts
build-ts: build-ts-workspace build-cairo-contracts build-sol-contracts
.PHONY: build-ts-workspace
build-ts-workspace:
yarn install --frozen-lockfile
yarn build
# TODO: use yarn workspaces features instead of managing separately like this
# https://yarnpkg.com/cli/workspaces/foreach
.PHONY: build-sol-contracts
build-sol-contracts:
cd contracts/ && \
yarn install --frozen-lockfile && \
yarn compile:solidity
# TODO: this should build cairo contracts when they are rewritten
.PHONY: build-ts-examples
build-ts-examples:
cd examples/contracts/aggregator-consumer && \
yarn install --frozen-lockfile && \
yarn compile:solidity
.PHONY: gowork
gowork:
go work init
go work use ./ops
go work use ./relayer
go work use ./integration-tests
.PHONY: gowork_rm
gowork_rm:
rm go.work*
.PHONY: format
format: format-go format-cairo format-ts
.PHONY: format-check
format-check: format-cairo-check format-ts-check
.PHONY: format-go
format-go: format-go-fmt format-go-mod-tidy
.PHONY: format-go-fmt
format-go-fmt:
cd ./relayer && go fmt ./...
cd ./ops && go fmt ./...
cd ./integration-tests && go fmt ./...
.PHONY: format-go-mod-tidy
format-go-mod-tidy:
cd ./relayer && go mod tidy
cd ./monitoring && go mod tidy
cd ./ops && go mod tidy
cd ./integration-tests && go mod tidy
.PHONY: format-cairo
format-cairo:
cairo-format -i ./contracts/src/**/*.cairo
cairo-format -i ./examples/**/*.cairo
.PHONY: format-cairo-check
format-cairo-check:
cairo-format -c ./contracts/src/**/*.cairo
cairo-format -c ./examples/**/*.cairo
.PHONY: format-ts
format-ts:
yarn format
.PHONY: format-ts-check
format-ts-check:
yarn format:check
.PHONY: lint-go-ops
lint-go-ops:
cd ./ops && golangci-lint --color=always --out-format checkstyle:golangci-lint-ops-report.xml run
.PHONY: lint-go-relayer
lint-go-relayer:
cd ./relayer && golangci-lint --color=always --out-format checkstyle:golangci-lint-relayer-report.xml run
.PHONY: lint-go-test
lint-go-test:
cd ./integration-tests && golangci-lint --color=always --exclude=dot-imports --out-format checkstyle:golangci-lint-integration-tests-report.xml run
.PHONY: test-go
test-go: test-unit-go test-integration-go
.PHONY: test-unit
test-unit: test-unit-go
.PHONY: test-unit-go
test-unit-go:
cd ./relayer && go test -v ./... -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt
cd ./relayer && go test -v ./... -race -count=10 -coverpkg=./... -coverprofile=race_coverage.txt
.PHONY: test-integration-go
# only runs tests with TestIntegration_* + //go:build integration
test-integration-go:
cd ./relayer && go test -v ./... -run TestIntegration -tags integration
.PHONY: test-integration-prep
test-integration-prep:
python -m venv ~/cairo_venv && \
. ~/cairo_venv/bin/activate
cd ./contracts && pip install -r requirements.txt
make build
.PHONY: test-integration
test-integration: test-integration-smoke test-integration-contracts test-integration-gauntlet
.PHONY: test-integration-smoke
test-integration-smoke: test-integration-prep
cd integration-tests/ && \
go test --timeout=2h -v ./smoke
# CI Already has already ran test-integration-prep
.PHONY: test-integration-smoke-ci
test-integration-smoke-ci:
cd integration-tests/ && \
go test --timeout=2h -v -count=1 -json ./smoke
.PHONY: test-integration-soak
test-integration-soak: test-integration-prep
cd integration-tests/ && \
go test --timeout=1h -v -json./soak
# CI Already has already ran test-integration-prep
.PHONY: test-integration-soak-ci
test-integration-soak-ci:
cd integration-tests/ && \
go test --timeout=1h -v -count=1 -json ./soak
.PHONY: test-integration-contracts
# TODO: better network lifecycle setup - requires external network (L1 + L2)
# TODO: readd test examples
# cd examples/contracts/aggregator-consumer/ && \
# yarn test
test-integration-contracts: build-ts env-devnet-hardhat
cd packages-ts/integration-multisig/ && \
yarn test
cd packages-ts/starknet/ && \
yarn test
.PHONY: test-integration-gauntlet
# TODO: better network lifecycle setup - tests setup/run their own network (L1 + conflict w/ above if not cleaned up)
# TODO: fix example
# cd packages-ts/starknet-gauntlet-example/ && \
# yarn test
test-integration-gauntlet: build-ts env-devnet-hardhat-down
cd packages-ts/starknet-gauntlet/ && \
yarn test
cd packages-ts/starknet-gauntlet-argent/ && \
yarn test
cd packages-ts/starknet-gauntlet-cli/ && \
yarn test
cd packages-ts/starknet-gauntlet-multisig/ && \
yarn test
cd packages-ts/starknet-gauntlet-ocr2/ && \
yarn test
cd packages-ts/starknet-gauntlet-oz/ && \
yarn test
cd packages-ts/starknet-gauntlet-token/ && \
yarn test
cd packages-ts/starknet-gauntlet-emergency-protocol/ && \
yarn test
.PHONY: test-ts
test-ts: test-ts-contracts test-integration-contracts test-integration-gauntlet
.PHONY: test-ts-contracts
test-ts-contracts: build-ts env-devnet-hardhat
cd contracts/ && \
yarn test
.PHONY: build-cairo-contracts
build-cairo-contracts:
cd contracts && scarb --profile release build
.PHONY: test-cairo-contracts
test-cairo-contracts:
cd contracts && scarb test
# TODO: this script needs to be replaced with a predefined K8s enviroment
.PHONY: env-devnet-hardhat
env-devnet-hardhat:
./ops/scripts/devnet-hardhat.sh
.PHONY: env-devnet-hardhat-down
env-devnet-hardhat-down:
./ops/scripts/devnet-hardhat-down.sh