diff --git a/.github/regression.sh b/.github/regression.sh index 66e3767c8..e757cd1bd 100755 --- a/.github/regression.sh +++ b/.github/regression.sh @@ -2,7 +2,11 @@ # shellcheck shell=bash disable=SC2317 set -Eeuo pipefail -trap 'echo "Error at line $LINENO"' ERR + +# shellcheck disable=SC2016 +basic_err_string='echo "Error at line $LINENO"' +# shellcheck disable=SC2064 +trap "$basic_err_string" ERR nix --version df -h . @@ -188,6 +192,12 @@ _cleanup_testnet_on_interrupt() { # cleanup on Ctrl+C or error # shellcheck disable=SC2329 _interrupted() { + # Ignore further interrupts and errors during cleanup + trap '' SIGINT + # shellcheck disable=SC2064 + trap "$basic_err_string" ERR + set +e + # Do testnet cleanup only on interrupted testrun. When not interrupted, # cleanup is done as part of a testrun. _cleanup_testnet_on_interrupt || : @@ -238,7 +248,7 @@ MON_PID=$! # ensure cleanup on ANY exit (success, error, Ctrl-C, set -e, etc.) # shellcheck disable=SC2064 -trap "echo 'Stopping monitor'; kill $MON_PID 2>/dev/null || true" EXIT +trap "echo 'Stopping monitor'; kill ${MON_PID:-} 2>/dev/null || true" EXIT # Run tests and generate report @@ -283,7 +293,13 @@ if [ "${KEEP_CLUSTERS_RUNNING:-""}" = 1 ]; then read -r fi +# redefine the ERR trap to avoid interfering with cleanup +# shellcheck disable=SC2064 +trap "$basic_err_string" ERR +# ignore Ctrl+C during cleanup +trap '' SIGINT _cleanup +trap - SIGINT # prepare artifacts for upload in GitHub Actions if [ -n "${GITHUB_ACTIONS:-""}" ]; then diff --git a/.github/run_tests.sh b/.github/run_tests.sh index 83a1537d1..e1b41cf4d 100755 --- a/.github/run_tests.sh +++ b/.github/run_tests.sh @@ -54,7 +54,7 @@ EOF run_pytest() { if [ -n "${SESSION_TIMEOUT:-}" ]; then - local -a timeout_arr=( "--signal=INT" "--kill-after=0" "$SESSION_TIMEOUT" ) + local -a timeout_arr=( "--foreground" "--signal=INT" "--kill-after=0" "$SESSION_TIMEOUT" ) echo "Running: PYTEST_ADDOPTS='${PYTEST_ADDOPTS:-}' timeout ${timeout_arr[*]} pytest $*" timeout "${timeout_arr[@]}" pytest "$@" else