From b02b418f8f5a16480f013bf876ab44a5ee0f2900 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Thu, 17 Dec 2020 15:58:09 +0100 Subject: [PATCH] migrate lint script to a mage target --- .travis.yml | 2 +- magefile.go | 11 +++++++++++ travis/lint.sh | 7 ------- 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100755 travis/lint.sh diff --git a/.travis.yml b/.travis.yml index 57845ca..1d8a09f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ install: - ./travis/install.sh script: - go run mage.go -v crossBuild - - ./travis/lint.sh + - go run mage.go lint - export GOMAXPROCS=4 - export GORACE=halt_on_error=1 - go test -race -v ./... diff --git a/magefile.go b/magefile.go index 78f9103..02e05de 100644 --- a/magefile.go +++ b/magefile.go @@ -5,6 +5,8 @@ package main import ( "encoding/json" "fmt" + "os" + "path" "github.com/magefile/mage/mg" "github.com/magefile/mage/sh" @@ -58,3 +60,12 @@ func CrossBuild() error { } return nil } + +func Lint() error { + gopath := os.Getenv("GOPATH") + if gopath == "" { + return fmt.Errorf("cannot retrieve GOPATH") + } + + return sh.Run(path.Join(gopath, "bin", "golangci-lint"), "run", "./...") +} diff --git a/travis/lint.sh b/travis/lint.sh deleted file mode 100755 index 98fb5bb..0000000 --- a/travis/lint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -if [[ "$TRAVIS_GO_VERSION" =~ ^1\.15\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then - $(go env GOPATH)/bin/golangci-lint run ./... -else - echo "linter has not been run" -fi