summaryrefslogtreecommitdiffstats
path: root/ci/lint.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/lint.sh')
-rwxr-xr-xci/lint.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/ci/lint.sh b/ci/lint.sh
new file mode 100755
index 00000000..f68c2c92
--- /dev/null
+++ b/ci/lint.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -u -e -x -o pipefail
+
+if [[ -n "${GOLANGCI_VERSION-}" ]]; then
+ # Retrieve the golangci-lint linter binary.
+ curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin ${GOLANGCI_VERSION}
+fi
+
+# Run the linter.
+golangci-lint run
+
+if [[ "${GO111MODULE-off}" == "on" ]]; then
+ # If Go modules are active then check that dependencies are correctly maintained.
+ go mod tidy
+ go mod vendor
+ git diff --exit-code --quiet || (echo "Please run 'go mod tidy' to clean up the 'go.mod' and 'go.sum' files."; false)
+fi