This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
73 lines (59 loc) · 1.76 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
73
BIN_DIR = bin
BIN_NAME = retrodep
BIN = $(BIN_DIR)/$(BIN_NAME)
PREFIX = /usr/local/bin
TOOLS = golang.org/x/tools/cmd/goimports golang.org/x/lint/golint github.com/mattn/goveralls
COVERPROFILE = profile.cov
GOBIN = $$GOPATH/bin
GOVERALLS = $(GOBIN)/goveralls
GOIMPORTS = $(GOBIN)/goimports
GOFMT = gofmt
GOLINT = $(GOBIN)/golint
DEFAULT_BRANCH = master
FILES_TO_CHECK = $(shell git diff --no-renames --name-status $(DEFAULT_BRANCH) -- | grep '\.go$$' | grep -v D | cut -f 2)
.PHONY: all clean deps test build fmt lint install check coveralls
all: build
clean:
@echo '\033[0;31mRemoving generated binaries\033[0m'; \
rm -rf $(BIN_DIR)
build:
@echo '\033[0;32mBuilding\033[0m'; \
go build -o $(BIN) ./main.go
install:
@echo 'Installing retrodep to \033[0;32m$(PREFIX)/$(BIN_NAME)\033[0m'; \
install $(BIN) $(PREFIX)/$(BIN_NAME)
tools:
@echo 'Installing \033[0;32m$(TOOLS)\033[0m'; \
for tool in $(TOOLS); do \
go get -u $$tool; \
done
test:
@echo 'Running \033[0;32mtests\033[0m'; \
go test . -v; \
go test ./retrodep/glide -v; \
go test ./retrodep -v -covermode=count -coverprofile=$(COVERPROFILE)
fmt:
@if test -n "$(FILES_TO_CHECK)"; then \
echo 'Running \033[0;32mgofmt\033[0m'; \
out=$$($(GOFMT) -l $(FILES_TO_CHECK)); \
echo $$out; \
test -z "$$out"; \
fi
lint:
@if test -n "$(FILES_TO_CHECK)"; then \
echo 'Running \033[0;32mgolint\033[0m'; \
out=$$($(GOLINT) $(FILES_TO_CHECK)); \
echo $$out; \
test -z "$$out"; \
fi
imports:
@if test -n "$(FILES_TO_CHECK)"; then \
echo 'Running \033[0;32mgoimports\033[0m'; \
out=$$($(GOIMPORTS) -l $(FILES_TO_CHECK)); \
echo $$out; \
test -z "$$out"; \
fi
check: fmt imports lint
coveralls:
@echo '\033[0;32mPublishing coverage\033[0m'; \
$(GOVERALLS) -coverprofile=$(COVERPROFILE) -service=travis-ci