-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
55 lines (39 loc) · 1.27 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
.PHONY: all
all: build fmt vet lint test
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor")
APP_EXECUTABLE="out/iap_auth"
COMMIT_HASH=$(shell git rev-parse --verify head | cut -c-1-8)
BUILD_DATE=$(shell date +%Y-%m-%dT%H:%M:%S%z)
setup:
go get -u github.com/golang/lint/golint
compile:
mkdir -p out/
go build -o $(APP_EXECUTABLE) -ldflags "-X main.Build=$(BUILD_DATE) -X main.Commit=$(COMMIT_HASH) -s -w"
build: compile fmt vet lint
install:
go install ./...
fmt:
go fmt ./...
vet:
go vet ./...
lint:
@if [[ `golint $(All_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } | wc -l | tr -d ' '` -ne 0 ]]; then \
golint $(ALL_PACKAGES) | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; }; \
exit 2; \
fi;
test: copy-config
go test ./...
test-cover-html:
@echo "mode: count" > coverage-all.out
$(foreach pkg, $(ALL_PACKAGES),\
go test -coverprofile=coverage.out -covermode=count $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o out/coverage.html
copy-config:
cp iap.conf.toml.sample iap.conf.toml
clean:
go clean && rm -rf ./vendor ./build
docker-up:
docker-compose up -d
start: docker-up compile
$(APP_EXECUTABLE) server