-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·58 lines (44 loc) · 1.61 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
# Include go binaries into path
export PATH := $(GOPATH)/bin:$(PATH)
BUILD=$(shell date +%FT%T)
VERSION= $(shell git rev-parse --short HEAD)
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD}"
SOURCE_PATH :=TEST_SOURCE_PATH=$(PWD)
GOBIN := $(PWD)/bin/
ENV:=GOBIN=$(GOBIN)
install: mod ## Run installing
@echo "Environment installed"
test: ## Run test covering
$(SOURCE_PATH) go test -coverprofile=$(PWD)/coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
rm coverage.out
build: mod ## Build the server
@echo "Build version $(VERSION)/$(BUILD)"
go build ${LDFLAGS} -o ./application ./main.go
run: build ## Run the server
./application
clean: clean-local clean-vendor clean-cache ## Remove build artifacts
clean-local: ## Remove build artifacts
@echo "clean started..."
rm -f application
rm -f application.zip
rm -f coverage.out
rm -f coverage.html
@echo "clean complete!"
clean-cache: ## Clean golang cache
@echo "clean-cache started..."
go clean -cache
go clean -testcache
@echo "clean-cache complete!"
clean-vendor: ## Remove vendor folder
@echo "clean-vendor started..."
rm -fr ./vendor
@echo "clean-vendor complete!"
mod: ## Download all dependencies
@echo "======================================================================"
@echo "Run MOD...."
GO111MODULE=on GONOSUMDB="*" GOPROXY=direct go mod tidy
GO111MODULE=on GONOSUMDB="*" GOPROXY=direct go mod vendor
GO111MODULE=on GONOSUMDB="*" GOPROXY=direct go mod download
GO111MODULE=on GONOSUMDB="*" GOPROXY=direct go mod verify
@echo "======================================================================"