-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.57 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
NAME = embdr
MAIN = cmd/${NAME}/main.go
SOURCES = $(wildcard *.go) $(wildcard cmd/emdbr/*.go)
COVERAGE = target/coverage.txt
LINT_REPORT = target/lint.txt
BINARY = target/${NAME}
MODULES = go.sum
MOD_FILE = go.mod
export GOBIN ?= $(shell go env GOPATH)/bin
TOOLS_DIR := target/tools/
GOLANGCI_LINT := ${TOOLS_DIR}github.com/golangci/golangci-lint/cmd/[email protected]
REVIEWDOG := ${TOOLS_DIR}github.com/reviewdog/reviewdog/cmd/[email protected]
GORELEASER := ${TOOLS_DIR}github.com/goreleaser/[email protected]
${GOLANGCI_LINT} ${REVIEWDOG}:
@echo Installing ${@}...
@cd $(shell mktemp -d); GO111MODULE=on go get $(@:${TOOLS_DIR}%=%)
@mkdir -p $(dir ${@})
@cp ${GOBIN}/$(firstword $(subst @, ,$(notdir ${@}))) ${@}
all: ${MODULES} ${COVERAGE} ${BINARY}
build: ${BINARY}
${BINARY}: ${SOURCES}
@mkdir -p target
go generate ./...
CGO_ENABLED=0 go build -o ${@} ${MAIN}
modules: ${MODULES}
${MODULES}: ${SOURCES} ${MOD_FILE}
go mod tidy
go get ./...
test: ${COVERAGE}
${COVERAGE}: ${SOURCES}
@mkdir -p target
go test -race -coverprofile=${@} -covermode=atomic ./...
lint: ${LINT_REPORT}
${LINT_REPORT}: ${SOURCES} ${GOLANGCI_LINT}
${GOLANGCI_LINT} run --out-format=line-number --enable-all --disable=wsl,gomnd,lll ./... 2>&1 | tee ${LINT_REPORT}
.PHONY: review
review: ${LINT_REPORT} ${REVIEWDOG}
cat ${LINT_REPORT} | ${REVIEWDOG} -f=golangci-lint -reporter=github-check
.PHONY: verify-no-changes
verify-no-changes: ${BINARY}
${BINARY} -p embdr -o template.go template.tmpl
git diff --name-status --exit-code
.PHONY: release
release: ${GORELEASER}
clean:
rm -rf target