-
Notifications
You must be signed in to change notification settings - Fork 53
/
Makefile
73 lines (52 loc) · 1.8 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
.PHONY: all
all: build fmt vet lint test coverage
default: build fmt vet lint test
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor")
APP_EXECUTABLE="out/weaver-server"
COMMIT_HASH=$(shell git rev-parse --verify head | cut -c-1-8)
BUILD_DATE=$(shell date +%Y-%m-%dT%H:%M:%S%z)
setup:
GO111MODULE=on go get -u golang.org/x/lint/golint
GO111MODULE=on go get github.com/mattn/goveralls
compile:
mkdir -p out/
GO111MODULE=on go build -o $(APP_EXECUTABLE) -ldflags "-X main.BuildDate=$(BUILD_DATE) -X main.Commit=$(COMMIT_HASH) -s -w" ./cmd/weaver-server
build: deps compile fmt vet lint
deps:
GO111MODULE=on go mod tidy -v
install:
GO111MODULE=on go install ./...
fmt:
GO111MODULE=on go fmt ./...
vet:
GO111MODULE=on 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
GO111MODULE=on 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;)
GO111MODULE=on go tool cover -html=coverage-all.out -o out/coverage.html
copy-config:
cp weaver.conf.yaml.sample weaver.conf.yaml
clean:
go clean && rm -rf ./vendor ./build ./weaver.conf.yaml
docker-clean:
docker-compose down
docker-spec: docker-clean
docker-compose build
docker-compose run --entrypoint "make test" dev_weaver
docker-server:
docker-compose run --entrypoint "make local-server" dev_weaver
docker-up:
docker-compose up -d
local-server: compile
$(APP_EXECUTABLE) start
coverage:
goveralls -service=travis-ci