forked from cosmos/interchain-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
256 lines (195 loc) · 9.4 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
#!/usr/bin/make -f
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
# Fetch tags and get the latest ICS version by filtering tags by vX.Y.Z and vX.Y.Z-lsm
# using lazy set to only execute commands when variable is used
LATEST_RELEASE ?= $(shell git fetch; git tag -l --sort -v:refname 'v*.?' 'v*.?'-lsm 'v*.??' 'v*.??'-lsm | head -n 1)
# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
sharedFlags = -X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
providerFlags := $(sharedFlags) -X github.com/cosmos/cosmos-sdk/version.AppName=interchain-security-pd -X github.com/cosmos/cosmos-sdk/version.Name=interchain-security-pd
consumerFlags := $(sharedFlags) -X github.com/cosmos/cosmos-sdk/version.AppName=interchain-security-cd -X github.com/cosmos/cosmos-sdk/version.Name=interchain-security-cd
democracyFlags := $(sharedFlags) -X github.com/cosmos/cosmos-sdk/version.AppName=interchain-security-cdd -X github.com/cosmos/cosmos-sdk/version.Name=interchain-security-cdd
standaloneFlags := $(sharedFlags) -X github.com/cosmos/cosmos-sdk/version.AppName=interchain-security-sd -X github.com/cosmos/cosmos-sdk/version.Name=interchain-security-sd
install: go.sum
export GOFLAGS='-buildmode=pie'
export CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CGO_LDFLAGS="-Wl,-z,relro,-z,now -fstack-protector"
go install -ldflags "$(providerFlags)" ./cmd/interchain-security-pd
go install -ldflags "$(consumerFlags)" ./cmd/interchain-security-cd
go install -ldflags "$(democracyFlags)" ./cmd/interchain-security-cdd
go install -ldflags "$(standaloneFlags)" ./cmd/interchain-security-sd
# run all tests: unit, integration, diff, and E2E
test: test-unit test-integration test-mbt test-e2e
# shortcut for local development
test-dev: test-unit test-integration test-mbt
# run unit tests
test-unit:
go test ./x/... ./app/...
test-unit-cov:
go test ./x/... ./app/... -coverpkg=./... -coverprofile=profile.out -covermode=atomic
# run unit and integration tests
test-integration:
go test ./tests/integration/... -timeout 30m
test-integration-cov:
go test ./tests/integration/... -timeout 30m -coverpkg=./... -coverprofile=integration-profile.out -covermode=atomic
# run mbt tests
test-mbt:
cd tests/mbt/driver;\
sh generate_traces.sh;\
cd ../../..;\
go test ./tests/mbt/... -timeout 30m
test-mbt-cov:
cd tests/mbt/driver;\
sh generate_traces.sh;\
cd ../../..;\
go test ./tests/mbt/... -timeout 30m -coverpkg=./... -coverprofile=mbt-profile.out -covermode=atomic
# runs mbt tests, but generates more traces
test-mbt-more-traces:
cd tests/mbt/driver;\
sh generate_more_traces.sh;\
cd ../../..;\
go test ./tests/mbt/... -timeout 30m
# run E2E tests
test-e2e:
go run ./tests/e2e/...
# run only happy path E2E tests
test-e2e-short:
go run ./tests/e2e/... --tc happy-path
# run only happy path E2E tests with cometmock
# this set of traces does not test equivocation but it does check downtime
test-e2e-short-cometmock:
go run ./tests/e2e/... --tc happy-path-short --use-cometmock --use-gorelayer
# run minimal set of traces with cometmock and gaia
test-e2e-short-cometmock-gaia:
go run ./tests/e2e/... --tc happy-path-short --use-cometmock --use-gorelayer --use-gaia
# run full E2E tests in sequence (including multiconsumer)
test-e2e-multi-consumer:
go run ./tests/e2e/... --include-multi-consumer
# run full E2E tests in parallel (including multiconsumer)
test-e2e-parallel:
go run ./tests/e2e/... --include-multi-consumer --parallel
# run E2E compatibility tests against latest release
test-e2e-compatibility-tests-latest:
go run ./tests/e2e/... --tc compatibility -pv $(LATEST_RELEASE)
# run full E2E tests in sequence (including multiconsumer) using latest tagged gaia
test-gaia-e2e:
go run ./tests/e2e/... --include-multi-consumer --use-gaia
# run only happy path E2E tests using latest tagged gaia
test-gaia-e2e-short:
go run ./tests/e2e/... --tc happy-path --use-gaia
# run full E2E tests in parallel (including multiconsumer) using latest tagged gaia
test-gaia-e2e-parallel:
go run ./tests/e2e/... --include-multi-consumer --parallel --use-gaia
# run full E2E tests in sequence (including multiconsumer) using specific tagged version of gaia
# usage: GAIA_TAG=v9.0.0 make test-gaia-e2e-tagged
test-gaia-e2e-tagged:
go run ./tests/e2e/... --include-multi-consumer --use-gaia --gaia-tag $(GAIA_TAG)
# run only happy path E2E tests using latest tagged gaia
# usage: GAIA_TAG=v9.0.0 make test-gaia-e2e-short-tagged
test-gaia-e2e-short-tagged:
go run ./tests/e2e/... --tc happy-path --use-gaia --gaia-tag $(GAIA_TAG)
# run full E2E tests in parallel (including multiconsumer) using specific tagged version of gaia
# usage: GAIA_TAG=v9.0.0 make test-gaia-e2e-parallel-tagged
test-gaia-e2e-parallel-tagged:
go run ./tests/e2e/... --include-multi-consumer --parallel --use-gaia --gaia-tag $(GAIA_TAG)
# run all tests with caching disabled
test-no-cache:
go test ./... -count=1 && go run ./tests/e2e/...
# test reading a trace from a file
test-trace:
go run ./tests/e2e/... --test-file tests/e2e/tracehandler_testdata/happyPath.json::default
# tests and verifies the Quint models.
# Note: this is *not* using the Quint models to test the system,
# this tests/verifies the Quint models *themselves*.
verify-models:
cd tests/mbt/model;\
../run_invariants.sh
###############################################################################
### Linting ###
###############################################################################
golangci_version=v1.54.1
lint:
@echo "--> Running linter"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version)
golangci-lint run ./... --config .golangci.yml
format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs gofumpt -w -l
golangci-lint run --fix --config .golangci.yml
.PHONY: format
mockgen_cmd=go run github.com/golang/mock/mockgen
mocks:
$(mockgen_cmd) -package=keeper -destination=testutil/keeper/mocks.go -source=x/ccv/types/expected_keepers.go
BUILDDIR ?= $(CURDIR)/build
BUILD_TARGETS := build
build: BUILD_ARGS=-o $(BUILDDIR)/
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/
###############################################################################
### Protobuf ###
###############################################################################
DOCKER := $(shell which docker)
HTTPS_GIT := https://github.com/cosmos/interchain-security.git
containerProtoVer=0.13.0
containerProtoImage=ghcr.io/cosmos/proto-builder:$(containerProtoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage)
proto-all: proto-format proto-lint proto-gen
proto-gen:
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh;
proto-check:
@if git diff --quiet --exit-code main...HEAD -- proto; then \
echo "Pass! No committed changes found in /proto directory between the currently checked out branch and main."; \
else \
echo "Committed changes found in /proto directory between the currently checked out branch and main."; \
modified_protos=$$(git diff --name-only main...HEAD proto); \
modified_pb_files= ; \
for proto_file in $${modified_protos}; do \
proto_name=$$(basename "$${proto_file}" .proto); \
pb_files=$$(find x/ccv -name "$${proto_name}.pb.go"); \
for pb_file in $${pb_files}; do \
if git diff --quiet --exit-code main...HEAD -- "$${pb_file}"; then \
echo "Missing committed changes in $${pb_file}"; \
exit 1; \
else \
modified_pb_files+="$${pb_file} "; \
fi \
done \
done; \
echo "Pass! Correctly modified pb files: "; \
echo $${modified_pb_files}; \
fi
proto-format:
@echo "Formatting Protobuf files"
@$(protoImage) find ./ -name "*.proto" -exec clang-format -i {} \;
proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@$(protoImage) sh ./scripts/protocgen.sh
proto-lint:
@$(protoImage) buf lint --error-format=json
proto-check-breaking:
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main
proto-update-deps:
@echo "Updating Protobuf dependencies"
$(protoImage) buf mod update
.PHONY: proto-all proto-gen proto-format proto-lint proto-check proto-check-breaking proto-update-deps mocks
###############################################################################
### Documentation ###
###############################################################################
build-docs:
@cd docs && ./build.sh
.PHONY: build-docs
###############################################################################
### Test Traces ###
###############################################################################
e2e-traces:
cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v