forked from drand/drand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (93 loc) · 4.5 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
.PHONY: test test-unit test-integration demo deploy-local linter install build client drand relay-http relay-gossip relay-s3
# Version values
ifeq ($(MAJOR),)
MAJOR := 0
endif
ifeq ($(PATCH),)
PATCH := 0
endif
ifeq ($(MINOR),)
MINOR := 0
endif
VER_PACKAGE=github.com/drand/drand/common
CLI_PACKAGE=github.com/drand/drand/cmd/drand-cli
GIT_REVISION := $(shell git rev-parse HEAD)
BUILD_DATE := $(shell date -u +%d/%m/%Y@%H:%M:%S)
drand: build
#################### Lint and fmt process ##################
install_lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.41.1
lint:
golangci-lint --version
golangci-lint run -E gofmt -E gosec -E goconst -E gocritic --timeout 5m
lint-todo:
golangci-lint run -E stylecheck -E gosec -E goconst -E godox -E gocritic
fmt:
@echo "Checking (& upgrading) formatting of files. (if this fail, re-run until success)"
@{ \
files=$$( go fmt ./... ); \
if [ -n "$$files" ]; then \
echo "Files not properly formatted: $$files"; \
exit 1; \
fi; \
}
check-modtidy:
go mod tidy
git diff --exit-code -- go.mod go.sum
clean:
go clean
############################################ Test ############################################
test: test-unit test-integration
test-unit:
GO111MODULE=on go test -race -short -v ./...
test-unit-cover:
GO111MODULE=on go test -short -v -coverprofile=coverage.txt -covermode=count -coverpkg=all $(go list ./... | grep -v /demo/)
test-integration:
go test -v ./demo
cd demo && go build && ./demo -build -test -debug
coverage:
go get -u github.com/ory/go-acc
go get -v -t -d ./...
COVERAGE=true go-acc ./...
demo:
cd demo && go build && ./demo -build
#cd demo && sudo ./run.sh
############################################ Build ############################################
build_proto:
go get -u github.com/golang/protobuf/[email protected]
go get -u google.golang.org/grpc/cmd/[email protected]
cd protobuf && sh ./compile_proto.sh
# create the "drand" binary and install it in $GOBIN
install:
go install -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X $(CLI_PACKAGE).buildDate=$(BUILD_DATE) -X $(CLI_PACKAGE).gitCommit=$(GIT_REVISION)"
# create the "drand" binary in the current folder
build:
go build -o drand -mod=readonly -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X $(CLI_PACKAGE).buildDate=$(BUILD_DATE) -X $(CLI_PACKAGE).gitCommit=$(GIT_REVISION)"
# create the "drand-client" binary in the current folder
client:
go build -o drand-client -mod=readonly -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X main.buildDate=$(BUILD_DATE) -X main.gitCommit=$(GIT_REVISION)" ./cmd/client
drand-client: client
# create the "drand-relay-http" binary in the current folder
relay-http:
go build -o drand-relay-http -mod=readonly -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X main.buildDate=$(BUILD_DATE) -X main.gitCommit=$(GIT_REVISION)" ./cmd/relay
drand-relay-http: relay-http
# create the "drand-relay-gossip" binary in the current folder
relay-gossip:
go build -o drand-relay-gossip -mod=readonly -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X main.buildDate=$(BUILD_DATE) -X main.gitCommit=$(GIT_REVISION)" ./cmd/relay-gossip
drand-relay-gossip: relay-gossip
# create the "drand-relay-s3" binary in the current folder
relay-s3:
go build -o drand-relay-s3 -mod=readonly -ldflags "-X $(VER_PACKAGE).MAJOR=$(MAJOR) -X $(VER_PACKAGE).MINOR=$(MINOR) -X $(VER_PACKAGE).PATCH=$(PATCH) -X main.buildDate=$(BUILD_DATE) -X main.gitCommit=$(GIT_REVISION)" ./cmd/relay-s3
drand-relay-s3: relay-s3
build_all: drand drand-client drand-relay-http drand-relay-gossip drand-relay-s3
build_docker:
docker build --build-arg major=$(MAJOR) --build-arg minor=$(MINOR) --build-arg patch=$(PATCH) --build-arg gitCommit=`git rev-parse HEAD` -t drandorg/go-drand:latest .
############################################ Deps ############################################
install_deps_linux:
PROTOC_ZIP=protoc-3.14.0-linux-x86_64.zip
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
install_deps_darwin:
brew install protobuf