casaroli opened a new pull request, #21423:
URL: https://github.com/apache/nuttx/pull/21423

   ## Summary
   
   The depends-on steps of `build.yml`, `bluetooth.yml` and 
`membrowse-report.yml` read the PR description and the state of each dependency 
with `gh api`. The GitHub API fails sometimes for a short time: a network 
error, a 5xx answer, a rate limit, or an error page instead of JSON. For 
example, the `analyze (mirtoo, mirtoo:nsh, ...)` job of #21412 ended after one 
such answer, while the other analyze jobs of the same run read the same 
description at the same time:
   
   ```
   invalid character 'S' looking for beginning of value
   Error: Could not read the PR description.
   ```
   
   In `build.yml` and `bluetooth.yml` the same failure does not end the job, 
but the step uses the PR description of the event payload (an older one after 
an edit) or applies a dependency that is already merged.
   
   This PR adds `.github/scripts/gh_api_retry.sh` with `gh_api_retry()`, which 
takes the arguments of `gh api` and runs it again after 5, 10 and 20 seconds. 
It does not try again after HTTP 404 or 422, because the next try gives the 
same answer. The seven `gh api` calls of the three workflows use it. The error 
handling after each call does not change.
   
   ## Impact
   
   CI only. A run waits at most 35 seconds more when the API fails four times. 
No change to NuttX code.
   
   ## Testing
   
   - `gh_api_retry()` with a fake `gh` (sleep stubbed): an error page twice, 
then JSON: the third try succeeds and prints the body; HTTP 404: one try, 
return 1, the error on stderr; HTTP 503 always: four tries (5, 10, 20 s), 
return 1.
   - With the real `gh` on this PR's repository: `gh_api_retry 
repos/apache/nuttx/pulls/21412 --jq .number` prints 21412; `pulls/99999999` 
gives "Not Found (HTTP 404)" after one try.
   - `shellcheck -s bash .github/scripts/gh_api_retry.sh`: no warnings. 
`actionlint` on the three workflows: the same warnings as master, none new.
   - The CI of this PR runs the changed workflows.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to