summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2024-06-06 01:20:09 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2024-06-06 21:42:58 -0500
commit16f63fb0e82e9028ba1b9b868c7743e31f3d3f32 (patch)
treef6c94f2aad7dc57231ec45ab00a1087325ef0bfa
parent63674cd048f2763638d155cf515be08cc41e99f9 (diff)
downloadabuild-awilfox/feature-15.tar.gz
abuild-awilfox/feature-15.tar.bz2
abuild-awilfox/feature-15.tar.xz
abuild-awilfox/feature-15.zip
abuild: Implement a checkretry optionawilfox/feature-15
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
-rw-r--r--APKBUILD.58
-rw-r--r--abuild.in16
2 files changed, 24 insertions, 0 deletions
diff --git a/APKBUILD.5 b/APKBUILD.5
index dc1c24b..1a6d27d 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 72a29b2..076824f 100644
--- a/abuild.in
+++ b/abuild.in
@@ -1533,6 +1533,9 @@ build_abuildrepo() {
if options_has "checkroot"; then
_check=check_fakeroot
fi
+ if options_has "checkretry"; then
+ _check=check_retry
+ fi
if ! want_check; then
_check=true
fi
@@ -1787,6 +1790,19 @@ check_fakeroot() {
do_fakeroot "$abuild_path" $forceroot $color_opt $keep_build check
}
+# wrap check() with retries
+check_retry() {
+ count=${ABUILD_RETRY_COUNT:=5}
+ (cd "$startdir";
+ try=1
+ while [ $try -le $count ]; do
+ msg "Test attempt $try of $count..."
+ check && exit 0
+ try=$(($try+1))
+ [ $try -gt $count ] && exit 1
+ done)
+}
+
# build and package in fakeroot
rootpkg() {
cd "$startdir"