#!/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() { printf "\033[31mTests aborted.\033[0m\n"; rm -rf "$root/.test"; exit; } trap cleanup HUP INT ABRT TERM; cat <> "$root/.test/results" cd "$root/.test/repo" 2>> "$root/.test/results" || exit; 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 <