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 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