-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
60 lines (46 loc) · 1.14 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
SHELL=/usr/bin/env bash
BIN=bin/decompose
COP=cover.out
CMD=./cmd/decompose
ALL=./...
GIT_TAG=`git describe --abbrev=0 2>/dev/null || echo -n "no-tag"`
GIT_HASH=`git rev-parse --short HEAD 2>/dev/null || echo -n "no-git"`
BUILD_AT=`date +%FT%T%z`
LDFLAGS=-w -s \
-X main.buildDate=${BUILD_AT} \
-X main.gitVersion=${GIT_TAG} \
-X main.gitHash=${GIT_HASH}
export CGO_ENABLED=0
.PHONY: build
build: vet
@go build -trimpath -ldflags "${LDFLAGS}" -o "${BIN}" "${CMD}"
.PHONY: vet
vet:
@go vet "${ALL}"
.PHONY: test
test: vet
@CGO_ENABLED=1 go test -v -race -count 1 -tags=test \
-cover -coverpkg="${ALL}" -coverprofile="${COP}" \
"${ALL}"
.PHONY: test-update
test-update: test-clean
@echo "updating golden files..."
@go test -tags=test "./internal/builder" -update
.PHONY: test-clean
test-clean:
@echo "clean-up..."
@find . -name "*.golden" -delete
.PHONY: test-cover
test-cover: test
@go tool cover -func="${COP}"
.PHONY: lint
lint: vet
@golangci-lint run
.PHONY: markdown-fix
markdown-fix:
# https://github.com/executablebooks/mdformat
mdformat .
.PHONY: clean
clean:
[ -f "${BIN}" ] && rm "${BIN}"
[ -f "${COP}" ] && rm "${COP}"