-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
103 lines (78 loc) · 2.66 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
# FILE IS AUTOMATICALLY MANAGED BY github.com/vegaprotocol/terraform//github
export REPO_NAME := liqbot
export GO111MODULE := on
ifeq ($(CI),)
# Not in CI
VERSION := dev-$(USER)
VERSION_HASH := $(shell git rev-parse HEAD | cut -b1-8)
else
# In CI
ifneq ($(RELEASE_VERSION),)
VERSION := $(RELEASE_VERSION)
else
# No tag, so make one
VERSION := $(shell git describe --tags 2>/dev/null)
endif
VERSION_HASH := $(shell echo "$(GITHUB_SHA)" | cut -b1-8)
endif
GO_FLAGS := -ldflags "-X main.Version=$(VERSION) -X main.VersionHash=$(VERSION_HASH)"
.PHONY: build
build: ## install the binary in GOPATH/bin
@env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v -o bin/${REPO_NAME} ./cmd/${REPO_NAME}
.PHONY: build-simple
build-simple:
@env go build -v -o bin/${REPO_NAME} ./cmd/${REPO_NAME}
.PHONY: all
default: deps build test lint
.PHONY: coverage
coverage:
@go test -covermode=count -coverprofile="coverage.txt" ./...
@go tool cover -func="coverage.txt"
.PHONY: docker
docker: ## Build docker image
@docker build -t vegaprotocol/${REPO_NAME}:local .
.PHONY: coveragehtml
coveragehtml: coverage
@go tool cover -html=coverage.txt -o coverage.html
.PHONY: deps
deps: ## Get the dependencies
@go mod download
.PHONY: install
install:
@go install $(GO_FLAGS) ./cmd/${REPO_NAME}
.PHONY: release-ubuntu-latest
release-ubuntu-latest:
@mkdir -p build
@env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/${REPO_NAME}-linux-amd64 $(GO_FLAGS) ./cmd/${REPO_NAME}
@cd build && zip ${REPO_NAME}-linux-amd64.zip ${REPO_NAME}-linux-amd64
.PHONY: release-macos-latest
release-macos-latest:
@mkdir -p build
@env GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/${REPO_NAME}-darwin-amd64 $(GO_FLAGS) ./cmd/${REPO_NAME}
@cd build && zip ${REPO_NAME}-darwin-amd64.zip ${REPO_NAME}-darwin-amd64
.PHONY: release-windows-latest
release-windows-latest:
@env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -v -o build/${REPO_NAME}-amd64.exe $(GO_FLAGS) ./cmd/${REPO_NAME}
@cd build && 7z a -tzip ${REPO_NAME}-windows-amd64.zip ${REPO_NAME}-amd64.exe
.PHONY: lint
lint:
@golangci-lint run -v --config .golangci.toml
.PHONY: mocks
mocks: ## Make mocks
@find -name '*_mock.go' -print0 | xargs -0r rm
@go generate ./...
.PHONY: race
race: ## Run data race detector
@env CGO_ENABLED=1 go test -race ./...
.PHONY: retest
retest: ## Force re-run of all tests
@go test -count=1 ./...
.PHONY: test
test: ## Run tests
@go test ./...
.PHONY: clean
clean: ## Remove previous build
@rm -f ./bin/${REPO_NAME}
.PHONY: help
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'