This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (72 loc) · 1.74 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
SOURCES=$(shell find . -name "*.go" | grep -v vendor/)
PACKAGES=$(shell go list ./... | grep -v vendor/)
FGT := $(shell command -v fgt 2> /dev/null)
GOLINT := $(shell command -v golint 2> /dev/null)
ERRCHECK := $(shell command -v errcheck 2> /dev/null)
GO_CARPET := $(shell command -v go-carpet 2> /dev/null)
default: linters test
# build tools
build:
go build -o smaug cmd/smaug/*.go
.PHONY: build
# lint tools
linters: fmt lint
.PHONY: linters
linters-ci: linters-ci-get fmt-ci lint-ci vet-ci errcheck-ci
.PHONY: linters-ci
linters-ci-get:
ifndef FGT
go get -u github.com/GeertJohan/fgt
endif
ifndef GOLINT
go get -u github.com/golang/lint/golint
endif
ifndef ERRCHECK
go get -u github.com/kisielk/errcheck
endif
.PHONY: linters-ci-get
fmt:
gofmt -s -w $(SOURCES)
.PHONY: fmt
fmt-ci:
fgt gofmt -l $(SOURCES)
.PHONY: fmt-ci
lint:
go list ./... | grep -v vendor/ | grep -v Generated | xargs -L1 golint
.PHONY: lint
lint-ci:
go list ./... | grep -v vendor/ | grep -v Generated | xargs -L1 fgt golint
.PHONY: lint-ci
vet:
go tool vet -composites=false $(SOURCES)
.PHONY: vet
vet-ci:
fgt go tool vet -composites=false $(SOURCES)
.PHONY: vet-ci
errcheck:
errcheck -ignore Close $(PACKAGES)
.PHONY: errcheck
errcheck-ci:
$(FGT) errcheck -ignore Close $(PACKAGES)
.PHONY: errcheck-ci
# testing
test:
go test -v $(PACKAGES)
.PHONY: test
test-ci: linters-ci
GORACE="halt_on_error=1" go test -race -v $(PACKAGES)
.PHONY: test-ci
# code coverage
cov:
ifndef GO_CARPET
go get -u github.com/msoap/go-carpet
endif
go-carpet -256colors | less -R
.PHONY: cov
cov-rm:
rm go-carpet-coverage*
.PHONY: cov-rm
publish:
go get github.com/goreleaser/goreleaser
./scripts/goreleaser.yaml.sh "$(LD_RELEASE_FLAGS)" >/tmp/gorel.yaml
goreleaser --config /tmp/gorel.yaml