-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·190 lines (148 loc) · 6.39 KB
/
Makefile
File metadata and controls
executable file
·190 lines (148 loc) · 6.39 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
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
TOP = .
# pinned versions
FABRIC_VERSION ?= 3.1.4
FABRIC_TWO_DIGIT_VERSION = $(shell echo $(FABRIC_VERSION) | cut -d '.' -f 1,2)
FABRIC_X_TOOLS_VERSION ?= v0.0.12
FABRIC_X_COMMITTER_VERSION ?= 0.1.9
# need to install fabric binaries outside of fsc 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
# Run `make help` to find the supported targets
.DEFAULT_GOAL := help
.PHONY: help
help: ## List all commands with documentation
@echo "Available commands:"
@awk 'BEGIN {FS = ":.*?## "}; /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
#########################
# Install tools
#########################
.PHONY: install-tools
install-tools: ## Install all 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 %
.PHONY: install-linter
install-linter-tool: ## Install linter in $(go env GOPATH)/bin
@echo "Installing golangci Linter"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.10.1
.PHONY: install-fxconfig
install-fxconfig: ## Install fxconfig in $(FAB_BINS)
@env GOBIN=$(FAB_BINS) go install $(GO_FLAGS) github.com/hyperledger/fabric-x/tools/fxconfig@$(FABRIC_X_TOOLS_VERSION)
.PHONY: install-configtxgen
install-configtxgen: ## Install configtxgen in $(FAB_BINS)
env GOBIN=$(FAB_BINS) go install $(GO_FLAGS) github.com/hyperledger/fabric-x-common/cmd/configtxgen@v0.1.1-0.20260219094834-26c5a49ed548
env GOBIN=$(FAB_BINS) go install $(GO_FLAGS) github.com/hyperledger/fabric-x-common/cmd/cryptogen@v0.1.1-0.20260219094834-26c5a49ed548
@#env GOBIN=$(FAB_BINS) go install $(GO_FLAGS) github.com/hyperledger/fabric-x/tools/configtxgen@$(FABRIC_X_TOOLS_VERSION)
.PHONY: install-fabric-bins
install-fabric-bins: ## Install fabric binaries in $(FABRIC_BINARY_BASE)
./ci/scripts/download_fabric.sh $(FABRIC_BINARY_BASE) $(FABRIC_VERSION)
.PHONY: install-softhsm
install-softhsm: ## Install softhsm
./ci/scripts/install_softhsm.sh
.PHONY: install-fsccli
install-fsccli: ## Install fsccli
@go install ./cmd/fsccli
#########################
# Generate protos
#########################
.PHONY: protos
protos: ## Build all proto files
./scripts/compile_proto.sh
#########################
# Container
#########################
.PHONY: docker-images
docker-images: fabric-docker-images monitoring-docker-images testing-docker-images
.PHONY: fabric-docker-images
fabric-docker-images: ## Pull fabric 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: fabricx-docker-images
fabricx-docker-images: ## Pull fabric-x images
docker pull hyperledger/fabric-x-committer-test-node:$(FABRIC_X_COMMITTER_VERSION)
.PHONY: monitoring-docker-images
monitoring-docker-images: ## Pull images for monitoring
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: testing-docker-images
testing-docker-images: ## Pull images for system testing
docker pull postgres:16.2-alpine
docker tag postgres:16.2-alpine fsc.itests/postgres:latest
#########################
# Tests
#########################
# include the checks target
include $(TOP)/checks.mk
GO_PACKAGES = $$(go list ./... | grep -Ev '/(integration/)'; go list ./integration/nwo/...)
GO_PACKAGES_SDK = $$(go list ./... | grep '/sdk/dig$$')
GO_TEST_PARAMS ?= -race -cover
.PHONY: unit-tests
unit-tests: ## Run unit tests
@echo "Running unit tests..."
export FABRIC_LOGGING_SPEC=error; \
export FAB_BINS=$(FAB_BINS); \
go test $(GO_TEST_PARAMS) --skip '(Postgres)' $(GO_PACKAGES)
.PHONY: unit-tests-postgres
unit-tests-postgres: ## Run unit tests for postgres (requires container images as defined in testing-docker-images)
@echo "Running unit tests..."
export FABRIC_LOGGING_SPEC=error; \
go test $(GO_TEST_PARAMS) --run '(Postgres)' $(GO_PACKAGES)
.PHONY: unit-tests-sdk
unit-tests-sdk: ## Run sdk wiring tests
@echo "Running SDK tests..."
go test $(GO_TEST_PARAMS) --run "(TestWiring)" $(GO_PACKAGES_SDK)
run-otlp:
cd platform/view/services/tracing; docker-compose up -d
INTEGRATION_TARGETS =
## fsc section
INTEGRATION_TARGETS += fsc-pingpong
INTEGRATION_TARGETS += fsc-stoprestart
## fabric section
INTEGRATION_TARGETS += fabric-atsa
INTEGRATION_TARGETS += fabric-atsachaincode
INTEGRATION_TARGETS += fabric-events
INTEGRATION_TARGETS += fabric-iou
INTEGRATION_TARGETS += fabric-iouhsm
INTEGRATION_TARGETS += fabric-stoprestart
INTEGRATION_TARGETS += fabric-twonets
## fabricx section
INTEGRATION_TARGETS += fabricx-iou
INTEGRATION_TARGETS += fabricx-simple
INTEGRATION_TARGETS += fabricx-deployment
.PHONE: list-integration-tests
list-integration-tests: ## List all integration tests
@$(foreach t,$(INTEGRATION_TARGETS),echo "$(t)";)
.PHONY: integration-tests
integration-tests: $(addprefix integration-tests-,$(INTEGRATION_TARGETS)) ## Run all integration tests
$(addprefix integration-tests-,$(INTEGRATION_TARGETS)) : integration-tests-%:
export FAB_BINS=$(FAB_BINS); \
cd ./integration/$(firstword $(subst -, ,$*))/$(subst $(firstword $(subst -, ,$*))-,,$*); \
ginkgo $(GINKGO_TEST_OPTS) .
#########################
# Cleaning
#########################
.PHONY: clean
clean: $(addprefix clean-,$(INTEGRATION_TARGETS)) ## Clean generated testdata
rm -rf ./cmd/fsccli/out
rm -rf ./out
$(addprefix clean-,$(INTEGRATION_TARGETS)) : clean-%:
rm -rf ./integration/$(firstword $(subst -, ,$*))/$(subst $(firstword $(subst -, ,$*))-,,$*)/out
.PHONY: tidy
tidy: ## Run go mod tidy everywhere
go mod tidy
cd tools; go mod tidy
cd platform/fabric/services/state/cc/query; go mod tidy
.PHONY: clean-fabric-peer-images
clean-fabric-peer-images:
docker images -a | grep "_peer_" | awk '{print $3}' | xargs docker rmi