From 2ca00a18c2a3077e1b10405825687e40bcec2036 Mon Sep 17 00:00:00 2001 From: mauriziovitale Date: Tue, 28 Mar 2023 12:24:40 +0100 Subject: [PATCH] Override the retryAfterBaseValue --- .github/workflows/integration.yml | 13 +++++++++++++ .gitignore | 4 +++- src/retry-options.ts | 6 +++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index db4ac38..5dd8d7c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -57,3 +57,16 @@ jobs: if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then exit 1 fi + + test-retry-after: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Test retry with after + uses: ./ + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + retries: 3 + retry-after: 999 + script: | + console.log('Exec the plugin', context.repo.owner); diff --git a/.gitignore b/.gitignore index 2a27592..3712a23 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /node_modules/ -!/.vscode/ \ No newline at end of file +!/.vscode/ +.DS_Store +.env \ No newline at end of file diff --git a/src/retry-options.ts b/src/retry-options.ts index d73b01b..46a3c93 100644 --- a/src/retry-options.ts +++ b/src/retry-options.ts @@ -5,7 +5,7 @@ import { RequestRequestOptions } from '@octokit/types' export type RetryOptions = { doNotRetry?: number[] enabled?: boolean - delay?: number + retryAfterBaseValue?: number } export function getRetryOptions( @@ -23,7 +23,7 @@ export function getRetryOptions( } if (retryAfter > 0) { - retryOptions.delay = retryAfter + retryOptions.retryAfterBaseValue = retryAfter } if (exemptStatusCodes.length > 0) { @@ -40,7 +40,7 @@ export function getRetryOptions( core.debug( `GitHub client configured with: (retries: ${requestOptions.retries - }, retryAfter: ${retryOptions.delay ?? 'octokit default: 1000' + }, retryAfterBaseValue: ${retryOptions.retryAfterBaseValue ?? 'octokit default: 1000' } retry-exempt-status-code: ${retryOptions?.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]' })` )