-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (52 loc) · 1.3 KB
/
Copy pathMakefile
File metadata and controls
77 lines (52 loc) · 1.3 KB
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
# Binary names
AGENT_BIN := mysql-pitr-agent
SERVER_BIN := mysql-pitr-server
OUTPUT_DIR := bin
# Go parameters
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOMOD := $(GOCMD) mod
GOLINT := golangci-lint
GOVET := $(GOCMD) vet
# Build flags
LDFLAGS := -ldflags="-s -w"
.PHONY: all build agent server test lint vet clean docker-build fmt
all: lint test build
# --- Build ---
build: agent server
agent:
$(GOBUILD) $(LDFLAGS) -o $(OUTPUT_DIR)/$(AGENT_BIN) ./cmd/agent
server:
$(GOBUILD) $(LDFLAGS) -o $(OUTPUT_DIR)/$(SERVER_BIN) ./cmd/server
# --- Test ---
test:
$(GOTEST) -v -race -count=1 ./...
test-short:
$(GOTEST) -short -count=1 ./...
test-race:
$(GOTEST) -race -count=1 ./...
test-cover:
$(GOTEST) -v -race -count=1 -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# --- Linting & Vet ---
lint:
$(GOLINT) run ./...
vet:
$(GOVET) ./...
# --- Clean ---
clean:
rm -rf $(OUTPUT_DIR) coverage.out coverage.html
# --- Docker ---
docker-build:
docker build -t $(AGENT_BIN):latest -f Dockerfile --target agent .
docker build -t $(SERVER_BIN):latest -f Dockerfile --target server .
# --- Format ---
fmt:
$(GOCMD) fmt ./...
# --- Dependencies ---
deps:
$(GOMOD) tidy
$(GOMOD) download
tidy:
$(GOMOD) tidy