mirror of https://github.com/actions/toolkit
Resolved comments
parent
3abbc6c24c
commit
6cd8286138
|
@ -63,17 +63,16 @@ test('save with large cache outputs should fail', async () => {
|
||||||
const reserveCacheMock = jest
|
const reserveCacheMock = jest
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: ITypedResponseWithErrorMessage<ReserveCacheResponse> = {
|
const response: ITypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
result: null,
|
result: null,
|
||||||
headers: {},
|
headers: {}
|
||||||
typeKey: 'InvalidReserveCacheRequestException'
|
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(saveCache([filePath], primaryKey)).rejects.toThrowError(
|
await expect(saveCache([filePath], primaryKey)).rejects.toThrowError(
|
||||||
'Cache size of ~11264 MB (11811160064 B) is over the data cap limit, not saving cache.'
|
'Cache size of ~11264 MB (11811160064 B) is over the 10GB limit, not saving cache.'
|
||||||
)
|
)
|
||||||
|
|
||||||
const archiveFolder = '/foo/bar'
|
const archiveFolder = '/foo/bar'
|
||||||
|
@ -94,7 +93,7 @@ test('save with reserve cache failure should fail', async () => {
|
||||||
const reserveCacheMock = jest
|
const reserveCacheMock = jest
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
.mockImplementation(async () => {
|
.mockImplementation(async () => {
|
||||||
const response: ITypedResponseWithErrorMessage<ReserveCacheResponse> = {
|
const response: ITypedResponse<ReserveCacheResponse> = {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
result: null,
|
result: null,
|
||||||
headers: {}
|
headers: {}
|
||||||
|
|
|
@ -171,9 +171,17 @@ export async function saveCache(
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
await listTar(archivePath, compressionMethod)
|
await listTar(archivePath, compressionMethod)
|
||||||
}
|
}
|
||||||
|
const fileSizeLimit = 10 * 1024 * 1024 * 1024 // 10GB per repo limit
|
||||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
|
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath)
|
||||||
core.debug(`File Size: ${archiveFileSize}`)
|
core.debug(`File Size: ${archiveFileSize}`)
|
||||||
|
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||||
|
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||||
|
throw new Error(
|
||||||
|
`Cache size of ~${Math.round(
|
||||||
|
archiveFileSize / (1024 * 1024)
|
||||||
|
)} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const cacheSize = archiveFileSize
|
const cacheSize = archiveFileSize
|
||||||
core.debug('Reserving Cache')
|
core.debug('Reserving Cache')
|
||||||
|
@ -186,20 +194,15 @@ export async function saveCache(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (reserveCacheResponse?.result?.cacheId) {
|
||||||
reserveCacheResponse?.statusCode === 400 &&
|
cacheId = reserveCacheResponse?.result?.cacheId
|
||||||
reserveCacheResponse?.typeKey === 'InvalidReserveCacheRequestException'
|
} else if (reserveCacheResponse?.statusCode === 400) {
|
||||||
) {
|
|
||||||
throw new ReserveCacheError(
|
throw new ReserveCacheError(
|
||||||
reserveCacheResponse?.message ??
|
reserveCacheResponse?.error?.message ??
|
||||||
`Cache size of ~${Math.round(
|
`Cache size of ~${Math.round(
|
||||||
archiveFileSize / (1024 * 1024)
|
archiveFileSize / (1024 * 1024)
|
||||||
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
)} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if (reserveCacheResponse?.result?.cacheId) {
|
|
||||||
cacheId = reserveCacheResponse?.result?.cacheId
|
|
||||||
} else {
|
} else {
|
||||||
throw new ReserveCacheError(
|
throw new ReserveCacheError(
|
||||||
`Unable to reserve cache with key ${key}, another job may be creating this cache.`
|
`Unable to reserve cache with key ${key}, another job may be creating this cache.`
|
||||||
|
|
|
@ -123,3 +123,10 @@ export function assertDefined<T>(name: string, value?: T): T {
|
||||||
|
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isGhes(): boolean {
|
||||||
|
const ghUrl = new URL(
|
||||||
|
process.env["GITHUB_SERVER_URL"] || "https://github.com"
|
||||||
|
);
|
||||||
|
return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import {CompressionMethod} from './constants'
|
import {CompressionMethod} from './constants'
|
||||||
import {ITypedResponse} from '@actions/http-client/interfaces'
|
import {ITypedResponse} from '@actions/http-client/interfaces'
|
||||||
|
import {HttpClientError} from '@actions/http-client'
|
||||||
|
|
||||||
export interface ITypedResponseWithErrorMessage<T> extends ITypedResponse<T> {
|
export interface ITypedResponseWithErrorMessage<T> extends ITypedResponse<T> {
|
||||||
message?: string
|
error?: HttpClientError
|
||||||
typeKey?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ArtifactCacheEntry {
|
export interface ArtifactCacheEntry {
|
||||||
|
|
|
@ -110,8 +110,7 @@ export async function retryTypedResponse<T>(
|
||||||
statusCode: error.statusCode,
|
statusCode: error.statusCode,
|
||||||
result: null,
|
result: null,
|
||||||
headers: {},
|
headers: {},
|
||||||
message: error.message,
|
error: error
|
||||||
typeKey: error.result.typeKey
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return undefined
|
return undefined
|
||||||
|
|
Loading…
Reference in New Issue