From 31aac83bad79a69b36527d4e6812885c67d46163 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Sat, 5 Jan 2019 14:54:17 +1100 Subject: [PATCH] travis: use Makefile (#181) Add a bunch of useful makefile targets Signed-off-by: Dave Cheney --- .travis.yml | 2 +- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.travis.yml b/.travis.yml index d4b9266..3569e24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,4 @@ go: - tip script: - - go test -v ./... + - make check diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..46ecb35 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +PKGS := github.com/pkg/errors +SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS)) +GO := go + +check: test vet gofmt unused misspell unconvert gosimple ineffassign + +test: + $(GO) test $(PKGS) + +vet: | test + $(GO) vet $(PKGS) + +staticcheck: + $(GO) get honnef.co/go/tools/cmd/staticcheck + staticcheck $(PKGS) + +unused: + $(GO) get honnef.co/go/tools/cmd/unused + unused -exported $(PKGS) + +misspell: + $(GO) get github.com/client9/misspell/cmd/misspell + misspell \ + -locale GB \ + -error \ + *.md *.go + +unconvert: + $(GO) get github.com/mdempsky/unconvert + unconvert -v $(PKGS) + +gosimple: + $(GO) get honnef.co/go/tools/cmd/gosimple + gosimple $(PKGS) + +ineffassign: + $(GO) get github.com/gordonklaus/ineffassign + find $(SRCDIRS) -name '*.go' | xargs ineffassign + +pedantic: check unparam errcheck staticcheck + +unparam: + $(GO) get mvdan.cc/unparam + unparam ./... + +errcheck: + $(GO) get github.com/kisielk/errcheck + errcheck $(PKGS) + +gofmt: + @echo Checking code is gofmted + @test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)"