forked from hyperledger-labs/orion-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
124 lines (99 loc) · 3.48 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
TIMEOUT = 20m
GO = go
DOCKER = docker
DOCKER_IMAGE = orionbcdb/orion-server
DOCKERFILE = images/Dockerfile
PKGS = $(or $(PKG),$(shell env GO111MODULE=on $(GO) list ./...))
TESTPKGS = $(shell env GO111MODULE=on $(GO) list -f \
'{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' \
$(PKGS))
COVERAGE_MODE = atomic
COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out
COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml
COVERAGE_HTML = $(COVERAGE_DIR)/index.html
BIN = $(CURDIR)/bin
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN)
@tmp=$$(mktemp -d); \
env GO11MODULE=off GOPATH=$$tmpp GOBIN=$(BIN) go get $(PACKAGE) \
|| ret=$$?;
rm -rf $$tmp ; exit $$ret
$(BIN)/golangci-lint: PACKAGE=github.com/golangci/golangci-lint/cmd/golangci-lint
GOLINT = $(BIN)/golangci-lint
lint: | $(GOLINT)
$(GOLINT) run
GOCOV = $(BIN)/gocov
$(BIN)/gocov: PACKAGE=github.com/axw/gocov/...
GOCOVXML = $(BIN)/gocov-xml
$(BIN)/gocov-xml: PACKAGE=github.com/AlekSi/gocov-xml
GO2XUNIT = $(BIN)/go2xunit
$(BIN)/go2xunit: PACKAGE=github.com/tebeka/go2xunit
.PHONY: fmt
fmt:
$(GO) fmt $(PKGS)
.PHONY: goimports
goimports:
find . -name \*.go -not -path "./pkg/types/*" -exec goimports -w -l {} \;
.PHONY: binary
binary:
go build -o $(BIN)/bdb cmd/bdb/main.go
go build -o $(BIN)/signer cmd/signer/signer.go
go build -o $(BIN)/encoder cmd/base64_encoder/encoder.go
go build -o $(BIN)/decoder cmd/base64_decoder/decoder.go
.PHONY: test
test-script:
scripts/run-unit-tests.sh
.PHONY: clean
clean:
@rm -rf $(BIN)
@rm -rf test/tests.* test/coverage.*
.PHONY: docker-clean
docker-clean:
$(DOCKER) rmi $(DOCKER_IMAGE)
.PHONY: protos
protos:
docker run -it -v `pwd`:`pwd` -w `pwd` sykesm/fabric-protos:0.2 scripts/compile_go_protos.sh
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
test-bench: ARGS=-run=__absolutelynothing__ -bench=.
test-short: ARGS=-short
test-verbose: ARGS=-v
test-race: ARGS=-race
$(TEST_TARGETS): test
check test tests:
go build -o $(BIN)/bdb cmd/bdb/main.go
go test -timeout $(TIMEOUT) $(ARGS) $(TESTPKGS)
test-coverage-tools: | $(GOCOVMERGE) $(GOCOV) $(GOCOVXML)
test-coverage: COVERAGE_DIR := $(CURDIR)/test/coverage.$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
test-coverage: test-coverage-tools
go build -o $(BIN)/bdb cmd/bdb/main.go
mkdir -p $(COVERAGE_DIR)/coverage
$(GO) test \
-coverpkg=$$($(GO) list -f '{{ join .Deps "\n" }}' $(TESTPKGS) | \
grep '^$(MODULE)/' | \
tr '\n' ',' | sed 's/,$$//') \
-covermode=$(COVERAGE_MODE) \
-coverprofile="$(COVERAGE_PROFILE)" $(TESTPKGS)
$(GO) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
$(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML)
.PHONY: docker
docker:
$(DOCKER) build -t $(DOCKER_IMAGE) --no-cache -f $(DOCKERFILE) .
.PHONY: docker-multiarch
docker-multiarch:
make docker-linux-amd64
make docker-linux-arm64
make docker-linux-arm-v7
make docker-linux-s390x
.PHONY: docker-linux-amd64
docker-linux-amd64:
$(DOCKER) buildx build --platform linux/amd64 -f $(DOCKERFILE) -t $(DOCKER_IMAGE):linux-amd64 --load .
.PHONY: docker-linux-arm64
docker-linux-arm64:
$(DOCKER) buildx build --platform linux/arm64 -f $(DOCKERFILE) -t $(DOCKER_IMAGE):linux-arm64 --load .
.PHONY: docker-linux-arm-v7
docker-linux-arm-v7:
$(DOCKER) buildx build --platform linux/arm/v7 -f $(DOCKERFILE) -t $(DOCKER_IMAGE):linux-arm-v7 --load .
.PHONY: docker-linux-s390x
docker-linux-s390x:
$(DOCKER) buildx build --platform linux/s390x -f $(DOCKERFILE) -t $(DOCKER_IMAGE):linux-s390x --load .