-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
214 lines (169 loc) · 5.65 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
BIN_DIR = 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
download:
go mod download
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 rust || 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
@echo
asdf install
endif
ifeq ($(OSFLAG),$(LINUX))
@echo "Linux system detected - please install and use NIX (@see shell.nix)."
@echo
ifneq ($(CI),true)
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"
build_js:
yarn install --frozen-lockfile
build_contracts: contracts_compile contracts_install
contracts_compile: artifacts_clean
./scripts/build-contracts.sh
contracts_install: artifacts_cp_gauntlet artifacts_cp_wasmd
artifacts_cp_gauntlet:
cp -r artifacts/. packages-ts/gauntlet-cosmos-contracts/artifacts/bin
artifacts_cp_wasmd:
cp -r artifacts/. ops/wasmd/artifacts
artifacts_clean: artifacts_clean_root artifacts_clean_gauntlet artifacts_clean_wasmd
artifacts_clean_root:
rm -rf artifacts/*
artifacts_clean_gauntlet:
rm -rf packages-ts/gauntlet-cosmos-contracts/artifacts/bin/*
artifacts_clean_wasmd:
rm -rf ops/wasmd/artifacts/*
build: build_js build_contracts
# Common build step
build_relay:
go build -v ./pkg/cosmos/...
# Unit test without race detection
test_relay_unit: build_relay
go test -v -covermode=atomic ./pkg/cosmos/... -coverpkg=./... -coverprofile=unit_coverage.txt
# Unit test with race detection
test_relay_unit_race: build_relay
go test -v -covermode=atomic ./pkg/cosmos/... -race -count=10 -coverpkg=./... -coverprofile=race_coverage.txt
# copied over from starknet, replace as needed
.PHONY: build-go
build-go: build-go-relayer build-go-ops build-go-integration-tests
.PHONY: build-go-relayer
build-go-relayer:
cd pkg/ && 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 ./...
.PHONY: format-go
format-go: format-go-fmt gomodtidy
.PHONY: format-go-fmt
format-go-fmt:
cd ./pkg && go fmt ./...
cd ./ops && go fmt ./...
cd ./integration-tests && go fmt ./...
.PHONY: gomods
gomods: ## Install gomods
go install github.com/jmank88/[email protected]
.PHONY: gomodtidy
gomodtidy: gomods
gomods tidy
.PHONY: mockery
mockery: $(mockery) ## Install mockery.
go install github.com/vektra/mockery/[email protected]
.PHONY: rm-mocked
rm-mocked:
grep -rl "^// Code generated by mockery" | grep .go$ | xargs -r rm
.PHONY: generate
generate: mockery gomods
gomods -w go generate -x ./...
.PHONY: lint-go
lint-go: lint-go-ops lint-go-relayer lint-go-test
.PHONY: lint-go-ops
lint-go-ops:
cd ./ops && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always run
.PHONY: lint-go-relayer
lint-go-relayer:
cd ./pkg && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always run
.PHONY: lint-go-test
lint-go-test:
cd ./integration-tests && golangci-lint --max-issues-per-linter 0 --max-same-issues 0 --color=always --exclude=dot-imports run
.PHONY: test-integration-prep
test-integration-prep:
# add any stuff that we might need here
make build
.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 ./pkg && go test -v ./...
cd ./pkg && go test -v ./... -race -count=10
.PHONY: test-integration-go
# only runs tests with TestIntegration_* + //go:build integration
test-integration-go:
cd ./pkg && go test -v ./... -run TestIntegration -tags integration
.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 2>&1 | tee /tmp/gotest.log | gotestfmt
.PHONY: test-integration-remote-runner
test-integration-remote-runner:
cd integration-tests/ && \
./"$(suite)".test -test.v -test.count 1 $(args) -test.run ^$(test_name)$
.PHONY: test-integration-soak
test-integration-soak: test-integration-prep
cd integration-tests/ && \
go test --timeout=1h -v ./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 2>&1 | tee /tmp/gotest.log | gotestfmt