generated from Yandex-Practicum/go-musthave-metrics-tpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (46 loc) · 1.42 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
API_DOCS = docs/api
AGENT_VERSION ?= 0.1.0
SERVER_VERSION ?= 0.1.0
BUILD_DATE ?= $(shell date +%F\ %H:%M:%S)
BUILD_COMMIT ?= $(shell git rev-parse --short HEAD)
build: agent server staticlint
.PHONY: build
agent: ## build agent
go build \
-ldflags "\
-X 'main.buildVersion=$(AGENT_VERSION)' \
-X 'main.buildDate=$(BUILD_DATE)' \
-X 'main.buildCommit=$(BUILD_COMMIT)' \
" \
-o cmd/$@/$@ \
cmd/$@/*.go
.PHONY: agent
server: ## build server
rm -rf $(API_DOCS)
swag init -g ./internal/httpserver/router.go --output docs/api
go build \
-ldflags "\
-X 'main.buildVersion=$(SERVER_VERSION)' \
-X 'main.buildDate=$(BUILD_DATE)' \
-X 'main.buildCommit=$(BUILD_COMMIT)' \
" \
-o cmd/$@/$@ \
cmd/$@/*.go
.PHONY: server
staticlint: ## build static lint
go build -o cmd/$@/$@ cmd/$@/*.go
.PHONY: staticlint
clean: ## remove build artifacts
rm -rf cmd/agent/agent cmd/server/server cmd/staticlint/staticlint
.PHONY: clean
unit-tests: ## run unit tests
@go test -v -race ./... -coverprofile=coverage.out.tmp -covermode atomic
@cat coverage.out.tmp | grep -v -E "(_mock|.pb).go" > coverage.out
@go tool cover -html=coverage.out -o coverage.html
@go tool cover -func=coverage.out
.PHONY: unit-tests
godoc: ### show public packages documentation using godoc
@echo "Project documentation is available at:"
@echo "http://127.0.0.1:3000/pkg/github.com/ex0rcist/metflix/pkg/\n"
@godoc -http=:3000 -play
.PHONY: godoc