-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathMakefile
More file actions
319 lines (271 loc) · 10.6 KB
/
Copy pathMakefile
File metadata and controls
319 lines (271 loc) · 10.6 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# pinned versions
FABRIC_VERSION ?= 3.1.4
FABRIC_CA_VERSION ?= 1.5.7
FABRIC_TWO_DIGIT_VERSION = $(shell echo $(FABRIC_VERSION) | cut -d '.' -f 1,2)
FABRIC_X_TOOLS_VERSION ?= v1.0.0
FABRIC_X_COMMITTER_VERSION ?= 1.0.3
# need to install fabric binaries outside of panuru's tree for now (due to chaincode packaging issues)
FABRIC_BINARY_BASE=$(PWD)/../fabric
FAB_BINS ?= $(FABRIC_BINARY_BASE)/bin
# integration test options
GINKGO_TEST_OPTS ?=
GINKGO_TEST_OPTS += --keep-going -cover
TOP = .
# include the checks target
include $(TOP)/checks.mk
# Define all Go module directories
GO_MODULES := . integration token/services/storage/db/kvs/hashicorp cmd/artifactgen cmd/tokengen cmd/token_validation_service cmd/profiler cmd/skicleanup
TIDY_GO_MODULES := $(GO_MODULES) tools
# include fabricx target
include $(TOP)/fabricx.mk
# include the interop target
include $(TOP)/interop.mk
# include the fungible target
include $(TOP)/fungible.mk
all: install-tools install-softhsm checks unit-tests #integration-tests
.PHONY: install-tools
# install tools required for development and testing
install-tools:
# Thanks for great inspiration https://marcofranssen.nl/manage-go-tools-via-go-modules
@echo Installing tools from tools/tools.go
@cd tools; cat tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI % go install %
@$(MAKE) install-linter-tool
.PHONY: download-fabric
# download fabric binaries
download-fabric:
./ci/scripts/download_fabric.sh $(FABRIC_BINARY_BASE) $(FABRIC_VERSION) $(FABRIC_CA_VERSION)
GO_TEST_PARAMS ?= -coverpkg=./... -coverprofile=profile.cov
GO_PACKAGES = $(shell go list ./... | grep -v '/integration/' | grep -v 'regression' | grep -v 'mock' | grep -v 'protos-go' | grep -v 'testutils'; go list ./integration/nwo/...)
.PHONY: unit-tests
# run standard unit tests
unit-tests:
@go test $(GO_TEST_PARAMS) $(GO_PACKAGES)
cd token/services/storage/db/kvs/hashicorp/; go test -cover ./...
.PHONY: unit-tests-race
# run unit tests with race detection
unit-tests-race:
@export GORACE=history_size=7; go test -race -cover $(shell go list ./... | grep -v '/integration/' | grep -v 'regression')
cd integration/nwo/; go test -cover ./...
.PHONY: unit-tests-regression
# run regression unit tests
unit-tests-regression:
@go test -race -timeout 0 -cover $(shell go list ./... | grep -v '/integration/' | grep 'regression')
.PHONY: install-softhsm
# install softhsm for testing
install-softhsm:
./ci/scripts/install_softhsm.sh
.PHONY: docker-images
# build/pull docker images needed for testing
docker-images: fabric-docker-images monitoring-docker-images testing-docker-images
.PHONY: testing-docker-images
# pull docker images for testing (postgres, vault)
testing-docker-images:
docker pull postgres:16.2-alpine
docker tag postgres:16.2-alpine fsc.itests/postgres:latest
docker pull hashicorp/vault
.PHONY: fabric-docker-images
# pull fabric docker images
fabric-docker-images:
docker pull hyperledger/fabric-baseos:$(FABRIC_TWO_DIGIT_VERSION)
docker image tag hyperledger/fabric-baseos:$(FABRIC_TWO_DIGIT_VERSION) hyperledger/fabric-baseos:latest
docker pull hyperledger/fabric-ccenv:$(FABRIC_TWO_DIGIT_VERSION)
docker image tag hyperledger/fabric-ccenv:$(FABRIC_TWO_DIGIT_VERSION) hyperledger/fabric-ccenv:latest
.PHONY: monitoring-docker-images
# pull monitoring docker images (explorer, prometheus, grafana, jaeger)
monitoring-docker-images:
docker pull ghcr.io/hyperledger-labs/explorer-db:latest
docker pull ghcr.io/hyperledger-labs/explorer:latest
docker pull prom/prometheus:latest
docker pull grafana/grafana:latest
docker pull cr.jaegertracing.io/jaegertracing/jaeger:2.12.0
.PHONY: integration-tests-nft-dlog
# run nft integration tests with idemix
integration-tests-nft-dlog:
cd ./integration/token/nft/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
.PHONY: integration-tests-nft-fabtoken
# run nft integration tests with fabtoken
integration-tests-nft-fabtoken:
cd ./integration/token/nft/fabtoken; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
.PHONY: integration-tests-dvp-fabtoken
# run dvp integration tests with fabtoken
integration-tests-dvp-fabtoken:
cd ./integration/token/dvp/fabtoken; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
.PHONY: integration-tests-dvp-dlog
# run dvp integration tests with idemix
integration-tests-dvp-dlog:
cd ./integration/token/dvp/dlog; export FAB_BINS=$(FAB_BINS); ginkgo $(GINKGO_TEST_OPTS) .
.PHONY: tidy
# tidy up go modules
tidy:
@echo "Tidying Go modules..."
@for dir in $(TIDY_GO_MODULES); do \
echo " Tidying module: $$dir"; \
(cd $$dir && go mod tidy); \
done
.PHONY: clean
# clean up docker artifacts and generated files
clean:
docker network prune -f
docker container prune -f
docker volume prune -f
rm -rf ./integration/token/fungible/dlog/out/
rm -rf ./integration/token/fungible/dlog/testdata/
rm -rf ./integration/token/fungible/dlogx/out/
rm -rf ./integration/token/fungible/dloghsm/out/
rm -rf ./integration/token/fungible/dloghsm/testdata/
rm -rf ./integration/token/fungible/dlogstress/out/
rm -rf ./integration/token/fungible/dlogstress/testdata/
rm -rf ./integration/token/fungible/fabtoken/out/
rm -rf ./integration/token/fungible/fabtoken/testdata/
rm -rf ./integration/token/fungible/odlog/out/
rm -rf ./integration/token/fungible/ofabtoken/out/
rm -rf ./integration/token/fungible/mixed/out/
rm -rf ./integration/token/nft/dlog/out/
rm -rf ./integration/token/nft/fabtoken/out/
rm -rf ./integration/token/nft/odlog/out/
rm -rf ./integration/token/nft/ofabtoken/out/
rm -rf ./integration/token/dvp/dlog/out/
rm -rf ./integration/token/dvp/fabtoken/out/
rm -rf ./integration/token/interop/fabtoken/out/
rm -rf ./integration/token/interop/dlog/out/
rm -rf ./integration/token/fungible/update/out/
rm -rf ./integration/token/fungible/update/testdata/
.PHONY: clean-fabric-peer-images
# clean up fabric peer images
clean-fabric-peer-images:
docker images -a | grep "_peer.org" | awk '{print $3}' | xargs docker rmi
docker images -a | grep "_peer_" | awk '{print $3}' | xargs docker rmi
.PHONY: tokengen
# install tokengen tool (must build without cgo; see #1445)
tokengen:
@cd ./cmd/tokengen/; CGO_ENABLED=0 go install github.com/LFDT-Panurus/panurus/cmd/tokengen
.PHONY: artifactgen
# install artifactgen tool (must build without cgo; see #1445)
artifactgen:
@cd ./cmd/artifactgen/; CGO_ENABLED=0 go install github.com/LFDT-Panurus/panurus/cmd/artifactgen
.PHONY: skicleanup
# install skicleanup tool (must build without cgo; see #1445)
skicleanup:
@cd ./cmd/skicleanup/; CGO_ENABLED=0 go install github.com/LFDT-Panurus/panurus/cmd/skicleanup
.PHONY: traceinspector
# install traceinspector tool
traceinspector:
@go install ./token/services/benchmark/cmd/traceinspector
.PHONY: memcheck
# install memcheck tool
memcheck:
@go install ./token/services/benchmark/cmd/memcheck
.PHONY: txgen
# install idemixgen/txgen tool
txgen:
@go install github.com/IBM/idemix/tools/idemixgen
.PHONY: profile-validator-transfer
# regenerate validator transfer profile documentation
profile-validator-transfer:
@echo "Regenerating validator transfer profile..."
@cd tools/profiler && ./profile.sh BenchmarkValidatorTransfer -f VerifyTokenRequestFromRaw
.PHONY: profile
# run profiler on any test or benchmark
# Usage: make profile TEST=BenchmarkValidatorTransfer [ROOT=VerifyTokenRequestFromRaw]
# Usage: make profile TEST=TestMyFunction
profile:
@if [ -z "$(TEST)" ]; then \
echo "Error: TEST parameter is required"; \
echo "Usage: make profile TEST=<test_or_benchmark_name> [ROOT=<root_function>]"; \
echo "Example: make profile TEST=BenchmarkValidatorTransfer ROOT=VerifyTokenRequestFromRaw"; \
exit 1; \
fi
@echo "Running profiler on $(TEST)..."
@if [ -n "$(ROOT)" ]; then \
cd tools/profiler && ./profile.sh $(TEST) -f $(ROOT); \
else \
cd tools/profiler && ./profile.sh $(TEST); \
fi
.PHONY: clean-all-containers
# clean up all docker containers
clean-all-containers:
@if [ -n "$$(docker ps -aq)" ]; then docker rm -f $$(docker ps -aq); else echo "No containers to remove"; fi
.PHONY: lint
# run various linters
lint:
@echo "Running Go Linters..."
@for dir in $(GO_MODULES); do \
echo " Linting module: $$dir"; \
(cd $$dir && golangci-lint run --color=always --timeout=4m ./...) || exit 1; \
done
.PHONY: lint-auto-fix
# run linters with auto-fix
lint-auto-fix:
@echo "Running Go Linters with auto-fix..."
@for dir in $(GO_MODULES); do \
echo " Linting module: $$dir"; \
(cd $$dir && golangci-lint run --color=always --timeout=4m --fix ./...) || exit 1; \
done
.PHONY: install-linter-tool
# install golangci-lint
install-linter-tool:
@echo "Installing golangci Linter"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(HOME)/go/bin v2.12.2
.PHONY: fmt
fmt: ## Run gofmt on the entire project
@echo "Running gofmt..."
@for dir in $(GO_MODULES); do \
echo " Formatting module: $$dir"; \
(cd $$dir && find . -path './.git' -prune -o -name '*.go' -print | xargs gofmt -l -s -w); \
done
.PHONY: update-all-deps-latest
update-all-deps-latest: ## Update all dependencies in all Go modules to their latest version
@echo "Updating all dependencies to @latest..."
@for dir in $$(find . -name "go.mod" -exec dirname {} \;); do \
echo "=> Updating dependencies in $$dir"; \
(cd $$dir && go get ./...@latest && go mod tidy); \
done
.PHONY: docs-install
# Install documentation dependencies
docs-install:
pip install -r requirements.txt
.PHONY: docs-serve
# Serve documentation locally for development
docs-serve:
mkdocs serve
.PHONY: docs-build
# Build the static documentation site for production
docs-build:
mkdocs build --strict
.PHONY: protos-format
protos-format: ## Run buf format to fix protobuf files
@echo "Fixing protobuf formatting..."
@buf format -w
.PHONY: protos
# generate protobuf files
protos:
@echo "Generating protobuf files..."
@buf generate
.PHONY: update-dep
update-dep:
@test -n "$(DEP)" || (echo "usage: make update-dep DEP=module/path VER=vX.Y.Z" && exit 1)
@test -n "$(VER)" || (echo "usage: make update-dep DEP=module/path VER=vX.Y.Z" && exit 1)
@find . -name go.mod -not -path '*/vendor/*' -exec bash -ec '\
for mod do \
dir=$$(dirname "$$mod"); \
cd "$$dir" || exit 1; \
if go list -m all | grep -q "^$(DEP) "; then \
echo "==> $$(pwd)"; \
go get "$(DEP)@$(VER)" || exit 1; \
fi; \
cd - >/dev/null || exit 1; \
done \
' bash {} +
@$(MAKE) tidy
.PHONY: list-dep-modules
list-dep-modules:
@test -n "$(DEP)" || (echo "usage: make list-dep-modules DEP=module/path" && exit 1)
@find . -name go.mod -not -path '*/vendor/*' | while read -r mod; do \
dir=$$(dirname "$$mod"); \
( \
cd "$$dir" || exit 1; \
if go list -m all | grep -q "^$(DEP) "; then \
echo "$$dir"; \
fi; \
); \
done