-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
45 lines (35 loc) · 1.33 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
PACKAGES=$(shell go list ./... | grep -v /vendor)
help: ## Print help text.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
install: # Install depencies.
@go get -u github.com/golang/dep/cmd/dep
@dep ensure
@go get -u github.com/golang/lint/golint
@go get -u github.com/kisielk/errcheck
@go get -u github.com/client9/misspell/cmd/misspell
lint: ## Check code using various linters and static checkers.
@echo "Running gofmt..."
@gofmt -d $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@echo "Running go vet..."
@for package in $(PACKAGES); do \
go vet -v $$package || exit 1; \
done
@echo "Running golint..."
@for package in $(PACKAGES); do \
golint -set_exit_status $$package || exit 1; \
done
@echo "Running errcheck..."
@for package in $(PACKAGES); do \
errcheck -ignore 'Close' -ignoretests $$package || exit 1; \
done
@echo "Running misspell..."
@for package in $(PACKAGES); do \
misspell -error $$package; \
done
test: ## Run unit tests and print test coverage.
@for package in $(PACKAGES); do \
touch .coverage.out; \
go test -race -coverprofile .coverage.out $$package && go tool cover -func=.coverage.out || exit 1; \
rm .coverage.out; \
done
.PHONY: help install lint test