2018-02-16 23:38:45 +01:00
|
|
|
SOURCE_FILES?=./...
|
|
|
|
TEST_PATTERN?=.
|
|
|
|
TEST_OPTIONS?=
|
|
|
|
|
|
|
|
# Install all the build and lint dependencies
|
|
|
|
setup:
|
|
|
|
go get -u golang.org/x/tools/cmd/cover
|
|
|
|
go get -u github.com/caarlos0/bandep
|
2018-03-11 19:44:39 +01:00
|
|
|
go get -u gopkg.in/alecthomas/gometalinter.v2
|
|
|
|
ifeq ($(OS), Darwin)
|
|
|
|
brew install dep
|
|
|
|
else
|
|
|
|
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
|
|
endif
|
2018-02-16 23:38:45 +01:00
|
|
|
dep ensure
|
2018-03-11 19:44:39 +01:00
|
|
|
gometalinter.v2 --install
|
2018-02-16 23:38:45 +01:00
|
|
|
echo "make check" > .git/hooks/pre-commit
|
|
|
|
chmod +x .git/hooks/pre-commit
|
|
|
|
.PHONY: setup
|
|
|
|
|
2018-02-05 03:54:03 +01:00
|
|
|
check:
|
2018-02-16 23:38:45 +01:00
|
|
|
bandep --ban github.com/tj/assert
|
|
|
|
.PHONY: check
|
2018-02-05 03:54:03 +01:00
|
|
|
|
2018-02-16 23:38:45 +01:00
|
|
|
# Run all the tests
|
2018-02-05 03:54:03 +01:00
|
|
|
test:
|
2018-03-25 20:58:44 +02:00
|
|
|
go test $(TEST_OPTIONS) -v -coverpkg=./... -race -failfast -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=5m
|
2018-02-16 23:38:45 +01:00
|
|
|
.PHONY: cover
|
|
|
|
|
|
|
|
# Run all the tests and opens the coverage report
|
|
|
|
cover: test
|
|
|
|
go tool cover -html=coverage.txt
|
|
|
|
.PHONY: cover
|
|
|
|
|
|
|
|
# gofmt and goimports all go files
|
|
|
|
fmt:
|
|
|
|
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
|
|
|
|
.PHONY: fmt
|
|
|
|
|
|
|
|
# Run all the linters
|
|
|
|
lint:
|
2018-03-11 19:44:39 +01:00
|
|
|
gometalinter.v2 --vendor ./...
|
2018-02-16 23:38:45 +01:00
|
|
|
.PHONY: lint
|
|
|
|
|
|
|
|
# Run all the tests and code checks
|
|
|
|
ci: build test lint
|
|
|
|
.PHONY: ci
|
|
|
|
|
|
|
|
# Build a beta version of goreleaser
|
|
|
|
build:
|
|
|
|
go generate ./...
|
|
|
|
go build
|
|
|
|
.PHONY: build
|
|
|
|
|
|
|
|
# Show to-do items per file.
|
|
|
|
todo:
|
|
|
|
@grep \
|
|
|
|
--exclude-dir=vendor \
|
|
|
|
--exclude-dir=node_modules \
|
|
|
|
--exclude=Makefile \
|
|
|
|
--text \
|
|
|
|
--color \
|
2018-03-11 19:44:39 +01:00
|
|
|
-nRo -E ' TODO:.*|SkipNow' .
|
2018-02-16 23:38:45 +01:00
|
|
|
.PHONY: todo
|
|
|
|
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := build
|