-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·71 lines (54 loc) · 1.42 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
NAME := go-minruby
VERSION := $(shell git describe --tags --abbrev=0)
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -X 'main.version=$(VERSION)' \
-X 'main.revision=$(REVISION)'
OK_COLOR = \033[0;32m
ERROR_COLOR = \033[0;31m
WARN_COLOR = \033[0;33m
NO_COLOR = \033[m
OK_STRING = "[OK]"
ERROR_STRING = "[ERROR]"
WARN_STRING = "[WARNING]"
## Build binaries and run
run: build
./go-minruby
## Build binaries
build:
go build -ldflags "$(LDFLAGS)"
## Initial Setup
setup:
go get github.com/golang/lint/golint
go get golang.org/x/tools/cmd/goimports
go get github.com/Songmu/make2help/cmd/make2help
go get github.com/rakyll/gotest
## Run tests
test:
if LATE_THRESHOLD_MIN=10 gotest ./... -v; then \
echo "$(OK_COLOR)$(OK_STRING) go test succeeded$(NO_COLOR)"; \
else \
echo "$(ERROR_COLOR)$(ERROR_STRING) go test failed$(NO_COLOR)n"; \
fi
## Show coverage
coverage:
for pkg in $$(go list ./...); do \
gotest $$pkg -coverprofile=$(basename $pkg).out ;\
done
for pkg in $$(go list ./...); do \
go tool cover -func=$(basename $pkg).out; \
done
## Lint source codes
lint:
go vet ./...
for d in $$(go list ./...); do \
golint -set_exit_status ${GOPATH}/src/$$d/*.go || exit $$?; \
done
## Format source codes
fmt:
for d in $$(go list ./...); do \
goimports -w ${GOPATH}/src/$$d; \
done
## Show help
help:
@make2help $(MAKEFILE_LIST)
.PHONY: git-hooks setup test coverage lint fmt build help