-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
58 lines (45 loc) · 1.76 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
.SHELLFLAGS=-c -o pipefail
SHELL=/bin/bash
export CGO_LDFLAGS_ALLOW="-Wl,-z,now"
export CGO_LDFLAGS="-ldl -llz4 -lm"
export GO111MODULE = on
export GOFLAGS = -mod=vendor
export CGO_LDFLAGS_ALLOW="-Wl,-z,now"
export CGO_LDFLAGS="${BUILDER_LINKER_FLAGS}"
BRANCH := $(shell git branch --show-current)
CLEANBRANCH := $(shell git branch --show-current | sed 's/\//-/')
SHORT := $(shell git rev-parse --short HEAD)
DEVTAG := ${CLEANBRANCH}-${SHORT}
LINT_BIN := $(shell go env GOPATH)/bin/golangci-lint
ifeq (${BRANCH}, main)
TAG := $(shell cat .version)
else
TAG := "$(shell cat .version)-${DEVTAG}"
endif
deps:
go mod download
go mod tidy
go mod verify
go mod vendor
fmt: ; $(info Running goimports to format the codebase...) @
@goimports -w -e $$(find . -type f -name '*.go' -not -path "*/vendor/*")
$(LINT_BIN): ; $(info Getting lint...) @
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.41.1
lint: $(LINT_BIN) ; $(info Running lint...) @
CGO_LDFLAGS_ALLOW="-Wl,-z,now" CGO_LDFLAGS="${BUILDER_LINKER_FLAGS}" $(LINT_BIN) --timeout 10m run
CGO_LDFLAGS_ALLOW="-Wl,-z,now" CGO_LDFLAGS="${BUILDER_LINKER_FLAGS}" go vet ./...
test: fmt lint $(info Running tests...)
# NOTE: make sure to export the values for the env variables in the terminal prompt before running the tests
export BYBIT_API_KEY=${BYBIT_API_KEY}
export BYBIT_API_SECRET=${BYBIT_API_SECRET}
CGO_ENABLED=0 go test -coverprofile cover.out ./...
CGO_ENABLED=0 go tool cover -html=cover.out -o cover.html
.PHONY: all
# NOTE: Install godoc to run this command: `go install golang.org/x/tools/cmd/godoc@latest`
docs:
godoc -http=:6060
tag:
@echo "[!!!] Releasing git tag ${TAG} [!!!]"
git tag ${TAG}
git push --tags
@echo "[!!!] Done! [!!!]"