( retries: number, exemptStatusCodes: number[], defaultOptions: OctokitOptions )
| 8 | } |
| 9 | |
| 10 | export function getRetryOptions( |
| 11 | retries: number, |
| 12 | exemptStatusCodes: number[], |
| 13 | defaultOptions: OctokitOptions |
| 14 | ): [RetryOptions, RequestRequestOptions | undefined] { |
| 15 | if (retries <= 0) { |
| 16 | return [{enabled: false}, defaultOptions.request] |
| 17 | } |
| 18 | |
| 19 | const retryOptions: RetryOptions = { |
| 20 | enabled: true |
| 21 | } |
| 22 | |
| 23 | if (exemptStatusCodes.length > 0) { |
| 24 | retryOptions.doNotRetry = exemptStatusCodes |
| 25 | } |
| 26 | |
| 27 | // The GitHub type has some defaults for `options.request` |
| 28 | // see: https://github.com/actions/toolkit/blob/4fbc5c941a57249b19562015edbd72add14be93d/packages/github/src/utils.ts#L15 |
| 29 | // We pass these in here so they are not overidden. |
| 30 | const requestOptions: RequestRequestOptions = { |
| 31 | ...defaultOptions.request, |
| 32 | retries |
| 33 | } |
| 34 | |
| 35 | core.debug( |
| 36 | `GitHub client configured with: (retries: ${ |
| 37 | requestOptions.retries |
| 38 | }, retry-exempt-status-code: ${ |
| 39 | retryOptions.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]' |
| 40 | })` |
| 41 | ) |
| 42 | |
| 43 | return [retryOptions, requestOptions] |
| 44 | } |
| 45 | |
| 46 | export function parseNumberArray(listString: string): number[] { |
| 47 | if (!listString) { |
no outgoing calls
no test coverage detected