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,
|
destinationStream: fs.WriteStream,
|
||||||
isGzip: boolean
|
isGzip: boolean
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise<void>((resolve, reject) => {
|
||||||
if (isGzip) {
|
if (isGzip) {
|
||||||
const gunzip = zlib.createGunzip()
|
const gunzip = zlib.createGunzip()
|
||||||
response.message
|
response.message
|
||||||
|
|
|
@ -92,7 +92,10 @@ export function getCacheVersion(
|
||||||
// Add salt to cache version to support breaking changes in cache entry
|
// Add salt to cache version to support breaking changes in cache entry
|
||||||
components.push(versionSalt)
|
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(
|
export async function getCacheEntry(
|
||||||
|
@ -227,9 +230,9 @@ async function uploadChunk(
|
||||||
end: number
|
end: number
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
core.debug(
|
core.debug(
|
||||||
`Uploading chunk of size ${
|
`Uploading chunk of size ${end -
|
||||||
end - start + 1
|
start +
|
||||||
} bytes at offset ${start} with content range: ${getContentRange(
|
1} bytes at offset ${start} with content range: ${getContentRange(
|
||||||
start,
|
start,
|
||||||
end
|
end
|
||||||
)}`
|
)}`
|
||||||
|
|
|
@ -17,7 +17,7 @@ describe('@actions/core/src/command', () => {
|
||||||
afterEach(() => {})
|
afterEach(() => {})
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
process.stdout.write = originalWriteFunction as unknown as (
|
process.stdout.write = (originalWriteFunction as unknown) as (
|
||||||
str: string
|
str: string
|
||||||
) => boolean
|
) => boolean
|
||||||
})
|
})
|
||||||
|
@ -51,7 +51,8 @@ describe('@actions/core/src/command', () => {
|
||||||
command.issueCommand(
|
command.issueCommand(
|
||||||
'some-command',
|
'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(
|
command.issueCommand(
|
||||||
'some-command',
|
'some-command',
|
||||||
{
|
{
|
||||||
prop1: {test: 'object'} as unknown as string,
|
prop1: ({test: 'object'} as unknown) as string,
|
||||||
prop2: 123 as unknown as string,
|
prop2: (123 as unknown) as string,
|
||||||
prop3: true as unknown as string
|
prop3: (true as unknown) as string
|
||||||
},
|
},
|
||||||
{test: 'object'} as unknown as string
|
({test: 'object'} as unknown) as string
|
||||||
)
|
)
|
||||||
assertWriteCalls([
|
assertWriteCalls([
|
||||||
`::some-command prop1={"test"%3A"object"},prop2=123,prop3=true::{"test":"object"}${os.EOL}`
|
`::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 () => {
|
it('adds EOL', async () => {
|
||||||
await summary.addRaw(fixtures.text).addEOL().write()
|
await summary
|
||||||
|
.addRaw(fixtures.text)
|
||||||
|
.addEOL()
|
||||||
|
.write()
|
||||||
await assertSummary(fixtures.text + os.EOL)
|
await assertSummary(fixtures.text + os.EOL)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,10 @@ export class ToolRunner extends events.EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse += '"'
|
reverse += '"'
|
||||||
return reverse.split('').reverse().join('')
|
return reverse
|
||||||
|
.split('')
|
||||||
|
.reverse()
|
||||||
|
.join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
private _uvQuoteCmdArg(arg: string): string {
|
private _uvQuoteCmdArg(arg: string): string {
|
||||||
|
@ -347,7 +350,10 @@ export class ToolRunner extends events.EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse += '"'
|
reverse += '"'
|
||||||
return reverse.split('').reverse().join('')
|
return reverse
|
||||||
|
.split('')
|
||||||
|
.reverse()
|
||||||
|
.join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
private _cloneExecOptions(options?: im.ExecOptions): im.ExecOptions {
|
private _cloneExecOptions(options?: im.ExecOptions): im.ExecOptions {
|
||||||
|
@ -685,9 +691,8 @@ class ExecState extends events.EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.processClosed && state.processExited) {
|
if (!state.processClosed && state.processExited) {
|
||||||
const message = `The STDIO streams did not close within ${
|
const message = `The STDIO streams did not close within ${state.delay /
|
||||||
state.delay / 1000
|
1000} seconds of the exit event from process '${
|
||||||
} seconds of the exit event from process '${
|
|
||||||
state.toolPath
|
state.toolPath
|
||||||
}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`
|
}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`
|
||||||
state._debug(message)
|
state._debug(message)
|
||||||
|
|
|
@ -31,8 +31,9 @@ describe('auth', () => {
|
||||||
|
|
||||||
it('does basic http get request with pat token auth', async () => {
|
it('does basic http get request with pat token auth', async () => {
|
||||||
const token = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
|
const token = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
|
||||||
const ph: am.PersonalAccessTokenCredentialHandler =
|
const ph: am.PersonalAccessTokenCredentialHandler = new am.PersonalAccessTokenCredentialHandler(
|
||||||
new am.PersonalAccessTokenCredentialHandler(token)
|
token
|
||||||
|
)
|
||||||
|
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [
|
const http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [
|
||||||
ph
|
ph
|
||||||
|
|
|
@ -57,8 +57,7 @@ export class BearerCredentialHandler implements ifm.RequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PersonalAccessTokenCredentialHandler
|
export class PersonalAccessTokenCredentialHandler
|
||||||
implements ifm.RequestHandler
|
implements ifm.RequestHandler {
|
||||||
{
|
|
||||||
token: string
|
token: string
|
||||||
|
|
||||||
constructor(token: string) {
|
constructor(token: string) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ describe('retry-helper tests', () => {
|
||||||
|
|
||||||
it('all attempts fail', async () => {
|
it('all attempts fail', async () => {
|
||||||
let attempts = 0
|
let attempts = 0
|
||||||
let error: Error = null as unknown as Error
|
let error: Error = (null as unknown) as Error
|
||||||
try {
|
try {
|
||||||
await retryHelper.execute(() => {
|
await retryHelper.execute(() => {
|
||||||
throw new Error(`some error ${++attempts}`)
|
throw new Error(`some error ${++attempts}`)
|
||||||
|
@ -87,7 +87,7 @@ describe('retry-helper tests', () => {
|
||||||
|
|
||||||
it('checks retryable after first attempt', async () => {
|
it('checks retryable after first attempt', async () => {
|
||||||
let attempts = 0
|
let attempts = 0
|
||||||
let error: Error = null as unknown as Error
|
let error: Error = (null as unknown) as Error
|
||||||
try {
|
try {
|
||||||
await retryHelper.execute(
|
await retryHelper.execute(
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -105,7 +105,7 @@ describe('retry-helper tests', () => {
|
||||||
|
|
||||||
it('checks retryable after second attempt', async () => {
|
it('checks retryable after second attempt', async () => {
|
||||||
let attempts = 0
|
let attempts = 0
|
||||||
let error: Error = null as unknown as Error
|
let error: Error = (null as unknown) as Error
|
||||||
try {
|
try {
|
||||||
await retryHelper.execute(
|
await retryHelper.execute(
|
||||||
async () => {
|
async () => {
|
||||||
|
|
|
@ -19,7 +19,10 @@ const IS_MAC = process.platform === 'darwin'
|
||||||
|
|
||||||
describe('@actions/tool-cache', function() {
|
describe('@actions/tool-cache', function() {
|
||||||
beforeAll(function() {
|
beforeAll(function() {
|
||||||
nock('http://example.com').persist().get('/bytes/35').reply(200, {
|
nock('http://example.com')
|
||||||
|
.persist()
|
||||||
|
.get('/bytes/35')
|
||||||
|
.reply(200, {
|
||||||
username: 'abc',
|
username: 'abc',
|
||||||
password: 'def'
|
password: 'def'
|
||||||
})
|
})
|
||||||
|
@ -174,7 +177,10 @@ describe('@actions/tool-cache', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has status code in exception dictionary for HTTP error code responses', async () => {
|
it('has status code in exception dictionary for HTTP error code responses', async () => {
|
||||||
nock('http://example.com').persist().get('/bytes/bad').reply(400, {
|
nock('http://example.com')
|
||||||
|
.persist()
|
||||||
|
.get('/bytes/bad')
|
||||||
|
.reply(400, {
|
||||||
username: 'bad',
|
username: 'bad',
|
||||||
password: 'file'
|
password: 'file'
|
||||||
})
|
})
|
||||||
|
@ -757,15 +763,23 @@ describe('@actions/tool-cache', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('works with a 502 temporary failure', async function() {
|
it('works with a 502 temporary failure', async function() {
|
||||||
nock('http://example.com').get('/temp502').twice().reply(502, undefined)
|
nock('http://example.com')
|
||||||
nock('http://example.com').get('/temp502').reply(200, undefined)
|
.get('/temp502')
|
||||||
|
.twice()
|
||||||
|
.reply(502, undefined)
|
||||||
|
nock('http://example.com')
|
||||||
|
.get('/temp502')
|
||||||
|
.reply(200, undefined)
|
||||||
|
|
||||||
const statusCodeUrl = 'http://example.com/temp502'
|
const statusCodeUrl = 'http://example.com/temp502'
|
||||||
await tc.downloadTool(statusCodeUrl)
|
await tc.downloadTool(statusCodeUrl)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("doesn't retry 502s more than 3 times", async function() {
|
it("doesn't retry 502s more than 3 times", async function() {
|
||||||
nock('http://example.com').get('/perm502').times(3).reply(502, undefined)
|
nock('http://example.com')
|
||||||
|
.get('/perm502')
|
||||||
|
.times(3)
|
||||||
|
.reply(502, undefined)
|
||||||
|
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
|
|
||||||
|
@ -795,8 +809,12 @@ describe('@actions/tool-cache', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("doesn't retry 404", async function() {
|
it("doesn't retry 404", async function() {
|
||||||
nock('http://example.com').get('/not-found-404').reply(404, undefined)
|
nock('http://example.com')
|
||||||
nock('http://example.com').get('/not-found-404').reply(500, undefined)
|
.get('/not-found-404')
|
||||||
|
.reply(404, undefined)
|
||||||
|
nock('http://example.com')
|
||||||
|
.get('/not-found-404')
|
||||||
|
.reply(500, undefined)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const statusCodeUrl = 'http://example.com/not-found-404'
|
const statusCodeUrl = 'http://example.com/not-found-404'
|
||||||
|
|
|
@ -140,7 +140,10 @@ export function _getOsVersion(): string {
|
||||||
(parts[0].trim() === 'VERSION_ID' ||
|
(parts[0].trim() === 'VERSION_ID' ||
|
||||||
parts[0].trim() === 'DISTRIB_RELEASE')
|
parts[0].trim() === 'DISTRIB_RELEASE')
|
||||||
) {
|
) {
|
||||||
version = parts[1].trim().replace(/^"/, '').replace(/"$/, '')
|
version = parts[1]
|
||||||
|
.trim()
|
||||||
|
.replace(/^"/, '')
|
||||||
|
.replace(/"$/, '')
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue