diff --git a/Makefile b/Makefile index 8fd541c..634f4f5 100644 --- a/Makefile +++ b/Makefile @@ -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 -- diff --git a/etc/hooks/post-commit b/etc/hooks/post-commit index 8d31e89..0999a7e 100755 --- a/etc/hooks/post-commit +++ b/etc/hooks/post-commit @@ -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 <> "$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 <