forked from artberri/daddy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (59 loc) · 1.72 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
.PHONY: help all formatcheck format test vet lint qa coverage
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
FILES_WITHOUT_PROPER_FORMAT?=$$(gofmt -l -s ${GOFMT_FILES})
# Tools
BIN_DIR = $(GOPATH)/bin
GOLINT = $(BIN_DIR)/golint
$(GOLINT):
go get -u golang.org/x/lint/golint
help:
@echo ""
@echo "The following commands are available:"
@echo ""
@echo " make qa : Ensure project quality"
@echo " make format : Format the source code"
@echo " make formatcheck : Check if the source code has been formatted"
@echo " make vet : Look for suspicious constructs"
@echo " make test : Run tests"
@echo " make lint : Check for style errors"
@echo ""
all: help
formatcheck:
@echo "Checking file format..."
@if [ ! -z "$(FILES_WITHOUT_PROPER_FORMAT)" ]; then \
echo "The following files have formatting errors:"; \
echo "$(FILES_WITHOUT_PROPER_FORMAT)"; \
exit 1; \
else \
echo "OK"; \
fi;
format:
@echo "Formatting files..."
@gofmt -w -s $(GOFMT_FILES)
@echo "OK"
test:
@echo "Testing..."
@go test -i ./... || exit 1
@go test -timeout=60s -parallel=4 ./...
vet:
@echo "Looking for suspicious constructs..."
@go vet ./...
@echo "OK"
lint: $(GOLINT)
@echo "Checking for style errors..."
golint ./...
@test -z "$$(golint ./...)"
@echo "OK"
COVERAGE_DIR = coverage
COVERAGE_MODE = atomic
COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out
COVERAGE_HTML = $(COVERAGE_DIR)/index.html
coverage:
@echo "Running coverage..."
mkdir -p $(COVERAGE_DIR)
go test \
-covermode=$(COVERAGE_MODE) \
-coverprofile="$(COVERAGE_PROFILE)" ./...
go tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML)
qa: formatcheck vet lint test
qa-ci: formatcheck vet lint coverage