From 1c66892837fb41909abce9c087001be7f39f0ffe Mon Sep 17 00:00:00 2001 From: Lup Yuen Lee Date: Sun, 22 Mar 2026 14:40:14 +0800 Subject: [PATCH 1/2] CI: Checkout from lupyuen13/nuttx Checkout from lupyuen13/nuttx Signed-off-by: Lup Yuen Lee --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b068964cda35e..e3ec50d90a448 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -97,8 +97,8 @@ jobs: - name: Checkout nuttx repo uses: actions/checkout@v6 with: - repository: apache/nuttx - ref: ${{ steps.gittargets.outputs.os_ref }} + repository: lupyuen13/nuttx + ref: retry-build path: sources/nuttx fetch-depth: 1 - name: Checkout nuttx repo tags From 3dc30d7929a3e0f35b87766d56f155f1c4c93ced Mon Sep 17 00:00:00 2001 From: Lup Yuen Lee Date: Fri, 20 Mar 2026 21:37:06 +0800 Subject: [PATCH 2/2] CI: Build and retry 5 times with Random Exponential Backoff Build and retry 5 times with Random Exponential Backoff Signed-off-by: Lup Yuen Lee --- tools/testbuild.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/tools/testbuild.sh b/tools/testbuild.sh index 6d80903155b1c..15d6874a9c9f4 100755 --- a/tools/testbuild.sh +++ b/tools/testbuild.sh @@ -580,6 +580,55 @@ function dotest { fi } +# Build one entry from the test list file. Retry 5 times on failure. + +function retrytest { + # Remember the Fail Status and clear it for each build + local line=$1 + local prevfail=$fail + local backoff=60 # Initial Exponential Backoff, in seconds + + # Build and retry 5 times on failure, with Random Exponential Backoff + local maxbuilds=6 + for ((i = 1; i <= $maxbuilds; i++)); do + echo "Build Attempt $i" + fail=0 + dotest $line + + # Don't retry if the build succeeded + if [ ${fail} -eq 0 ]; then + break + else + # Build Failed: Clean up any corrupted downloads, don't reuse + git -C $nuttx clean -fd + git -C $APPSDIR clean -fd + pushd $nuttx ; git status ; popd + pushd $APPSDIR ; git status ; popd + fi + + # If Previous Build already failed: No point retrying + if [ ${prevfail} -ne 0 ]; then + break + fi + + # If this is Final Retry: Don't wait + if [ $i -eq $maxbuilds ]; then + break + fi + + # Wait for Random Exponential Backoff, then retry + delay=$(( (RANDOM % $backoff) + 1 )) + echo "Wait $delay seconds ($backoff backoff)" + backoff=$(($backoff * 2)) + sleep $delay + done + + # Return the Previous Fail Status, unless this build failed + if [ ${fail} -eq 0 ]; then + fail=$prevfail + fi +} + # Perform the build test for each entry in the test list file for line in $testlist; do @@ -588,10 +637,10 @@ for line in $testlist; do dir=`echo $line | cut -d',' -f1` list=`find boards$dir -name defconfig | cut -d'/' -f4,6` for i in ${list}; do - dotest $i${line/"$dir"/} + retrytest $i${line/"$dir"/} done else - dotest $line + retrytest $line fi done