-
Notifications
You must be signed in to change notification settings - Fork 80
/
Makefile
68 lines (53 loc) · 1.5 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
.PHONY: default install build build-cross clean test quicktest fmt vet lint install-deps update-deps clean-deps
default: fmt vet lint build quicktest
run:
go run ./cmd/audit2rbac/audit2rbac.go
install-deps:
go mod vendor
build/update-vendor-notices.sh
update-deps:
go mod vendor
build/update-vendor-notices.sh
clean-deps:
rm -fr vendor
build: check_go_version
go build -o bin/audit2rbac $(shell ./build/print-ldflags.sh) ./cmd/audit2rbac
build-cross: check_go_version
./build/build-cross.sh cmd/audit2rbac/audit2rbac.go
install:
go install $(shell ./build/print-ldflags.sh) ./cmd/audit2rbac
clean:
rm -fr bin
test:
go test -v -race -cover ./pkg/...
quicktest:
go test ./pkg/...
# Capture output and force failure when there is non-empty output
fmt:
@echo gofmt -l ./pkg
@OUTPUT=`gofmt -l ./pkg 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "gofmt must be run on the following files:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
vet:
go vet -atomic -bool -copylocks -nilfunc -printf -rangeloops -unreachable -unsafeptr -unusedresult ./pkg
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
# Capture output and force failure when there is non-empty output
lint:
@echo golint ./pkg/...
@OUTPUT=`golint ./pkg/... 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "golint errors:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
check_go_version:
@OUTPUT=`go version`; \
if [[ "$$OUTPUT" != *"go1.13."* ]]; then \
echo "Expected: go version go1.11.*"; \
echo "Found: $$OUTPUT"; \
exit 1; \
fi