Skip to content

Replace @action/github dependency with latest Octokit #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ uses the GitHub API and the workflow run context.
To use this action, provide an input named `script` that contains the body of an asynchronous JavaScript function call.
The following arguments will be provided:

- `github` A pre-authenticated
- `github`/`octokit` A pre-authenticated
[octokit/rest.js](https://octokit.github.io/rest.js) client with pagination plugins
- `context` An object containing the [context of the workflow
run](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts)
- `context` An object containing partial [context of the workflow run](./src/context.ts)
- `core` A reference to the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package
- `glob` A reference to the [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob) package
- `io` A reference to the [@actions/io](https://github.com/actions/toolkit/tree/main/packages/io) package
Expand All @@ -33,6 +32,11 @@ documentation.

## Breaking Changes

### V8

Version 8 of this action upgraded `@octokit/core` from v5 to v7, which could impact scripts that would
be impacted by those breaking changes.

### V7

Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions
Expand Down
44 changes: 4 additions & 40 deletions __test__/get-retry-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,30 @@ import {getRetryOptions} from '../src/retry-options'

describe('getRequestOptions', () => {
test('retries disabled if retries == 0', async () => {
const [retryOptions, requestOptions] = getRetryOptions(
0,
[400, 500, 502],
[]
)
const retryOptions = getRetryOptions(0, [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,
[400, 500, 502],
[]
)
const retryOptions = getRetryOptions(1, [400, 500, 502])

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

expect(requestOptions?.retries).toEqual(1)
})

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

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

expect(requestOptions?.retries).toEqual(1)
})

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

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

expect(requestOptions?.retries).toEqual(1)
})

test('requestOptions does not override defaults from @actions/github', async () => {
const [retryOptions, requestOptions] = getRetryOptions(1, [], {
request: {
agent: 'default-user-agent'
},
foo: 'bar'
})
const retryOptions = getRetryOptions(1, [])

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

expect(requestOptions?.retries).toEqual(1)
expect(requestOptions?.agent).toEqual('default-user-agent')
expect(requestOptions?.foo).toBeUndefined() // this should not be in the `options.request` object, but at the same level as `request`
})
})
Loading