Created
January 28, 2021 12:02
-
-
Save arussellsaw/ffae08315d0d45c8111467020908a7a5 to your computer and use it in GitHub Desktop.
go test your diff with emoji
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "⏱ pre-commit tests" | |
STAGED_GO_FILES=$(git diff HEAD --name-only -- '*.go') | |
> /tmp/testdirs | |
for file in $STAGED_GO_FILES; do | |
dir=$(dirname "$file") | |
echo "./$dir" >> /tmp/testdirs | |
done | |
if [ -s /tmp/testdirs ] | |
then | |
packages=$(cat /tmp/testdirs | sort| uniq) | |
echo "🎁 testing packages:" | |
echo "$packages" | |
gotestsum --hide-summary=skipped --format dots $packages | |
if [ $? -eq 0 ] | |
then | |
echo "✅ done" | |
exit 0 | |
else | |
echo "❌ something went wrong 🤔" | |
exit 1 | |
fi | |
else | |
echo "👀 nothing to test" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment