Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 51 additions & 2 deletions tools/testbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading