-
Notifications
You must be signed in to change notification settings - Fork 88
/
Makefile
46 lines (36 loc) · 1006 Bytes
/
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
ROOT_PKG ?= "github.com/vartanbeno/go-reddit"
LIST_PKG := $(shell go list $(ROOT_PKG)/...)
# Tests
TEST_TIMEOUT ?= 20
.DEFAULT_GOAL := usage
# Print colorized log
define log
echo "\n\033[1;32m--- [$(@)] $(1) ---\033[0m\n"
endef
.PHONY: all
all: lint fmt vet test test-coverage
.PHONY: usage
usage:
@echo "make [all|fmt|vet|lint|test|test-coverage]"
.PHONY: fmt
fmt:
@$(call log,"Running formatter")
@go fmt $(LIST_PKG)
.PHONY: vet
vet:
@$(call log,"Running vet")
@go vet -all $(LIST_PKG)
.PHONY: lint
lint:
@$(call log,"Running linter")
@golint -set_exit_status $(LIST_PKG)
.PHONY: test
test: fmt vet lint
@$(call log,"Running tests")
@go test -v -race -short -timeout $(TEST_TIMEOUT)s $(ARGS) $(LIST_PKG)
.PHONY: test-coverage
test-coverage: fmt vet lint
@$(call log,"Running tests with coverage")
@go test -v -race -short -timeout $(TEST_TIMEOUT)s $(ARGS) -coverprofile=coverage.out $(LIST_PKG)
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out -o coverage.html