mirror of https://github.com/actions/toolkit
prettier and add type
parent
ac336c5cf5
commit
c43f71bc5f
|
@ -306,7 +306,7 @@ export class DownloadHttpClient {
|
|||
destinationStream: fs.WriteStream,
|
||||
isGzip: boolean
|
||||
): Promise<void> {
|
||||
await new Promise((resolve, reject) => {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
if (isGzip) {
|
||||
const gunzip = zlib.createGunzip()
|
||||
response.message
|
||||
|
|
|
@ -92,7 +92,10 @@ export function getCacheVersion(
|
|||
// Add salt to cache version to support breaking changes in cache entry
|
||||
components.push(versionSalt)
|
||||
|
||||
return crypto.createHash('sha256').update(components.join('|')).digest('hex')
|
||||
return crypto
|
||||
.createHash('sha256')
|
||||
.update(components.join('|'))
|
||||
.digest('hex')
|
||||
}
|
||||
|
||||
export async function getCacheEntry(
|
||||
|
@ -227,9 +230,9 @@ async function uploadChunk(
|
|||
end: number
|
||||
): Promise<void> {
|
||||
core.debug(
|
||||
`Uploading chunk of size ${
|
||||
end - start + 1
|
||||
} bytes at offset ${start} with content range: ${getContentRange(
|
||||
`Uploading chunk of size ${end -
|
||||
start +
|
||||
1} bytes at offset ${start} with content range: ${getContentRange(
|
||||
start,
|
||||
end
|
||||
)}`
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('@actions/core/src/command', () => {
|
|||
afterEach(() => {})
|
||||
|
||||
afterAll(() => {
|
||||
process.stdout.write = originalWriteFunction as unknown as (
|
||||
process.stdout.write = (originalWriteFunction as unknown) as (
|
||||
str: string
|
||||
) => boolean
|
||||
})
|
||||
|
@ -51,7 +51,8 @@ describe('@actions/core/src/command', () => {
|
|||
command.issueCommand(
|
||||
'some-command',
|
||||
{
|
||||
name: 'percent % percent % cr \r cr \r lf \n lf \n colon : colon : comma , comma ,'
|
||||
name:
|
||||
'percent % percent % cr \r cr \r lf \n lf \n colon : colon : comma , comma ,'
|
||||
},
|
||||
''
|
||||
)
|
||||
|
@ -116,11 +117,11 @@ describe('@actions/core/src/command', () => {
|
|||
command.issueCommand(
|
||||
'some-command',
|
||||
{
|
||||
prop1: {test: 'object'} as unknown as string,
|
||||
prop2: 123 as unknown as string,
|
||||
prop3: true as unknown as string
|
||||
prop1: ({test: 'object'} as unknown) as string,
|
||||
prop2: (123 as unknown) as string,
|
||||
prop3: (true as unknown) as string
|
||||
},
|
||||
{test: 'object'} as unknown as string
|
||||
({test: 'object'} as unknown) as string
|
||||
)
|
||||
assertWriteCalls([
|
||||
`::some-command prop1={"test"%3A"object"},prop2=123,prop3=true::{"test":"object"}${os.EOL}`
|
||||
|
|
|
@ -150,7 +150,10 @@ describe('@actions/core/src/summary', () => {
|
|||
})
|
||||
|
||||
it('adds EOL', async () => {
|
||||
await summary.addRaw(fixtures.text).addEOL().write()
|
||||
await summary
|
||||
.addRaw(fixtures.text)
|
||||
.addEOL()
|
||||
.write()
|
||||
await assertSummary(fixtures.text + os.EOL)
|
||||
})
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ describe('@actions/exec', () => {
|
|||
expect(exitCode).toBe(0)
|
||||
})
|
||||
|
||||
it('Handles child process holding streams open', async function () {
|
||||
it('Handles child process holding streams open', async function() {
|
||||
const semaphorePath = path.join(
|
||||
getTestTemp(),
|
||||
'child-process-semaphore.txt'
|
||||
|
@ -403,7 +403,7 @@ describe('@actions/exec', () => {
|
|||
fs.unlinkSync(semaphorePath)
|
||||
}, 10000) // this was timing out on some slower hosted macOS runs at default 5s
|
||||
|
||||
it('Handles child process holding streams open and non-zero exit code', async function () {
|
||||
it('Handles child process holding streams open and non-zero exit code', async function() {
|
||||
const semaphorePath = path.join(
|
||||
getTestTemp(),
|
||||
'child-process-semaphore.txt'
|
||||
|
@ -457,7 +457,7 @@ describe('@actions/exec', () => {
|
|||
fs.unlinkSync(semaphorePath)
|
||||
}, 10000) // this was timing out on some slower hosted macOS runs at default 5s
|
||||
|
||||
it('Handles child process holding streams open and stderr', async function () {
|
||||
it('Handles child process holding streams open and stderr', async function() {
|
||||
const semaphorePath = path.join(
|
||||
getTestTemp(),
|
||||
'child-process-semaphore.txt'
|
||||
|
|
|
@ -267,7 +267,10 @@ export class ToolRunner extends events.EventEmitter {
|
|||
}
|
||||
|
||||
reverse += '"'
|
||||
return reverse.split('').reverse().join('')
|
||||
return reverse
|
||||
.split('')
|
||||
.reverse()
|
||||
.join('')
|
||||
}
|
||||
|
||||
private _uvQuoteCmdArg(arg: string): string {
|
||||
|
@ -347,7 +350,10 @@ export class ToolRunner extends events.EventEmitter {
|
|||
}
|
||||
|
||||
reverse += '"'
|
||||
return reverse.split('').reverse().join('')
|
||||
return reverse
|
||||
.split('')
|
||||
.reverse()
|
||||
.join('')
|
||||
}
|
||||
|
||||
private _cloneExecOptions(options?: im.ExecOptions): im.ExecOptions {
|
||||
|
@ -685,9 +691,8 @@ class ExecState extends events.EventEmitter {
|
|||
}
|
||||
|
||||
if (!state.processClosed && state.processExited) {
|
||||
const message = `The STDIO streams did not close within ${
|
||||
state.delay / 1000
|
||||
} seconds of the exit event from process '${
|
||||
const message = `The STDIO streams did not close within ${state.delay /
|
||||
1000} seconds of the exit event from process '${
|
||||
state.toolPath
|
||||
}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`
|
||||
state._debug(message)
|
||||
|
|
|
@ -31,8 +31,9 @@ describe('auth', () => {
|
|||
|
||||
it('does basic http get request with pat token auth', async () => {
|
||||
const token = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
|
||||
const ph: am.PersonalAccessTokenCredentialHandler =
|
||||
new am.PersonalAccessTokenCredentialHandler(token)
|
||||
const ph: am.PersonalAccessTokenCredentialHandler = new am.PersonalAccessTokenCredentialHandler(
|
||||
token
|
||||
)
|
||||
|
||||
const http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [
|
||||
ph
|
||||
|
|
|
@ -57,8 +57,7 @@ export class BearerCredentialHandler implements ifm.RequestHandler {
|
|||
}
|
||||
|
||||
export class PersonalAccessTokenCredentialHandler
|
||||
implements ifm.RequestHandler
|
||||
{
|
||||
implements ifm.RequestHandler {
|
||||
token: string
|
||||
|
||||
constructor(token: string) {
|
||||
|
|
|
@ -519,7 +519,7 @@ export class HttpClient {
|
|||
handleResult(new Error(`Request timeout: ${info.options.path}`))
|
||||
})
|
||||
|
||||
req.on('error', function (err) {
|
||||
req.on('error', function(err) {
|
||||
// err has statusCode property
|
||||
// res should have headers
|
||||
handleResult(err)
|
||||
|
@ -530,7 +530,7 @@ export class HttpClient {
|
|||
}
|
||||
|
||||
if (data && typeof data !== 'string') {
|
||||
data.on('close', function () {
|
||||
data.on('close', function() {
|
||||
req.end()
|
||||
})
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ describe('retry-helper tests', () => {
|
|||
|
||||
it('all attempts fail', async () => {
|
||||
let attempts = 0
|
||||
let error: Error = null as unknown as Error
|
||||
let error: Error = (null as unknown) as Error
|
||||
try {
|
||||
await retryHelper.execute(() => {
|
||||
throw new Error(`some error ${++attempts}`)
|
||||
|
@ -87,7 +87,7 @@ describe('retry-helper tests', () => {
|
|||
|
||||
it('checks retryable after first attempt', async () => {
|
||||
let attempts = 0
|
||||
let error: Error = null as unknown as Error
|
||||
let error: Error = (null as unknown) as Error
|
||||
try {
|
||||
await retryHelper.execute(
|
||||
async () => {
|
||||
|
@ -105,7 +105,7 @@ describe('retry-helper tests', () => {
|
|||
|
||||
it('checks retryable after second attempt', async () => {
|
||||
let attempts = 0
|
||||
let error: Error = null as unknown as Error
|
||||
let error: Error = (null as unknown) as Error
|
||||
try {
|
||||
await retryHelper.execute(
|
||||
async () => {
|
||||
|
|
|
@ -17,28 +17,31 @@ import * as tc from '../src/tool-cache'
|
|||
const IS_WINDOWS = process.platform === 'win32'
|
||||
const IS_MAC = process.platform === 'darwin'
|
||||
|
||||
describe('@actions/tool-cache', function () {
|
||||
beforeAll(function () {
|
||||
nock('http://example.com').persist().get('/bytes/35').reply(200, {
|
||||
username: 'abc',
|
||||
password: 'def'
|
||||
})
|
||||
describe('@actions/tool-cache', function() {
|
||||
beforeAll(function() {
|
||||
nock('http://example.com')
|
||||
.persist()
|
||||
.get('/bytes/35')
|
||||
.reply(200, {
|
||||
username: 'abc',
|
||||
password: 'def'
|
||||
})
|
||||
setGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 0)
|
||||
setGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 0)
|
||||
})
|
||||
|
||||
beforeEach(async function () {
|
||||
beforeEach(async function() {
|
||||
await io.rmRF(cachePath)
|
||||
await io.rmRF(tempPath)
|
||||
await io.mkdirP(cachePath)
|
||||
await io.mkdirP(tempPath)
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
setResponseMessageFactory(undefined)
|
||||
})
|
||||
|
||||
afterAll(async function () {
|
||||
afterAll(async function() {
|
||||
await io.rmRF(tempPath)
|
||||
await io.rmRF(cachePath)
|
||||
setGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', undefined)
|
||||
|
@ -174,10 +177,13 @@ describe('@actions/tool-cache', function () {
|
|||
})
|
||||
|
||||
it('has status code in exception dictionary for HTTP error code responses', async () => {
|
||||
nock('http://example.com').persist().get('/bytes/bad').reply(400, {
|
||||
username: 'bad',
|
||||
password: 'file'
|
||||
})
|
||||
nock('http://example.com')
|
||||
.persist()
|
||||
.get('/bytes/bad')
|
||||
.reply(400, {
|
||||
username: 'bad',
|
||||
password: 'file'
|
||||
})
|
||||
|
||||
expect.assertions(2)
|
||||
|
||||
|
@ -190,7 +196,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('works with redirect code 302', async function () {
|
||||
it('works with redirect code 302', async function() {
|
||||
nock('http://example.com')
|
||||
.persist()
|
||||
.get('/redirect-to')
|
||||
|
@ -289,7 +295,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('extract 7z using custom 7z tool', async function () {
|
||||
it('extract 7z using custom 7z tool', async function() {
|
||||
const tempDir = path.join(
|
||||
__dirname,
|
||||
'test-extract-7z-using-custom-7z-tool'
|
||||
|
@ -637,7 +643,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
)
|
||||
|
||||
it('installs a zip and extracts it to specified directory', async function () {
|
||||
it('installs a zip and extracts it to specified directory', async function() {
|
||||
const tempDir = path.join(__dirname, 'test-install-zip')
|
||||
try {
|
||||
await io.mkdirP(tempDir)
|
||||
|
@ -700,7 +706,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('extract zip to a directory that does not exist', async function () {
|
||||
it('extract zip to a directory that does not exist', async function() {
|
||||
const tempDir = path.join(__dirname, 'test-install-zip')
|
||||
try {
|
||||
await io.mkdirP(tempDir)
|
||||
|
@ -756,16 +762,24 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('works with a 502 temporary failure', async function () {
|
||||
nock('http://example.com').get('/temp502').twice().reply(502, undefined)
|
||||
nock('http://example.com').get('/temp502').reply(200, undefined)
|
||||
it('works with a 502 temporary failure', async function() {
|
||||
nock('http://example.com')
|
||||
.get('/temp502')
|
||||
.twice()
|
||||
.reply(502, undefined)
|
||||
nock('http://example.com')
|
||||
.get('/temp502')
|
||||
.reply(200, undefined)
|
||||
|
||||
const statusCodeUrl = 'http://example.com/temp502'
|
||||
await tc.downloadTool(statusCodeUrl)
|
||||
})
|
||||
|
||||
it("doesn't retry 502s more than 3 times", async function () {
|
||||
nock('http://example.com').get('/perm502').times(3).reply(502, undefined)
|
||||
it("doesn't retry 502s more than 3 times", async function() {
|
||||
nock('http://example.com')
|
||||
.get('/perm502')
|
||||
.times(3)
|
||||
.reply(502, undefined)
|
||||
|
||||
expect.assertions(1)
|
||||
|
||||
|
@ -777,7 +791,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('retries 429s', async function () {
|
||||
it('retries 429s', async function() {
|
||||
nock('http://example.com')
|
||||
.get('/too-many-requests-429')
|
||||
.times(2)
|
||||
|
@ -794,9 +808,13 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it("doesn't retry 404", async function () {
|
||||
nock('http://example.com').get('/not-found-404').reply(404, undefined)
|
||||
nock('http://example.com').get('/not-found-404').reply(500, undefined)
|
||||
it("doesn't retry 404", async function() {
|
||||
nock('http://example.com')
|
||||
.get('/not-found-404')
|
||||
.reply(404, undefined)
|
||||
nock('http://example.com')
|
||||
.get('/not-found-404')
|
||||
.reply(500, undefined)
|
||||
|
||||
try {
|
||||
const statusCodeUrl = 'http://example.com/not-found-404'
|
||||
|
@ -806,7 +824,7 @@ describe('@actions/tool-cache', function () {
|
|||
}
|
||||
})
|
||||
|
||||
it('supports authorization headers', async function () {
|
||||
it('supports authorization headers', async function() {
|
||||
nock('http://example.com', {
|
||||
reqheaders: {
|
||||
authorization: 'token abc123'
|
||||
|
@ -822,7 +840,7 @@ describe('@actions/tool-cache', function () {
|
|||
)
|
||||
})
|
||||
|
||||
it('supports custom headers', async function () {
|
||||
it('supports custom headers', async function() {
|
||||
nock('http://example.com', {
|
||||
reqheaders: {
|
||||
accept: 'application/octet-stream'
|
||||
|
@ -841,7 +859,7 @@ describe('@actions/tool-cache', function () {
|
|||
)
|
||||
})
|
||||
|
||||
it('supports authorization and custom headers', async function () {
|
||||
it('supports authorization and custom headers', async function() {
|
||||
nock('http://example.com', {
|
||||
reqheaders: {
|
||||
accept: 'application/octet-stream',
|
||||
|
|
|
@ -140,7 +140,10 @@ export function _getOsVersion(): string {
|
|||
(parts[0].trim() === 'VERSION_ID' ||
|
||||
parts[0].trim() === 'DISTRIB_RELEASE')
|
||||
) {
|
||||
version = parts[1].trim().replace(/^"/, '').replace(/"$/, '')
|
||||
version = parts[1]
|
||||
.trim()
|
||||
.replace(/^"/, '')
|
||||
.replace(/"$/, '')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue