-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (50 loc) · 1.52 KB
/
Makefile
File metadata and controls
65 lines (50 loc) · 1.52 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
61
62
63
64
65
TEST?=./...
GOFMT_FILES?=$$(find . -not -path "./vendor/*" -type f -name '*.go')
PKG_PREFIX=github.com/Vungle/vungo
PKGS=$(PKG_PREFIX)/openrtb $(PKG_PREFIX)/vast
export GO111MODULE=on
default: test
# build
build:
go build $(PKGS)
# test runs the unit tests
test:
go test $(TESTARGS) ./...
# generate runs `go generate` to build the dynamically generated source files.
generate:
@echo PATH=$$PATH
find . -name '*_easyjson.go' -delete
go generate ./...
check_git_diff: go_mod_tidy
@if git diff --quiet; then echo "All commited"; else echo "Error: Not commit yet"; git diff; exit 1; fi
check_generate: check_git_diff generate
@if git diff --quiet; then echo "OK, generate is not needed."; else echo "Error: need generate."; git diff; exit 1; fi
go_mod_tidy:
@echo PATH=$$PATH
go mod tidy
fmt:
gofmt -w $(GOFMT_FILES)
golint:
@warnings=$$(golint $(TEST)); \
if [ -n "$$warnings" ]; then \
echo "golint reports warnings:"; \
echo "$$warnings"; \
exit 1; \
else \
echo "golint pass"; \
fi
vet:
go vet -printfuncs="Verbose,Verbosef,Info,Infof,Warning,Warningf,Error,Errorf,Fatal,Fatalf" $(TEST)
imports:
@warnings=$$(find . -name "*.go" -not -name "*_easyjson.go" | xargs goimports -l -w); \
if [ -n "$$warnings" ]; then \
echo "goimports reports warnings:"; \
echo "$$warnings"; \
exit 1; \
else \
echo "goimports no change"; \
fi
lint: imports vet golint
# disallow any parallelism (-j) for Make.
.NOTPARALLEL:
.PHONY: build check_git_diff check_generate fmt generate golint imports lint precommit test vet