-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
70 lines (54 loc) · 1.26 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
APP = caldera
RELEASE ?= v0.2.5
RELEASE_DATE = $(shell date +%FT%T%Z)
PROJECT = github.com/takama/caldera
LDFLAGS = "-s -w \
-X $(PROJECT)/pkg/version.RELEASE=$(RELEASE) \
-X $(PROJECT)/pkg/version.DATE=$(RELEASE_DATE)"
GO_PKG = $(shell go list $(PROJECT)/pkg/...)
all: run
vendor: bootstrap
@echo "+ $@"
@go mod tidy
run: clean build
@echo "+ $@"
./${APP}
build: vendor test lint
@echo "+ $@"
@go build -a -ldflags $(LDFLAGS) -o $(APP) $(PROJECT)/cmd/caldera
test:
@echo "+ $@"
@go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}"go test -race -cover {{.Dir}}"{{end}}' $(GO_PKG) | xargs -L 1 sh -c
fmt:
@echo "+ $@"
@go list -f '"gofmt -w -s -l {{.Dir}}"' $(GO_PKG) | xargs -L 1 sh -c
imports:
@echo "+ $@"
@go list -f '"goimports -w {{.Dir}}"' ${GO_PKG} | xargs -L 1 sh -c
lint: bootstrap
@echo "+ $@"
@golangci-lint run ./...
version:
@./bumper.sh
clean:
@rm -f ./${APP}
HAS_LINT := $(shell command -v golangci-lint;)
HAS_IMPORTS := $(shell command -v goimports;)
bootstrap:
ifndef HAS_LINT
go install github.com/golangci/golangci-lint/cmd/[email protected]
endif
ifndef HAS_IMPORTS
go install golang.org/x/tools/cmd/goimports
endif
.PHONY: all \
vendor \
run \
build \
test \
fmt \
imports \
lint \
version \
clean \
bootstrap