Skip to main content

ci: post-receive checks should fail with exit code 1 if tests fail

ID
dd014bb
date
2026-05-14 06:29:39+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
04a9d5e
message
ci: post-receive checks should fail with exit code 1 if tests fail
changed files
1 file, 5 additions, 7 deletions

Changed files

ci/run_post_receive_checks.sh (717) → ci/run_post_receive_checks.sh (687)

diff --git a/ci/run_post_receive_checks.sh b/ci/run_post_receive_checks.sh
index c3e0a63..5a60981 100755
--- a/ci/run_post_receive_checks.sh
+++ b/ci/run_post_receive_checks.sh
@@ -1,5 +1,8 @@
 #!/usr/bin/env bash
 
+set -o errexit
+set -o nounset
+
 if (( $# != 1 )); then
   echo "Usage: $0 REPO_NAME" >&2
   exit 1
@@ -8,10 +11,6 @@ fi
 # REPO_NAME is the name of the repository to run tests for
 REPO_NAME="$1"
 
-print_purple() {
-    echo -e "\033[35m-> $@\033[0m"
-}
-
 NOW=$(date +'%Y-%m-%dT%H-%M-%S')
 LOG_NAME="$REPO_NAME.$NOW.log"
 LOG_PATH="$TMPDIR/$LOG_NAME"
@@ -21,12 +20,11 @@ touch $LOG_PATH
 echo "Running tests"
 echo "Follow logs: tail -f \$TMPDIR/$LOG_NAME"
 
-bash ~/repos/scripts/ci/post_receive_tests.sh "$REPO_NAME" > $LOG_PATH 2>&1
-
-if (( $? == 0 )); then
+if bash ~/repos/scripts/ci/post_receive_tests.sh "$REPO_NAME" > $LOG_PATH 2>&1; then
   print_success "Post-receive tests passed!"
 else
   print_error "Post-receive tests failed!"
   cp "$LOG_PATH" ~/Desktop/$REPO_NAME.$NOW.failed.log
   print_error "See logs: cat ~/Desktop/$REPO_NAME.$NOW.failed.log"
+  exit 1
 fi