From bcc4c863122ce07658d0c44fae3875c2c7a5ae97 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Thu, 6 Jun 2024 01:20:09 -0500 Subject: abuild: Implement a checkretry option This allows a test suite to be retried automatically in case of flaky or unreliable tests upstream. The default retry count is 5, but can be set in abuild.conf with the variable `$ABUILD_RETRY_COUNT`. Closes: #15 --- APKBUILD.5 | 8 ++++++++ abuild.in | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/APKBUILD.5 b/APKBUILD.5 index af22a59..9baf772 100644 --- a/APKBUILD.5 +++ b/APKBUILD.5 @@ -298,6 +298,14 @@ Do not use this option. .It Cm !check Specifies that the package will not run a test suite. The reason for disabling the check phase should be noted in a comment. +.It Cm checkretry +Specifies that the package's test suite should be re-run multiple times in +case of failure. The reason should be noted in a comment. Note that this +option and +.Cm checkroot +cannot be used in the same package; +.Cm checkretry +will take precedence. .It Cm checkroot Specifies that the package's test suite will be run in .Xr fakeroot 8 . diff --git a/abuild.in b/abuild.in index 13e9824..932efb2 100644 --- a/abuild.in +++ b/abuild.in @@ -1557,6 +1557,9 @@ build_abuildrepo() { if options_has "checkx11"; then _check=check_x11 fi + if options_has "checkretry"; then + _check=check_retry + fi if ! want_check; then _check=true fi @@ -1853,6 +1856,16 @@ check_x11() { env DISPLAY=:7 dbus-run-session "$abuild_path" $forceroot $color_opt $keep_build check } +# wrap check() with retries +check_retry() { + count=${ABUILD_RETRY_COUNT:=5} + (cd "$startdir"; + while test $((count=$(($count-1)))) -ge 0; do + msg "Trying check..." + check && exit 0; + done; exit 1) +} + # build and package in fakeroot rootpkg() { cd "$startdir" -- cgit v1.2.3-70-g09d2