mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-11-04 17:17:48 +00:00
* ci: one reduced build job on draft pull requests and manual runs * ci: reject manual runs on tags * ci: reduced job by job condition, tests only when selected * ci: test selection and retries in scripts/ci/run-tests.sh * ci: guide to reduced builds and test selection
39 lines
763 B
Bash
Executable File
39 lines
763 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
|
|
else
|
|
echo "Attempt $i failed, retrying..."
|
|
i=$((i + 1))
|
|
sleep 1
|
|
fi
|
|
done
|
|
if [ "$i" -gt "$attempts" ]; then
|
|
echo "All $attempts attempts failed."
|
|
exit 1
|
|
fi
|