.PHONY: all precommit setup lint test integration_test build run fix jenkins

all: setup lint test build

ENVIRONMENT ?= development

precommit: fix lint test build

setup:
	go get -u github.com/alecthomas/gometalinter
	go get -u golang.org/x/tools/cmd/goimports
	go get -u github.com/smartystreets/goconvey
	gometalinter --install

lint:
	gometalinter --vendor --min-confidence=.3 --tests --deadline=90s --disable-all -Egolint -Etest -Eineffassign -Etestify -Eunconvert -Estaticcheck -Egoconst -Egocyclo -Eerrcheck -Egofmt -Evet -Einterfacer -Estructcheck -Evetshadow -Egosimple -Egoimports -Evarcheck -Emisspell -Emaligned -Etest ./...

test:
	env ENVIRONMENT=$(ENVIRONMENT) go test -race ./...

fix:
	git ls-files -- \*.go | grep -v _vendor | xargs gofmt -s -w
	git ls-files -- \*.go | grep -v _vendor | xargs goimports -w

jenkins: setup lint test
