Repository navigation
Description
Update: We have implemented CI Build Retry, as explained in this video:
Is your feature request related to a problem? Please describe.
We did a Quantitative Analysis of our Most Expensive PR (in terms of GitHub Runner Usage). We discovered that our CI Jobs are failing too often due to the Failed Downloading of Build Dependencies...
Which causes Developer Frustration and Wasted GitHub Runners. We propose to implement Retry for CI Builds, so that the Build Dependencies will be successfully downloaded when we retry a build. This means that a NuttX Target like pinephone:nsh will be rebuilt when it fails.
Describe the solution you'd like
@simbit18 Would you be able to implement this solution? It's not so urgent, but we need more time to test it thoroughly. Please lemme know thanks :-)
- Explained here:
Apache NuttX RTOS: Retrying a CI Build
Apache NuttX RTOS: Testing of Retry for CI Builds - We retry
dotest5 times in case of failure. We could implement a new wrapper functionretrytestthat will retrydotest5 times. (dotestbuilds a Single NuttX Target likepinephone:nsh) - For Simplicity: We will retry on Any Failure: Download Failed, Compile Error, ...
- Each Retry will have a Random Exponential Backoff. Retry 1: Wait randomly 0 to 60 seconds. Retry 2: Wait randomly 0 to 120 seconds. Retry 3: Wait randomly 0 to 240 seconds. Etc
- We will test at NuttX Mirror Repo, though I think the Download Failures don't happen so often at that repo
- We will also test at NuttX Build Farm, which has Download Failures much more often
Retry Logic looks like this, it refers to a Single NuttX Target like pinephone:nsh:
dotest is called here, which we can rename as retrytest:
Lines 582 to 597 in 76fe46a
| # Perform the build test for each entry in the test list file | |
| for line in $testlist; do | |
| firstch=${line:0:1} | |
| if [ "X$firstch" == "X/" ]; then | |
| 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"/} | |
| done | |
| else | |
| dotest $line | |
| fi | |
| done | |
Describe alternatives you've considered
We considered the alternatives explained in this video:
Verification
- I have verified before submitting the report.
Activity
simbit18 commentedon Mar 19, 2026
@lupyuen I’ve been looking for a solution to the problem of failed package downloads for a while now.
Here are some of my thoughts, the result of wracking my remaining brain cells :)
Simple solution
We use curl as our download tool, and it already offers a --retry option.
https://everything.curl.dev/usingcurl/downloads/retry.html
So we could use this method to retry X times.
Most comprehensive solution
A solution similar to the one used with espressif (esp-hal-3rdparty with git), but here with curl
add to the file https://github.com/apache/nuttx/blob/master/tools/Config.mk
When the same packages are downloaded repeatedly in a job, you can use the nxtmpdir folder
to avoid performing a second download.
Package storage is enabled as follows -S on [nuttx/.github/workflows/build.yml]
nuttx/tools/configure.sh
Line 35 in 201406b
You can use this system + a simple solution to try to reduce the likelihood of errors
Of course, here it is necessary to standardize all the logic for downloading packages.
(which is the right thing to do for proper maintenance)
I think the second is more comprehensive, but, we need the community to help!!!
We could launch an “adopt a .zip or .tar” campaign!!! :)
Your approach could also be another solution, but it has a different impact
on the time required for changes and testing.
Of course, if it’s a GitHub issue, no solution will fix the problem. :)
lupyuen commentedon Mar 19, 2026
Thanks @simbit18! Yeah we might have a problem getting NuttX Community to help with the curl fixes, which are highly intrusive and script-specific. And ultimately you and I will have to standby and make sure that every single fix works correctly :-)
Do you think we should go ahead to do the Build Retry our own (less intrusive) way, so we won't depend too much on NuttX Community? I'm just worried that the next Peak Period might come again soon, and we'll get into serious trouble with ASF Infra Team, if we use too many NuttX Runners :-(
lupyuen commentedon Mar 19, 2026
Sorry: Can curl do Random Exponential Backoff? I suspect a simple retry might not be sufficient, GitHub might still block our downloads, due to suspected spamming :-(
simbit18 commentedon Mar 19, 2026
Your solution is a good one, but it takes a lot of time, which I don't have right now.
lupyuen commentedon Mar 19, 2026
Yeah I fully understand :-) Let's reopen this feature later when we're ready. It's really difficult to push any changes to NuttX CI because...
The next time NuttX runs out of GitHub Runners: Maybe you and I won't be around any more? Let's wait and see :-)
simbit18 commentedon Mar 19, 2026
@lupyuen Making changes is a very delicate matter.
Perhaps we need to consider a completely new system for CI, but that takes time.
Anyway, when is the next marathon? :)
lupyuen commentedon Mar 20, 2026
Wonder if this will work for retrying CI Builds? I'll test on NuttX Build Farm, since it fails Dependency Download quite often...
lupyuen13/nuttx@master...lupyuen13:nuttx:retry-build
simbit18 commentedon Mar 20, 2026
@lupyuen That sounds like a great solution!
It should work.
lupyuen commentedon Mar 22, 2026
Hmmm interesting: Our Retry Build reuses the Corrupted Zip File (from the previous download). So the Retry Build will always fail. Lemme try to clean up, delete all Zip Files, and discard any leftover files:
Here's the earlier log: https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/5971712#L1122
lupyuen commentedon Mar 22, 2026
Yep the Retry Build works OK for ESP32 Runtime Download yay! It succeeded at Build Attempt 5: https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/5971711#L1587
lupyuen commentedon Mar 23, 2026
This video explains our script for Retry for CI Builds. And how we're testing at NuttX Main Repo / NuttX Mirror Repo / NuttX Build Farm:
lupyuen commentedon Mar 25, 2026
I made new video:
Which explains:
lupyuen commentedon Mar 26, 2026
Here's the new video:
That explains:
acassis commentedon Mar 26, 2026
@lupyuen @simbit18 isn't it possible to create an instruction in our Dockerfile to include these downloadable files in some directory in the Docker and just copy it during the building? This way we avoid downloading them during the build phase and speed up the building time
lupyuen commentedon Mar 27, 2026
Here's another video:
That explains:
simbit18 commentedon Mar 27, 2026
@lupyuen The error in the MSVC job has been resolved with this PR #18069 by @xuxin930
lupyuen commentedon Mar 30, 2026
We have a new video:
That explains:
lupyuen commentedon Apr 1, 2026
NuttX Build Monitor is now up :-)
lupyuen commentedon Apr 2, 2026
Finally reproduced the Download Errors! But 5 retries are not enough, I'm increasing from 5 retries to 7 retries. The Download Bug is really persistent and highly inconsistent. It seems to happen when we don't have available GitHub Runners? https://github.com/apache/nuttx/actions/runs/23679432579/job/69628262067#step:10:1098
Then later within the same arm-05 CI Job: Another download fails: https://github.com/apache/nuttx/actions/runs/23679432579/job/69628262067#step:10:1722
Finally this broke the CI Job: Another download fails after 5 retries, that's why I'm increasing to 7 retries: https://github.com/apache/nuttx/actions/runs/23679432579/job/69628262067#step:10:2047
lupyuen commentedon Apr 3, 2026
This video explains how we're using the new NuttX Build Monitor to test the Retry of CI Builds. So far the results look promising!
During our testing: All Download Failures succeeded after retries, none of them exceeded 7 attempts, mostly 4 attempts:
sim:nxcameraOK after 7 attempts: libyuv download retry @ 2026-04-05 23:37:08qemu-armv8a:netnsh_smpOK after 4 attempts: OpenAMP libmetal download retryesp32s3-devkit:eth_lan9250OK after 3 attempts: Xtensa codeload.github download retryicicle:rpmsg-ch2OK after 2 attempts: OpenAMP libmetal download retrysim:matterOK after 2 attempts: LLVM libcxx download retrysim:matterOK after 2 attempts: NestLabs nlunit-test download retrynrf52832-dk:sdcOK after 2 attempts: nRFConnect sdk-nrfxlib download retryExcept for this failure:
sim:nxcamerafailed after 8 attempts: libyuv download retry @ 2026-04-07 22:55:11Why is sim:nxcamera failing so often?
See the next comment...
lupyuen commentedon Apr 8, 2026
Could this Download Failure be a problem with GitHub Actions? Shouldn't we escalate to GitHub?
Outside GitHub Actions: We see the same Download Failures happening in our NuttX Build Farm (see below). Thus it's not a problem specific to GitHub Actions. We should not assume that Dependency Downloads are perfect, we should always retry.
NuttX Build Farm
sim:nxcamera: libyuv download failed @ 2026-04-07 23:26:23NuttX Build Farm
sim:nxcamera: libyuv download failed @ 2026-04-06 07:38:39NuttX Build Farm
qemu-armv8a:netnsh_smp: argtable3 download failedNuttX Build Farm
sim:lua: lua download failedNuttX CI uses a Docker Container, in GitHub Actions and in NuttX Build Farm. Maybe our Docker Image isn't configured correctly for networking?
That's possible. However our team has no expertise to troubleshoot Docker Networking.
Why is sim:nxcamera failing so often?
sim:nxcameradownloads libyuv from chromium.googlesource.com, which seems to be fairly unreliable. We should find an alternative site for it. Alternatively: We cache libyuv inside the Release Downloads Section of the NuttX Mirror Repo.https://github.com/apache/nuttx-apps/blob/master/graphics/libyuv/Makefile#L32
Update: Here's the patch:
Isn't it easier to fix the curl command in our Build Scripts to do retry?
There are at least 73 curl commands in our Build Scripts. We will require significant effort to change and test all 73 curl commands: https://github.com/search?q=repo%3Aapache%2Fnuttx-apps+curl+language%3AMakefile&type=code&p=2&l=Makefile
FYI curl also supports Exponential Backoff (not randomised though): https://everything.curl.dev/usingcurl/downloads/retry.html#tweak-your-retries
lupyuen commentedon Apr 18, 2026
Download Retry failed twice today (after 4 attempts) at around the same time:
Update: Fix is here
First Failure
https://github.com/apache/nuttx/actions/runs/24605418871/job/71950832530#step:10:451
Note that Build Attempts 2, 3 and 4 don't redownload any files. They seem to be reusing a corrupted download. Do we need to delete these in our Retry Script?
Second Failure, around the same time
https://github.com/apache/nuttx/actions/runs/24605418871/job/71950832521#step:10:324
Note that Build Attempt 2 and 4 don't download any files. Do we need to remove these?
Restart The Build: Also failed (but OK after the next rebuild)
https://github.com/apache/nuttx/actions/runs/24605418871/job/71954440588#step:10:759
Again: Build Attempts 2, 3 and 4 don't download any files. They seem to be reusing a corrupted download. Do we need to delete these in our Retry Script?
Around the Same Time at NuttX Build Farm: Download Retry also failed
Is there something wrong with github.com downloads around that time?
https://gitlab.com/lupyuen/nuttx-build-log/-/snippets/5982188#L871
lupyuen commentedon Apr 23, 2026
So far the Download Retry works OK, successfully completing the CI Build (instead of terminating the build):
esp32s3-devkit:fastboot_tcpesp32s3-devkit:qemu_debugphoton:wlan-perfnrf5340-dk:rptun_cpunetphoton:wlanesp32-audio-kit:wifistm32f4discovery:canardsim:wamresp32-devkitc:cxxnrf5340-dk:rpmsghci_sdc_cpunetesp32c6-devkitm:sta_softapstm32f777zit6-meadow:f7corecompnrf52832-dk:mcuboot_loader_minimalgd32f470zk-eval:fmclfsnshsim:matterqemu-armv8a:xedge_demoqemu-armv8a:netnsh_smp_hvesp32s3-devkit:wifibl602evb:wifithingy53:rpmsghci_sdc_cpunetesp32c3-devkit:mcuboot_update_agentesp32s3-devkit:coremarkesp32s3-devkit:mbedtlsolimex-stm32-p407:mqttcstm32h750b-dk:lvglnrf52832-dk:sdc_nimblerv-virt:citesticicle:rpmsg-ch1esp32-devkitc:wifisim:wamrcanmv230:remoteesp32-devkitc:mcuboot_update_agentverdin-mx8mp:rpmsgraspberrypi-4b:lvglesp32c3-legacy-devkit:wifigd32f450zk-eval:spilfsnshesp32-devkitc:wifi_smpsim:rpproxy_uartgd32f470zk-eval:fmclfsnshgd32f470zk-eval:fmclfsnshsim:lvgl_fbstm32f103-minimum:adbnrf52832-dk:mcuboot_appsim:alsaspresense:rndis_smpesp32s2-saola-1:coremarkrv-virt:knetnsh64qemu-armv8a:fbgd32f470zk-eval:fmclfsnshimx93-qsb:rpmsgesp32-lyrat:rtptoolssim:tflmsabre-6quad:netnshesp32s2-saola-1:wifisim:rtptoolsesp32s2-kaluga-1:lvgl_ili9341rv-virt:netnshgd32f450zk-eval:fmclfsnshesp32c3-legacy-devkit:wifilckfb-szpi-esp32s3:fastboot_tcpnrf5340-dk:composite_cpuapp(LLM Analysis of Download Failures)
Do we have any cases of Download Retry failing after 4 attempts? Very few, it happens during a massive storm of GitHub Download Errors (Can we get compensated for Wasted GitHub Runners?)
teensy-4.x:lua-4.1esp32s3-devkit:blenucleo-f446re:systemviewsim:usbdevHas our usage of GitHub Runners gone up, now that Compile Errors and Config Errors are getting retried? Nope, we are only using 10 Full-Time GitHub Runners for the past month, that's 40% of our quota of 25 Full-Time GitHub Runners:
ESP-HAL-3rdParty might potentially fail due to
git cloneerrors, right now it says "Retry Scheduled", we need to monitor:We saw NTFC Install Errors (
git clonefailed), so the NTFC Script has been updated to implement retry:Which might be caused by this GitHub Incident
$ git clone -b release-0.0.1 https://github.com/szafonimateusz-mi/nuttx-testing fatal: unable to access 'https://github.com/szafonimateusz-mi/nuttx-testing/': The requested URL returned error: 500Docker Login could also fail! This normally happens when we click "Re-run Failed Jobs" and All Jobs start spamming ghci.io at the same time, with unlimited concurrency. To fix this: Click "Re-run All Jobs" instead, which will do "Fetch Source > Select Builds" with limited concurrency. https://github.com/apache/nuttx-apps/actions/runs/25719743252/job/75518073144#step:7:10
(More about Docker Login Retry)
To see the above Download Retries: Just filter by "Error" in NuttX Build Monitor. More details:
lupyuen commentedon Apr 27, 2026
FYI: "GitHub Copilot code review will start consuming GitHub Actions minutes on June 1, 2026"