#!/usr/bin/env bash # # Runs every test in this repo and prints one passed/skipped/failed total. # Not wired to any `.gitea/workflows` -- see the README for why, the same # reasoning weblib-ci#9 recorded for that repo: run it by hand before # pushing. # # bash run_tests.sh # # check_zip_alignment.py's and next_version_code.py's own suites need only # python3 (via with-nixpkgs.sh, since none is assumed to be on PATH); # everything else additionally needs apksigner/fdroidserver/jdk21/awscli2, # resolved through the same pin. All of it stays on loopback/local-store -- # nothing here reaches a real host, bucket or key, except the opt-in live # section inside test_publish.sh, which stays skipped unless # FDROID_CI_LIVE_BUCKET/FDROID_CI_LIVE_ENDPOINT and real credentials are set. set -uo pipefail here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) total_pass=0 total_skip=0 total_fail=0 any_hard_fail=0 run_python_suite() { local script=$1 echo "=== $script ===" local out if out=$(bash "$here/with-nixpkgs.sh" python3 python3 "$here/$script" -v 2>&1); then local n n=$(echo "$out" | grep -oE '^Ran [0-9]+ test' | grep -oE '[0-9]+') total_pass=$((total_pass + ${n:-0})) echo "$out" | tail -3 else total_fail=$((total_fail + 1)) any_hard_fail=1 echo "$out" fi echo } run_shell_suite() { local script=$1 echo "=== $script ===" local out rc=0 out=$(bash "$here/$script" 2>&1) || rc=$? echo "$out" local p s f p=$(echo "$out" | grep -oE '^passed=[0-9]+' | grep -oE '[0-9]+' | tail -1) s=$(echo "$out" | grep -oE 'skipped=[0-9]+' | grep -oE '[0-9]+' | tail -1) f=$(echo "$out" | grep -oE 'failed=[0-9]+' | grep -oE '[0-9]+' | tail -1) if [ -z "$p" ] && [ -z "$f" ]; then # the script itself crashed before reaching report_and_exit total_fail=$((total_fail + 1)) any_hard_fail=1 else total_pass=$((total_pass + ${p:-0})) total_skip=$((total_skip + ${s:-0})) total_fail=$((total_fail + ${f:-0})) [ "${f:-0}" -ne 0 ] && any_hard_fail=1 fi echo } run_python_suite test_check_zip_alignment.py run_python_suite test_next_version_code.py run_shell_suite test_with_nixpkgs.sh run_shell_suite test_sign_apk.sh run_shell_suite test_fdroid_update.sh run_shell_suite test_next_version_code.sh run_shell_suite test_publish.sh echo "====================================" echo "TOTAL: passed=$total_pass skipped=$total_skip failed=$total_fail" exit "$any_hard_fail"