Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/github.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions .licenses/npm/@actions/http-client-1.0.11.dep.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .licenses/npm/@actions/http-client-2.0.1.dep.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .licenses/npm/@actions/http-client.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .licenses/npm/@octokit/core.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions .licenses/npm/@octokit/plugin-retry.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions .licenses/npm/@octokit/request.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .licenses/npm/bottleneck.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions __test__/get-retry-options.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import {getRetryOptions} from '../src/retry-options'

describe('getRequestOptions', () => {
test('retries disabled if retries == 0', async () => {
const [retryOptions, requestOptions] = getRetryOptions(0, 8, [
400,
500,
502
])

expect(retryOptions.enabled).toBe(false)
expect(retryOptions.doNotRetry).toBeFalsy()

expect(requestOptions.retries).toBeFalsy()
})

test('properties set if retries > 0', async () => {
const [retryOptions, requestOptions] = getRetryOptions(1, 8, [
400,
500,
502
])

expect(retryOptions.enabled).toBe(true)
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])

expect(requestOptions.retries).toEqual(1)
expect(requestOptions.retryAfter).toEqual(8)
})

test('properties set if retries > 0', async () => {
const [retryOptions, requestOptions] = getRetryOptions(1, 8, [
400,
500,
502
])

expect(retryOptions.enabled).toBe(true)
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])

expect(requestOptions.retries).toEqual(1)
expect(requestOptions.retryAfter).toEqual(8)
})

test('retryAfter can be set to zero', async () => {
const [retryOptions, requestOptions] = getRetryOptions(1, 0, [
400,
500,
502
])

expect(retryOptions.enabled).toBe(true)
expect(retryOptions.doNotRetry).toEqual([400, 500, 502])

expect(requestOptions.retries).toEqual(1)
expect(requestOptions.retryAfter).toEqual(0)
})

test('retryOptions.doNotRetry not set if doNotRetry isEmpty', async () => {
const [retryOptions, requestOptions] = getRetryOptions(1, 0, [])

expect(retryOptions.enabled).toBe(true)
expect(retryOptions.doNotRetry).toBeUndefined()

expect(requestOptions.retries).toEqual(1)
expect(requestOptions.retryAfter).toEqual(0)
})
})
11 changes: 10 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ inputs:
previews:
description: A comma-separated list of API previews to accept
result-encoding:
description: Either "string" or "json" (default "json")—how the result will be encoded
description: Either "string" or "json" (default "json")—how the result will be encoded
default: json
retries:
description: "The number of times to retry a request"
default: "0"
retry-after:
description: "The number of seconds between retries. No effect unless `retries` is set."
Comment thread
luketomlinson marked this conversation as resolved.
Outdated
default: "0"
Comment thread
luketomlinson marked this conversation as resolved.
Outdated
do-not-retry:
Comment thread
luketomlinson marked this conversation as resolved.
Outdated
description: "A comma separated list of status codes that will NOT be retried. Example: '400,500'. No effect unless `retries` is set."
Comment thread
luketomlinson marked this conversation as resolved.
Outdated
default: ""
outputs:
result:
description: The return value of the script, stringified with `JSON.stringify`
Expand Down
Loading