1
0
Fork 1

Conform to sh & run full tests

remotes/1715175271555336803/main
gravel 2 years ago
parent 0c72d17e6a
commit 1b896b7666
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -16,7 +16,7 @@ sco: fetch html
# Refresh listing, generate HTML and update listing provider.
all:
/bin/php php/update-listing.php
/bin/php php/update-listing.php $(FLAGS)
# Fetch room listing.
fetch:
@ -83,7 +83,7 @@ test-noninteractive: FLAGS = --verbose
test-noninteractive: clean all
# Run Continuous Integration tests.
test-ci: FLAGS = --verbose --fast --no-color
test-ci: FLAGS = --verbose --no-color
test-ci: clean all
# -- Aliases --

@ -1,20 +1,22 @@
#!/bin/bash
#!/bin/sh
root="$(pwd)"
branch=$(git symbolic-ref HEAD 2>/dev/null || echo "?")
branch="${branch##refs/heads/}"
# Only test changes on main branch
if ! [ "$branch" = "main" ]; then
exit 0;
fi
# Trigger cleanup if tests are interrupted.
cleanup() {
echo -e "\033[31mTests aborted.\033[0m"
printf "\033[31mTests aborted.\033[0m"
rm -rf "$root/.test";
exit;
}
trap cleanup SIGHUP SIGINT SIGABRT SIGTERM;
trap cleanup HUP INT ABRT TERM;
cat <<EOF
I see you've committed to $branch! Time to test.
@ -22,22 +24,37 @@ I see you've committed to $branch! Time to test.
EOF
# Remove test directory if present.
rm -rf "$root/.test"
# Make and change into test directory.
mkdir "$root/.test" || exit;
cd "$root/.test" || exit;
# Clone the current repository into the test directory and change into it.
git clone .. repo 2>> "$root/.test/results"
cd "$root/.test/repo" 2>> "$root/.test/results" || exit;
if make test-ci &>> "$root/.test/results"; then
touch "$root/.test/results";
# Run tests and show certain lines of output if successful.
if make test-ci > "$root/.test/results" 2>&1; then
grep 'Done fetching communities' -A1 --color=no "$root/.test/results";
grep -E 'Generated [[:digit:]]+ listings' -B1 --color=no "$root/.test/results";
cat <<EOF
Tests passed.
Run \`make dev\` to test it yourself.
Run \`make dev\` to test the webpage yourself.
EOF
else
echo -e "\033[31mTests failed.\033[0m";
# Show end of output if tests were not successful.
printf "\033[31mTests failed.\033[0m";
tail -n10 "$root/.test/results";
echo "See $root/.test/results for the full log."
exit;
exit 1;
fi
# Forget the cloned repository has version control to decrease clutter.
rm -rf "$root/.test/repo/.git" || exit;
# Return to main repository
cd "$root" || exit;
# rm -rf .test