From 4d5cf025d0f29a3ce1512f58d02d6f5df32a93d7 Mon Sep 17 00:00:00 2001 From: Michael Lesko-Krleza Date: Thu, 12 Aug 2021 22:02:18 -0400 Subject: [PATCH] test: misc: Update golangci-lint test to run only in CI --- .golangci.yml | 2 +- misc/make-deps.sh | 23 +++++++++++++++++++++-- test.sh | 5 ++++- test/test-golangci-lint.sh | 9 ++++----- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 71d1cdecca..f33c381b7b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,4 +14,4 @@ linters: enable: - goimports - revive # using revive instead of golint as it runs more quickly - - misspell \ No newline at end of file + - misspell diff --git a/misc/make-deps.sh b/misc/make-deps.sh index 8fed981ee3..3e8f5a1467 100755 --- a/misc/make-deps.sh +++ b/misc/make-deps.sh @@ -157,13 +157,32 @@ go get golang.org/x/lint/golint # for `golint`-ing go get golang.org/x/tools/cmd/goimports # for fmt go get github.com/kevinburke/go-bindata/go-bindata # for compiling in non golang files go get github.com/dvyukov/go-fuzz/go-fuzz # for fuzzing the mcl lang bits -# heavily recommended to use curl to install instead of go get under https://golangci-lint.run/usage/install/ -curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1 if in_ci; then go get -u gopkg.in/alecthomas/gometalinter.v1 && \ mv "$(dirname $(command -v gometalinter.v1))/gometalinter.v1" "$(dirname $(command -v gometalinter.v1))/gometalinter" && \ gometalinter --install # bonus + + # # heavily recommended to use curl to install instead of go get under https://golangci-lint.run/usage/install/ + # glc_version = "v1.42.0" + # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh > $(go env GOPATH)/bin/golangci-lint + # chmod +x $(go env GOPATH)/bin/golangci-lint + # # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh + # echo "THIS IS IN BIN!" + # ls $(go env GOPATH)/bin/ + # echo "THIS IS IN GOLANGCI-LINT!" + # ls $(go env GOPATH)/bin/golangci-lint + # # puts binary into $(go env GOPATH)/bin/golangci-lint + # # heavily recommended to install specific version of golangci-lint as per https://golangci-lint.run/usage/install/ + # # used to avoid breaking builds when new linter errors are introduced from a new release (minor or major) + # sh -s -- -b $(go env GOPATH)/bin/golangci-lint $glc_version + # sh -s -- -b $(go env GOPATH)/bin/golangci-lint v1.42.0 + + # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh > $(go env GOPATH)/bin/golangci-lint-install + chmod u+x $(go env GOPATH)/bin/golangci-lint-install + sh $(go env GOPATH)/bin/golangci-lint-install v1.42.0 + fi fold_end "Install golang tools" diff --git a/test.sh b/test.sh index 4f51b55232..6b78c03c17 100755 --- a/test.sh +++ b/test.sh @@ -67,7 +67,6 @@ if label-block "basic"; then run-testsuite ./test/test-examples.sh run-testsuite ./test/test-gotest.sh run-testsuite ./test/test-gometalinter.sh - run-testsuite ./test/test-golangci-lint.sh run-testsuite ./test/test-golint.sh # test last, because this test is somewhat arbitrary # FIXME: this now fails everywhere :( skip-testsuite ./test/test-reproducible.sh @@ -85,6 +84,9 @@ if in_ci; then run-testsuite ./test/test-gotest.sh --race run-testsuite ./test/test-integration.sh --race fi + if label-block "basic"; then + run-testsuite ./test/test-golangci-lint.sh + fi # XXX: fix and enable these on travis (sudo: go: command not found) #run-testsuite ./test/test-gotest.sh --root @@ -96,6 +98,7 @@ else REASON="CI server only test" skip-testsuite ./test/test-gotest.sh --race REASON="CI server only test" skip-testsuite ./test/test-integration.sh REASON="CI server only test" skip-testsuite ./test/test-integration.sh --race + REASON="CI server only test" skip-testsuite ./test/test-golangci-test.sh REASON="CI server only test" skip-testsuite ./test/test-gotest.sh --root REASON="CI server only test" skip-testsuite ./test/test-gotest.sh --root --race diff --git a/test/test-golangci-lint.sh b/test/test-golangci-lint.sh index 7ea4ced394..537a04c3e2 100755 --- a/test/test-golangci-lint.sh +++ b/test/test-golangci-lint.sh @@ -7,7 +7,7 @@ command -v golangci-lint >/dev/null 2>&1 || { echo >&2 "golangci-lint not found" # configure settings for test scripts ROOT=$(dirname "${BASH_SOURCE}")/.. -cd "${ROOT}" # Enter mgmt root +cd "${ROOT}" # enter mgmt root . test/util.sh failures='' @@ -17,7 +17,7 @@ function run-test() } # using .golangci.yml config file settings in ROOT -gcl='golangci-lint run' +glc='golangci-lint run' # commented out from gometalinter linter test # aligncheck, dupl, errcheck, gas, goconst, gocyclo, gotype, unconvert @@ -27,7 +27,6 @@ gcl='golangci-lint run' # safesql, staticcheck, structcheck, unparam, unused, varcheck for dir in `find * -maxdepth 9 -type d -not -path 'old/*' -not -path 'old' -not -path 'tmp/*' -not -path 'tmp' -not -path 'vendor/*' -not -path 'examples/*' -not -path 'test/*' -not -path 'interpolate/*'`; do - # doesn't acquire files individually, but treats them as a set of * files match="$dir/*.go" @@ -35,7 +34,7 @@ for dir in `find * -maxdepth 9 -type d -not -path 'old/*' -not -path 'old' -not continue # no *.go files found fi - run-test $gcl "$dir" || fail_test "golangci-lint did not pass" + run-test $glc "$dir" || fail_test "golangci-lint did not pass" done if [[ -n "$failures" ]]; then @@ -45,4 +44,4 @@ if [[ -n "$failures" ]]; then echo exit 1 fi -echo 'PASS' \ No newline at end of file +echo 'PASS'