1.PHONY: all clean clean-coverage install install-dependencies install-tools lint test test-verbose test-with-coverage 2 3export ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) 4export PKG := github.com/sergi/go-diff 5export ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) 6 7$(eval $(ARGS):;@:) # turn arguments into do-nothing targets 8export ARGS 9 10ifdef ARGS 11 PKG_TEST := $(ARGS) 12else 13 PKG_TEST := $(PKG)/... 14endif 15 16all: install-tools install-dependencies install lint test 17 18clean: 19 go clean -i $(PKG)/... 20 go clean -i -race $(PKG)/... 21clean-coverage: 22 find $(ROOT_DIR) | grep .coverprofile | xargs rm 23install: 24 go install -v $(PKG)/... 25install-dependencies: 26 go get -t -v $(PKG)/... 27 go build -v $(PKG)/... 28install-tools: 29 # Install linting tools 30 go get -u -v golang.org/x/lint/... 31 go get -u -v github.com/kisielk/errcheck/... 32 33 # Install code coverage tools 34 go get -u -v github.com/onsi/ginkgo/ginkgo/... 35 go get -u -v github.com/modocache/gover/... 36 go get -u -v github.com/mattn/goveralls/... 37lint: 38 $(ROOT_DIR)/scripts/lint.sh 39test: 40 go test -race -test.timeout 120s $(PKG_TEST) 41test-verbose: 42 go test -race -test.timeout 120s -v $(PKG_TEST) 43test-with-coverage: 44 ginkgo -r -cover -race -skipPackage="testdata" 45