Add post-commit CI hook
parent
d1961405b9
commit
ce5ba7706f
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
root="$(pwd)"
|
||||
branch=$(git symbolic-ref HEAD 2>/dev/null || echo "?")
|
||||
branch="${branch##refs/heads/}"
|
||||
|
||||
if ! [ "$branch" = "main" ]; then
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
cleanup() {
|
||||
echo -e "\033[31mTests aborted.\033[0m"
|
||||
rm -rf "$root/.test";
|
||||
exit;
|
||||
}
|
||||
|
||||
trap cleanup SIGHUP SIGINT SIGABRT SIGTERM;
|
||||
|
||||
cat <<EOF
|
||||
I see you've committed to $branch! Time to test.
|
||||
(Press ^C to abort.)
|
||||
|
||||
EOF
|
||||
|
||||
rm -rf "$root/.test"
|
||||
mkdir "$root/.test" || exit;
|
||||
cd "$root/.test" || exit;
|
||||
git clone .. repo 2>> "$root/.test/results"
|
||||
cd "$root/.test/repo" 2>> "$root/.test/results" || exit;
|
||||
if make test-ci &>> "$root/.test/results"; then
|
||||
grep 'Done fetching communities' -A1 --color=no "$root/.test/results";
|
||||
cat <<EOF
|
||||
Tests passed.
|
||||
Run \`make dev\` to test it yourself.
|
||||
EOF
|
||||
else
|
||||
echo -e "\033[31mTests failed.\033[0m";
|
||||
tail -n10 "$root/.test/results";
|
||||
echo "See $root/.test/results for the full log."
|
||||
exit;
|
||||
fi
|
||||
cd "$root" || exit;
|
||||
# rm -rf .test
|
Loading…
Reference in New Issue