mirror of https://github.com/actions/toolkit
Misc Improvements
parent
813bcf1e6d
commit
c8d2dd1cf1
|
@ -1,7 +1,7 @@
|
|||
import {promises as fs} from 'fs'
|
||||
import * as path from 'path'
|
||||
import {getUploadSpecification} from '../src/upload-specification'
|
||||
import * as io from '../../io/src/io'
|
||||
import * as path from 'path'
|
||||
import {promises as fs} from 'fs'
|
||||
import {getUploadSpecification} from '../src/upload-specification'
|
||||
|
||||
const artifactName = 'my-artifact'
|
||||
const root = path.join(__dirname, '_temp', 'upload-specification')
|
||||
|
|
|
@ -46,7 +46,6 @@ export async function createArtifactInFileContainer(
|
|||
const body: string = await rawResponse.readBody()
|
||||
|
||||
if (
|
||||
rawResponse.message.statusCode &&
|
||||
isSuccessStatusCode(rawResponse.message.statusCode) &&
|
||||
body
|
||||
) {
|
||||
|
@ -248,7 +247,6 @@ async function uploadChunk(
|
|||
|
||||
const response = await uploadChunkRequest()
|
||||
if (
|
||||
response.message.statusCode &&
|
||||
isSuccessStatusCode(response.message.statusCode)
|
||||
) {
|
||||
debug(
|
||||
|
@ -256,7 +254,6 @@ async function uploadChunk(
|
|||
)
|
||||
return true
|
||||
} else if (
|
||||
response.message.statusCode &&
|
||||
isRetryableStatusCode(response.message.statusCode)
|
||||
) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -266,7 +263,6 @@ async function uploadChunk(
|
|||
await new Promise(resolve => setTimeout(resolve, 10000))
|
||||
const retryResponse = await uploadChunkRequest()
|
||||
if (
|
||||
retryResponse.message.statusCode &&
|
||||
isSuccessStatusCode(retryResponse.message.statusCode)
|
||||
) {
|
||||
return true
|
||||
|
@ -311,7 +307,6 @@ export async function patchArtifactSize(
|
|||
const body: string = await rawResponse.readBody()
|
||||
|
||||
if (
|
||||
rawResponse.message.statusCode &&
|
||||
isSuccessStatusCode(rawResponse.message.statusCode)
|
||||
) {
|
||||
debug(
|
||||
|
|
|
@ -26,11 +26,18 @@ export function getApiVersion(): string {
|
|||
return '6.0-preview'
|
||||
}
|
||||
|
||||
export function isSuccessStatusCode(statusCode: number): boolean {
|
||||
export function isSuccessStatusCode(statusCode?: number): boolean {
|
||||
if (!statusCode) {
|
||||
return false
|
||||
}
|
||||
return statusCode >= 200 && statusCode < 300
|
||||
}
|
||||
|
||||
export function isRetryableStatusCode(statusCode: number): boolean {
|
||||
export function isRetryableStatusCode(statusCode?: number): boolean {
|
||||
if (!statusCode) {
|
||||
return false
|
||||
}
|
||||
|
||||
const retryableStatusCodes = [
|
||||
HttpCodes.BadGateway,
|
||||
HttpCodes.ServiceUnavailable,
|
||||
|
|
Loading…
Reference in New Issue