lint: enable custom linters from go-lint project
This commit is contained in:
39
ops/build-lint.sh
Executable file
39
ops/build-lint.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
PROJECT_ROOT=$(cd "$SCRIPT_DIR/.." && pwd)
|
||||
cd "$PROJECT_ROOT" # .custom-gcl.yaml is only discovered in the project root.
|
||||
|
||||
# go-lint is public, but the public checksum database has not indexed it yet.
|
||||
# Preserve existing exclusions while fetching the module through the normal
|
||||
# proxy-then-direct resolution path.
|
||||
export GONOSUMDB="${GONOSUMDB:+$GONOSUMDB,}git.offline-twitter.com"
|
||||
|
||||
BIN="bin/golint"
|
||||
STAMP="bin/.golint.stamp"
|
||||
|
||||
# The pinned plugin version is recorded in .custom-gcl.yaml.
|
||||
current_stamp() {
|
||||
sha256sum .custom-gcl.yaml | cut -d' ' -f1
|
||||
}
|
||||
|
||||
if [ "$1" = "--if-needed" ] &&
|
||||
[ -x "$BIN" ] &&
|
||||
[ -f "$STAMP" ] &&
|
||||
[ "$(cat "$STAMP")" = "$(current_stamp)" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! [ -x "$(command -v golangci-lint)" ]; then
|
||||
echo "golangci-lint is not installed. Please install it from https://golangci-lint.run/welcome/install/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p bin
|
||||
echo "Building golint (golangci-lint + shared custom linters)..."
|
||||
golangci-lint custom
|
||||
current_stamp > "$STAMP"
|
||||
|
||||
echo "Done: $PROJECT_ROOT/$BIN"
|
||||
Reference in New Issue
Block a user