This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
140 lines (112 loc) · 4.77 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
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# Supported Targets:
#
# unit-test: runs unit tests
# fabric-unit-test runs fabric unit tests
# lint: runs linters
# checks: runs code checks
# docker-thirdparty: pulls thirdparty images (couchdb)
# populate-fixtures: populate crypto directory and channel configuration for bddtests
# crypto-gen: generates crypto directory
# channel-config-gen: generates test channel configuration transactions and blocks
# bddtests: run bddtests
# bddtests-fabric-peer-docker: builds the image used by the BDD tests
#
ARCH=$(shell go env GOARCH)
# Tool commands (overridable)
DOCKER_CMD ?= docker
GO_CMD ?= go
ALPINE_VER ?= 3.12
GO_TAGS ?=
GOPROXY ?= "https://proxy.golang.org"
# Local variables used by makefile
PROJECT_NAME = fabric-peer-ext
CONTAINER_IDS = $(shell docker ps -a -q)
DEV_IMAGES = $(shell docker images dev-* -q)
export GO111MODULE = on
ARCH = $(shell go env GOARCH)
GO_VER = $(shell grep "GO_VER" .ci-properties |cut -d'=' -f2-)
# Fabric tools docker image (overridable)
FABRIC_TOOLS_IMAGE ?= hyperledger/fabric-tools
# TODO: fabric-sdk-go fails when using artifacts generated by fabric-tools v2.0.0. Switch to fabric-tools v2.0.0 after the SDK is fixed.
# FABRIC_TOOLS_VERSION ?= 2.0.0
FABRIC_TOOLS_VERSION ?= 2.0.0-alpha
FABRIC_TOOLS_TAG ?= $(ARCH)-$(FABRIC_TOOLS_VERSION)
FABRIC_PEER_EXT_IMAGE ?= trustbloc/fabric-peer
FABRIC_PEER_EXT_VERSION ?= latest
FABRIC_PEER_EXT_TAG ?= $(FABRIC_PEER_EXT_VERSION)
FIXTURES_VERSION_1_4 = v1.4
FIXTURES_VERSION_2_2 = v2.2
checks: version license lint
lint:
@scripts/check_lint.sh
license: version
@scripts/check_license.sh
all: clean checks unit-test fabric-unit-test bddtests
unit-test: checks docker-thirdparty
@scripts/unit.sh
fabric-unit-test: export FABRIC_COMMAND=unit-test
fabric-unit-test: docker-thirdparty
@scripts/build_fabric.sh
bddtests: clean build-fabric-images populate-fixtures docker-thirdparty bddtests-fabric-peer-docker build-cc
@scripts/integration.sh
bddtests-fabric-peer-cli:
@echo "Building fabric-peer cli"
@mkdir -p ./.build/bin
@cd test/bddtests/fixtures/fabric/peer/cmd && go build -o ../../../../../../.build/bin/fabric-peer github.com/trustbloc/fabric-peer-ext/test/bddtests/fixtures/fabric/peer/cmd
bddtests-fabric-peer-docker:
@docker build -f ./test/bddtests/fixtures/images/fabric-peer/Dockerfile --no-cache -t trustbloc/fabric-peer-ext-test:latest \
--build-arg FABRIC_PEER_EXT_IMAGE=$(FABRIC_PEER_EXT_IMAGE) \
--build-arg FABRIC_PEER_EXT_TAG=$(FABRIC_PEER_EXT_TAG) \
--build-arg GO_VER=$(GO_VER) \
--build-arg ALPINE_VER=$(ALPINE_VER) \
--build-arg GO_TAGS=$(GO_TAGS) \
--build-arg GOPROXY=$(GOPROXY) .
build-fabric-images: export FABRIC_COMMAND=peer-docker orderer-docker ccenv-docker
build-fabric-images:
@scripts/build_fabric.sh
@docker tag hyperledger/fabric-peer:latest trustbloc/fabric-peer:latest
@docker tag hyperledger/fabric-ccenv:latest trustbloc/fabric-ccenv:latest
@docker tag hyperledger/fabric-orderer:latest trustbloc/fabric-orderer:latest
crypto-gen:
@echo "Generating crypto directory ..."
@$(DOCKER_CMD) run -i \
-v /$(abspath .):/opt/workspace/$(PROJECT_NAME) -u $(shell id -u):$(shell id -g) \
$(FABRIC_TOOLS_IMAGE):$(FABRIC_TOOLS_TAG) \
//bin/bash -c "FIXTURES_VERSION=${FIXTURES_VERSION} /opt/workspace/${PROJECT_NAME}/scripts/generate_crypto.sh"
channel-config-gen:
@echo "Generating test channel configuration transactions and blocks ..."
@$(DOCKER_CMD) run -i \
-v /$(abspath .):/opt/workspace/$(PROJECT_NAME) -u $(shell id -u):$(shell id -g) \
$(FABRIC_TOOLS_IMAGE):$(FABRIC_TOOLS_TAG) \
//bin/bash -c "FIXTURES_VERSION=${FIXTURES_VERSION} /opt/workspace/${PROJECT_NAME}/scripts/generate_channeltx.sh"
populate-fixtures: crypto-gen channel-config-gen
version:
@scripts/check_version.sh
docker-thirdparty:
@docker pull couchdb:3.1
build-cc:
@echo "Building cc"
@mkdir -p ./.build
@scripts/copycc.sh
clean:
@rm -rf ./.build
@rm -rf ./test/bddtests/fixtures/fabric/channel
@rm -rf ./test/bddtests/fixtures/fabric/crypto-config
@rm -rf ./test/bddtests/*.log
clean-images:
@echo "Stopping all containers, pruning containers and images, deleting dev images"
ifneq ($(strip $(CONTAINER_IDS)),)
@docker stop $(CONTAINER_IDS)
endif
@docker system prune -f
ifneq ($(strip $(DEV_IMAGES)),)
@docker rmi $(DEV_IMAGES) -f
endif
@docker rmi $(docker images securekey/* -aq)
.PHONY: all version clean-images unit-test docker-thirdparty license bddtests build-fabric-images crypto-gen channel-config-gen populate-fixtures bddtests-fabric-peer-cli bddtests-fabric-peer-docker