mirror of
https://github.com/actions/github-script.git
synced 2026-04-08 07:00:05 +00:00
Fix null handling, covered by integration tests
`core.getInput()` always returns a string, so testing for 'not null' is always true. This then leads to previews set to an array with a single empty string, breaking accept-header output. Updated eslint rules should help avoid this issue in future, and new integration tests verify that the github client configuration now reflects the intended configuration options.
This commit is contained in:
parent
36d245c808
commit
454e5d7e69
6 changed files with 1523 additions and 1323 deletions
15
src/main.ts
15
src/main.ts
|
|
@ -6,10 +6,10 @@ import * as glob from '@actions/glob'
|
|||
import * as io from '@actions/io'
|
||||
import {retry} from '@octokit/plugin-retry'
|
||||
import {RequestRequestOptions} from '@octokit/types'
|
||||
import fetch from 'node-fetch'
|
||||
import {callAsyncFunction} from './async-function'
|
||||
import {getRetryOptions, parseNumberArray, RetryOptions} from './retry-options'
|
||||
import {wrapRequire} from './wrap-require'
|
||||
import fetch from 'node-fetch'
|
||||
|
||||
process.on('unhandledRejection', handleError)
|
||||
main().catch(handleError)
|
||||
|
|
@ -24,7 +24,7 @@ type Options = {
|
|||
|
||||
async function main(): Promise<void> {
|
||||
const token = core.getInput('github-token', {required: true})
|
||||
const debug = core.getInput('debug')
|
||||
const debug = core.getBooleanInput('debug')
|
||||
const userAgent = core.getInput('user-agent')
|
||||
const previews = core.getInput('previews')
|
||||
const retries = parseInt(core.getInput('retries'))
|
||||
|
|
@ -37,11 +37,12 @@ async function main(): Promise<void> {
|
|||
defaultGitHubOptions
|
||||
)
|
||||
|
||||
const opts: Options = {}
|
||||
if (debug === 'true') opts.log = console
|
||||
if (userAgent != null) opts.userAgent = userAgent
|
||||
if (previews != null) opts.previews = previews.split(',')
|
||||
if (retryOpts) opts.retry = retryOpts
|
||||
const opts: Options = {
|
||||
retry: retryOpts
|
||||
}
|
||||
if (debug) opts.log = console
|
||||
if (userAgent) opts.userAgent = userAgent
|
||||
if (previews) opts.previews = previews.split(',')
|
||||
if (requestOpts) opts.request = requestOpts
|
||||
|
||||
const github = getOctokit(token, opts, retry)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export function getRetryOptions(
|
|||
`GitHub client configured with: (retries: ${
|
||||
requestOptions.retries
|
||||
}, retry-exempt-status-code: ${
|
||||
retryOptions?.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]'
|
||||
retryOptions.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]'
|
||||
})`
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue