diff --git a/Makefile b/Makefile index a74e492..402fc17 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,42 @@ +SOURCE_FILES?=$$(go list ./... | grep -v /vendor/) +TEST_PATTERN?=. +TEST_OPTIONS?= + +setup: + go get -u github.com/alecthomas/gometalinter + go get -u github.com/golang/dep/... + go get -u github.com/pierrre/gotestcover + go get -u golang.org/x/tools/cmd/cover + dep ensure + gometalinter --install --update + +test: + gotestcover $(TEST_OPTIONS) -covermode=count -coverprofile=coverage.out $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=30s + +cover: test + go tool cover -html=coverage.out + +fmt: + find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done + +lint: + gometalinter --vendor --disable-all \ + --enable=deadcode \ + --enable=ineffassign \ + --enable=gosimple \ + --enable=staticcheck \ + --enable=gofmt \ + --enable=goimports \ + --enable=dupl \ + --enable=misspell \ + --enable=errcheck \ + --enable=vet \ + --enable=vetshadow \ + --deadline=10m \ + ./... + +ci: lint test + docker-build: docker build -t caarlos0/domain_exporter . @@ -6,9 +45,4 @@ docker-push: docker: docker-build docker-push -test: - go test -v ./... - -setup: - go get -u github.com/golang/dep/cmd/dep - dep ensure -v +.DEFAULT_GOAL := build