Files
simplex-chat/scripts/ci/run-tests.sh
T
Evgeny @ SimpleX Chat f2dd8b6231 ci: limit each test attempt to 35 minutes (#7900)
* ci: limit each test attempt to 35 minutes

* ci: reword the timed-out attempt line in the CI guide
2026-10-29 22:08:01 +00:00

42 lines
853 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [ "$#" -eq 0 ]; then
echo "usage: $0 <test command>" >&2
exit 1
fi
if [ -n "${PR_BODY:-}" ]; then
TESTS=$(printf '%s\n' "$PR_BODY" | tr -d '\r' | awk '/^```ci-tests[ \t]*$/ {f = 1; next} /^```[ \t]*$/ {f = 0} f')
fi
args=()
while read -r p; do
if [ -n "$p" ]; then args+=(-m "$p"); fi
done <<< "${TESTS:-}"
if [ "${#args[@]}" -gt 0 ]; then
args+=(--fail-on=empty)
elif [ "${REDUCED:-}" = true ]; then
echo "No tests selected"
exit 0
fi
i=1
attempts=${ATTEMPTS:-1}
while [ "$i" -le "$attempts" ]; do
if "$@" "${args[@]}"; then
break
elif [ "$?" -eq 124 ]; then
echo "Attempt $i timed out."
fi
if [ "$i" -lt "$attempts" ]; then
echo "Attempt $i failed, retrying..."
sleep 1
fi
i=$((i + 1))
done
if [ "$i" -gt "$attempts" ]; then
echo "Attempt $attempts failed."
exit 1
fi