git-lfs/script/cibuild
brian m. carlson a487e7c3b7
script/cibuild: install scutiger during tests
Scutiger is our reference git-lfs-transfer implementation, so let's
install it during CI, clean up after tests, ignore our temporary
directory, and add code to appropriately make use of the binary in
tests.

If Scutiger is not available, let the tests pass unless we're in CI,
where we should always have the binary available.  Also, skip the tests
when the repository is a SHA-256 repository, since Scutiger uses
libgit2, which doesn't yet support SHA-256 repositories.
2021-07-20 19:16:00 +00:00

59 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
# Strip out CI environment variables which cause tests to fail.
unset $(env | grep -E '^GIT(HUB)?_' | grep -v '^GIT_DEFAULT_HASH=' | sed -e 's/=.*$//')
UNAME=$(uname -s)
X=""
if [[ $UNAME == MINGW* || $UNAME == MSYS* || $UNAME == CYGWIN* ]]; then
X=".exe"
WINDOWS=1
export GIT_LFS_NO_TEST_COUNT=1
export GIT_LFS_LOCK_ACQUIRE_DISABLED=1
fi
# Build git-lfs-transfer from scutiger.
cargo install --root t/scutiger scutiger-lfs
# Set GOPATH if it isn't already set.
eval "$(go env | grep GOPATH)"
go get golang.org/x/tools/cmd/goimports
GOIMPORTS="$GOPATH/bin/goimports"
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
PROVE="prove"
PROVE_EXTRA_ARGS="-j9"
if [ "$WINDOWS" ]; 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..."
if git grep -lE '[[:space:]]+$' | \
grep -vE '(^vendor/|\.git/(objects/|index)|\.bat$)'
then
exit 1
fi
echo "Formatting files..."
# Building and installing goimports and goversioninfo will have modified go.mod
# and go.sum, so reset the branch before formatting.
git reset --hard
make GOIMPORTS="$GOIMPORTS" fmt
echo "Looking for files that are not formatted correctly..."
git status -s
[ -z "$(git status --porcelain)" ]