-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (123 loc) · 5.67 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
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# Supported Targets:
# all : runs unit and integration tests
# depend: checks that test dependencies are installed
# depend-install: installs test dependencies
# unit-test: runs all the unit tests
# integration-test: runs all the integration tests
# checks: runs all check conditions (license, spelling, linting)
# clean: stops docker conatainers used for integration testing
# mock-gen: generate mocks needed for testing (using mockgen)
# channel-config-gen: generates the channel configuration transactions and blocks used by tests
# populate: populates generated files (not included in git) - currently only vendor
# populate-vendor: populate the vendor directory based on the lock
# populate-clean: cleans up populated files (might become part of clean eventually)
# thirdparty-pin: pulls (and patches) pinned dependencies into the project under internal
#
# Tool commands (overridable)
GO_CMD ?= go
GO_DEP_CMD ?= dep
DOCKER_CMD ?= docker
DOCKER_COMPOSE_CMD ?= docker-compose
# Build flags (overridable)
GO_LDFLAGS ?= -ldflags=-s
GO_TESTFLAGS ?=
FABRIC_SDK_EXPERIMENTAL ?= true
FABRIC_SDK_EXTRA_GO_TAGS ?=
FABRIC_SDK_POPULATE_VENDOR ?= true
# Fabric tool versions (overridable)
FABRIC_TOOLS_VERSION ?= 1.0.3
FABRIC_BASE_VERSION ?= 0.4.2
# Fabric base docker image (overridable)
FABRIC_BASE_IMAGE ?= hyperledger/fabric-baseimage
FABRIC_BASE_TAG ?= $(ARCH)-$(FABRIC_BASE_VERSION)
# Fabric tools docker image (overridable)
FABRIC_TOOLS_IMAGE ?= hyperledger/fabric-tools
FABRIC_TOOLS_TAG ?= $(ARCH)-$(FABRIC_TOOLS_VERSION)
# Upstream fabric patching (overridable)
THIRDPARTY_FABRIC_CA_BRANCH ?= master
THIRDPARTY_FABRIC_CA_COMMIT ?= 2886abda6792cf3b5e708ed18dbde07106597071
THIRDPARTY_FABRIC_BRANCH ?= master
THIRDPARTY_FABRIC_COMMIT ?= f754f40d3165571cecf5fce43c8a034559983311
# Local variables used by makefile
PACKAGE_NAME := github.com/uhuchain/uhu-hlf-client
ARCH := $(shell uname -m)
# The version of dep that will be installed by depend-install (or in the CI)
GO_DEP_COMMIT := v0.3.1
# Setup Go Tags
GO_TAGS := $(FABRIC_SDK_EXTRA_GO_TAGS)
ifeq ($(FABRIC_SDK_EXPERIMENTAL),true)
GO_TAGS += experimental
endif
# Detect CI
ifdef JENKINS_URL
export FABRIC_SDKGO_DEPEND_INSTALL := true
endif
# Global environment exported for scripts
export GO_CMD
export GO_DEP_CMD
export ARCH
export GO_LDFLAGS
export GO_DEP_COMMIT
export GO_TAGS
export GO_TESTFLAGS
all: checks unit-test integration-test
depend:
@test/scripts/dependencies.sh
depend-install:
@FABRIC_SDKGO_DEPEND_INSTALL="true" test/scripts/dependencies.sh
checks: depend license lint spelling
.PHONY: license build-softhsm2-image
license:
@test/scripts/check_license.sh
lint: populate
@test/scripts/check_lint.sh
spelling:
@test/scripts/check_spelling.sh
build-softhsm2-image:
@$(DOCKER_CMD) build --no-cache -q -t "softhsm2-image" \
--build-arg FABRIC_BASE_IMAGE=$(FABRIC_BASE_IMAGE) \
--build-arg FABRIC_BASE_TAG=$(FABRIC_BASE_TAG) \
./test/fixtures/softhsm2
unit-test: checks depend populate
@test/scripts/unit.sh
unit-tests: unit-test
integration-tests-nopkcs11: clean depend populate
@cd ./test/fixtures && $(DOCKER_COMPOSE_CMD) -f docker-compose.yaml -f docker-compose-nopkcs11-test.yaml up --force-recreate --abort-on-container-exit
@cd test/fixtures && ../scripts/check_status.sh "-f ./docker-compose.yaml -f ./docker-compose-nopkcs11-test.yaml"
integration-tests-pkcs11: clean depend populate build-softhsm2-image
@cd ./test/fixtures && $(DOCKER_COMPOSE_CMD) -f docker-compose.yaml -f docker-compose-pkcs11-test.yaml up --force-recreate --abort-on-container-exit
@cd test/fixtures && ../scripts/check_status.sh "-f ./docker-compose.yaml -f ./docker-compose-pkcs11-test.yaml"
integration-test: integration-tests-nopkcs11 integration-tests-pkcs11
mock-gen:
mockgen -build_flags '$(GO_LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api/apitxn ProposalProcessor | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apitxn/mocks/mockapitxn.gen.go
mockgen -build_flags '$(GO_LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api/apiconfig Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apiconfig/mocks/mockconfig.gen.go
mockgen -build_flags '$(GO_LDFLAGS)' github.com/hyperledger/fabric-sdk-go/api/apifabca FabricCAClient | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apifabca/mocks/mockfabriccaclient.gen.go
channel-config-gen:
@echo "Generating test channel configuration transactions and blocks ..."
@$(DOCKER_CMD) run -i \
-v $(abspath .):/opt/gopath/src/$(PACKAGE_NAME) \
$(FABRIC_TOOLS_IMAGE):$(FABRIC_TOOLS_TAG) \
/bin/bash -c "/opt/gopath/src/${PACKAGE_NAME}/test/scripts/generate_channeltx.sh"
thirdparty-pin:
@echo "Pinning third party packages ..."
@UPSTREAM_COMMIT=$(THIRDPARTY_FABRIC_COMMIT) UPSTREAM_BRANCH=$(THIRDPARTY_FABRIC_BRANCH) scripts/third_party_pins/fabric/apply_upstream.sh
@UPSTREAM_COMMIT=$(THIRDPARTY_FABRIC_CA_COMMIT) UPSTREAM_BRANCH=$(THIRDPARTY_FABRIC_CA_BRANCH) scripts/third_party_pins/fabric-ca/apply_upstream.sh
populate: populate-vendor
populate-vendor:
ifeq ($(FABRIC_SDK_POPULATE_VENDOR),true)
@echo "Populating vendor ..."
@$(GO_DEP_CMD) ensure -vendor-only
endif
populate-clean:
rm -Rf vendor
clean:
$(GO_CMD) clean
rm -Rf /tmp/enroll_user /tmp/msp /tmp/keyvaluestore /tmp/hfc-kvs
rm -f integration-report.xml report.xml
rm -f test/fixtures/tls/fabricca/certs/server/ca.org*.example.com-cert.pem
cd test/fixtures && $(DOCKER_COMPOSE_CMD) -f docker-compose.yaml -f docker-compose-nopkcs11-test.yaml -f docker-compose-pkcs11-test.yaml down