From 5261598a6f4a63045557d953c1663f90e0ddc96b Mon Sep 17 00:00:00 2001 From: John Weldon Date: Mon, 15 Oct 2018 13:26:12 -0700 Subject: [PATCH] Add go versions, make scripts more resilient --- .travis.yml | 30 ++++++++++++++++-------------- Makefile | 20 ++++++++++++++++++-- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d13417a8..1fc0f3ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,19 @@ +sudo: false language: go -env: - global: - - VET_VERSIONS="1.6 1.7 1.8 1.9 1.10 tip" - - LINT_VERSIONS="1.7 1.8 1.9 1.10 tip" go: - - "1.4" - - "1.5" - - "1.6" - - "1.7" - - "1.8" - - "1.9" - - "1.10" + - "1.4.x" + - "1.5.x" + - "1.6.x" + - "1.7.x" + - "1.8.x" + - "1.9.x" + - "1.10.x" + - "1.11.x" - tip + +git: + depth: 1 + matrix: fast_finish: true allow_failures: @@ -20,10 +22,10 @@ go_import_path: gopkg.in/ldap.v2 install: - go get gopkg.in/asn1-ber.v1 - go get code.google.com/p/go.tools/cmd/cover || go get golang.org/x/tools/cmd/cover - - go get github.com/golang/lint/golint || true + - go get github.com/golang/lint/golint || go get golang.org/x/lint/golint || true - go build -v ./... script: - make test - make fmt - - if [[ "$VET_VERSIONS" == *"$TRAVIS_GO_VERSION"* ]]; then make vet; fi - - if [[ "$LINT_VERSIONS" == *"$TRAVIS_GO_VERSION"* ]]; then make lint; fi + - make vet + - make lint diff --git a/Makefile b/Makefile index a9d351c7..0994d55f 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,23 @@ fmt: # Only run on go1.5+ vet: - go tool vet -atomic -bool -copylocks -nilfunc -printf -shadow -rangeloops -unreachable -unsafeptr -unusedresult . + @go tool -n vet >/dev/null 2>&1; \ + if [ $$? -eq 0 ]; then \ + echo "go vet" ; \ + go tool vet \ + -atomic \ + -bool \ + -copylocks \ + -nilfunc \ + -printf \ + -shadow \ + -rangeloops \ + -unreachable \ + -unsafeptr \ + -unusedresult \ + . ; \ + fi ; + # https://github.com/golang/lint # go get github.com/golang/lint/golint @@ -44,7 +60,7 @@ vet: # Only run on go1.5+ lint: @echo golint ./... - @OUTPUT=`golint ./... 2>&1`; \ + @OUTPUT=`command -v golint >/dev/null 2>&1 && golint ./... 2>&1`; \ if [ "$$OUTPUT" ]; then \ echo "golint errors:"; \ echo "$$OUTPUT"; \