-
Notifications
You must be signed in to change notification settings - Fork 70
/
Makefile
89 lines (69 loc) · 2.52 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
# -------------------------------------------------------------
# This makefile defines the following targets
# - tape - builds a binary program
# - docker - build the tape image
# - unit-test - runs the go-test based unit tests
# - integration-test - runs the integration tests
# - install - installs a binary program to GOBIN path
FABRIC_VERSION = latest
INTERGATION_CASE = ANDLogic
BASE_VERSION = 0.2.0
PREV_VERSION = 0.1.2
PROJECT_NAME = tape
DOCKERIMAGE = ghcr.io/hyperledger-twgc/tape
export DOCKERIMAGE
EXTRA_VERSION ?= $(shell git rev-parse --short HEAD)
BuiltTime ?= $(shell date)
PROJECT_VERSION=$(BASE_APISERVER_VERSION)-snapshot-$(EXTRA_VERSION)
PKGNAME = github.com/hyperledger-twgc/$(PROJECT_NAME)
CGO_FLAGS = CGO_CFLAGS=" "
ARCH=$(shell go env GOARCH)
MARCH=$(shell go env GOOS)-$(shell go env GOARCH)
# defined in pkg/infra/version.go
METADATA_VAR = Version=$(BASE_VERSION)
METADATA_VAR += CommitSHA=$(EXTRA_VERSION)
GO_LDFLAGS = $(patsubst %,-X $(PKGNAME)/pkg/infra/cmdImpl.%,$(METADATA_VAR))
GO_LDFLAGS += -X '$(PKGNAME)/pkg/infra/cmdImpl.BuiltTime=$(BuiltTime)'
GO_TAGS ?=
export GO_LDFLAGS GO_TAGS FABRIC_VERSION INTERGATION_CASE
base_dir := $(patsubst %/,%,$(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
tape:
@echo "Building tape program......"
go build -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" ./cmd/tape
escapes:
@echo "go build check for escapes"
go build -gcflags="-m -l" ./... | grep "escapes to heap" || true
set_govulncheck:
@go install golang.org/x/vuln/cmd/govulncheck@latest
vuls: set_govulncheck
@govulncheck -v ./... || true
.PHONY: docker
docker:
@echo "Building tape docker......"
docker build . --tag=ghcr.io/hyperledger-twgc/tape
.PHONY: unit-test
unit-test:
@echo "Run unit test......"
go test -v ./... --race --bench=. -cover --count=1
go test -fuzz=Fuzz -fuzztime 30s ./pkg/infra/trafficGenerator
.PHONY: integration-test
integration-test:
@echo "Run integration test......"
./test/integration-test.sh $(FABRIC_VERSION) $(INTERGATION_CASE)
.PHONY: install
install:
@echo "Install tape......"
go install -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" ./cmd/tape
include gotools.mk
.PHONY: checks
checks: gotools-install linter
.PHONY: linter
linter:
go mod vendor
docker pull golangci/golangci-lint:latest
docker run --tty --rm \
--volume '$(base_dir)/.cache/golangci-lint:/root/.cache' \
--volume '$(base_dir):/app' \
--workdir /app \
golangci/golangci-lint \
golangci-lint run --verbose