github.com/pachyderm/pachyderm@v1.13.4/etc/testing/lint.sh (about) 1 #!/usr/bin/env bash 2 3 set -e 4 5 GIT_REPO_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" 2>&1 > /dev/null && git rev-parse --show-toplevel) 6 cd "${GIT_REPO_DIR}" 7 8 # Collect untracked args into '\( -o -path abc -o -path def -o ... \) -prune' 9 # argument to be passed to 'find' 10 skip_paths=() 11 for file in $(git status --porcelain | grep '^??' | sed 's/^?? //'); do 12 # Convert to relative path, as required by -path 13 file="./$(realpath --relative-to="." "${file}")" 14 # 1. Always prefix with -o (i.e. don't fencepost; find always has an argument 15 # before skip_paths, so including the initial -o works whether skip_paths 16 # is empty or not 17 # 2. strip trailing slash as required by -path 18 skip_paths+=( -o -path "${file%/}" ) 19 done 20 21 go get -u golang.org/x/lint/golint 22 find "./src" \ 23 \( -path "*.pb.go" -o -path "*pkg/tar*" "${skip_paths[@]}" \) -prune -o -name '*.go' -print \ 24 | while read -r file; do 25 golint -set_exit_status "$file"; 26 done; 27 28 files=$(gofmt -l "${GIT_REPO_DIR}/src" || true) 29 if [[ -n "${files}" ]]; then 30 echo Files not passing gofmt: 31 tr ' ' '\n' <<< "$files" 32 exit 1 33 fi 34 35 go get honnef.co/go/tools/cmd/staticcheck 36 staticcheck "${GIT_REPO_DIR}/..." 37 38 # shellcheck disable=SC2046 39 find . \ 40 \( -path ./etc/plugin "${skip_paths[@]}" \) -prune -o -name "*.sh" -print \ 41 | while read -r file; do 42 shellcheck -e SC1091 -e SC2010 -e SC2181 -e SC2004 -e SC2219 "${file}" 43 done