git-lfs/script/cibuild
brian m. carlson 4d5a56a1fb
script: check for trailing whitespace as part of CI
Since we'd like to avoid trailing whitespace in our codebase, help
developers catch issues by checking for trailing whitespace during CI.
Exclude the vendor directory, as we don't want to change vendored code,
and exclude any git objects or indices we store in the repository, since
they're binary zlib-compressed data.  Exclude batch files as well, since
they contain carriage returns, which are considered non-linefeed
whitespace on Unix.

Note that we use git grep -E, since not all versions of git grep are
compiled with PCRE for the -P option.  Fortunately, POSIX provides a
character class that matches all whitespace.
2018-10-04 14:18:44 +00:00

36 lines
955 B
Bash
Executable File

#!/usr/bin/env bash
set -e
GOIMPORTS="goimports"
if [ "appveyor" = "$USERNAME" ]; then
GOIMPORTS="C:\\Users\\appveyor\\go\\bin\\goimports"
fi
make GOIMPORTS="$GOIMPORTS" && make GOIMPORTS="$GOIMPORTS" test
# re-run test to ensure GIT_TRACE output doesn't leak into the git package
GIT_TRACE=1 make GOIMPORTS="$GOIMPORTS" PKGS=git test
pushd t >/dev/null
UNAME=$(uname -s)
X=""
if [[ $UNAME == MINGW* || $UNAME == MSYS* || $UNAME == CYGWIN* ]]; then
X=".exe"
fi
PROVE="prove"
PROVE_EXTRA_ARGS="-j9"
if [ "appveyor" = "$USERNAME" ]; then
export PATH="/c/Strawberry/perl/bin:.:$PATH"
PROVE="prove.bat"
PROVE_EXTRA_ARGS="$PROVE_EXTRA_ARGS --exec bash"
fi
VERBOSE_LOGS=1 make X="$X" clean
VERBOSE_LOGS=1 make X="$X" PROVE="$PROVE" PROVE_EXTRA_ARGS="$PROVE_EXTRA_ARGS"
popd >/dev/null
echo "Looking for trailing whitespace..."
! git grep -lE '[[:space:]]+$' | \
grep -vE '(^vendor/|\.git/(objects/|index)|\.bat$)'