-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (56 loc) · 1.63 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
# Variables shared between targets
APP_NAME := Blockchain Lab
APP_DESCRIPTION := Learn about blockchain technology
APP_VERSION := 1.0.0
GO_PROJECT := github.com/samuelvl/blockchain-lab
BIN_PATH := bin
BIN_NAME := blockchain-lab
##@ General
.PHONY: help
help: ## Display this help.
@awk 'BEGIN { \
FS = ":.*##"; \
printf "\nUsage:\n make \033[36m<target>\033[0m\n" \
} \
/^[a-zA-Z_0-9-]+:.*?##/ { \
printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 \
} \
/^##@/ { \
printf "\n\033[1m%s\033[0m\n", substr($$0, 5) \
} ' $(MAKEFILE_LIST)
##@ Golang dependency management
.PHONY: update-deps download-deps deps
update-deps: ## Update go.mod with last dependencies versions.
$(info • Updating dependencies...)
@go get -v -u all
download-deps: ## Download dependencies in the vendor folder.
$(info • Downloading vendor dependencies...)
@go mod tidy -v
@go mod vendor -v
deps: update-deps download-deps
##@ Golang testing
.PHONY: test
test: ## Run unit tests.
$(info • Running unit tests...)
@go test ./pkg/... -v \
-race \
-covermode=atomic -coverprofile=test/coverage.out \
-bench=^Benchmark.* -benchtime 5s -count 1
##@ Golang building
.PHONY: build
build: ## Generate binaries.
$(info • Generating $(BIN_NAME) binary...)
@go build \
-work \
-race \
-o $(BIN_PATH)/$(BIN_NAME)
##@ Golang execution
.PHONY: run
run: ## Run the app locally.
@sh -c '$(BIN_PATH)/$(BIN_NAME)'
##@ Documentation
.PHONY: docs
docs: ## Generate documentation using gomarkdoc tool.
$(info • Generating code documentation...)
@rm -rf docs/pkg/*
@gomarkdoc --output 'docs/{{.Dir}}/GODOC.md' ./pkg/...