-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (47 loc) · 1.78 KB
/
Makefile
File metadata and controls
60 lines (47 loc) · 1.78 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
# gohan Makefile
# ─── Version info injected at build time ─────────────────────────────────────
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
LDFLAGS = -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
# ─── Paths ────────────────────────────────────────────────────────────────────
BIN = gohan
CMD = ./cmd/gohan
COVERAGE = coverage.out
.PHONY: all build test lint serve clean install coverage help
## all: build the binary (default target)
all: build
## build: compile the gohan binary with version ldflags
build:
go build -ldflags "$(LDFLAGS)" -o $(BIN) $(CMD)
## install: install gohan to GOPATH/bin
install:
go install -ldflags "$(LDFLAGS)" $(CMD)
## test: run all tests with the race detector
test:
go test -race -count=1 ./...
## coverage: run tests and report total coverage percentage
coverage:
go test -race -coverprofile=$(COVERAGE) -covermode=atomic -count=1 ./...
@echo ""
@go tool cover -func=$(COVERAGE) | grep total
## lint: run golangci-lint
lint:
golangci-lint run ./...
## vet: run go vet
vet:
go vet ./...
## serve: start the development server (requires config.yaml in current directory)
serve: build
./$(BIN) serve
## clean: remove build outputs and cache
clean:
rm -f $(BIN)
rm -f $(COVERAGE)
rm -rf dist/
rm -rf .gohan/
## help: print this help message
help:
@echo "Usage: make <target>"
@echo ""
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'