mirror of https://github.com/actions/toolkit
added info error as well
parent
e051715283
commit
639c79e4a4
|
@ -62,7 +62,7 @@ test('save with large cache outputs should fail', async () => {
|
||||||
const cacheId = await saveCache([filePath], primaryKey)
|
const cacheId = await saveCache([filePath], primaryKey)
|
||||||
expect(cacheId).toBe(-1)
|
expect(cacheId).toBe(-1)
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
||||||
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Error: Cache size of ~11264 MB (11811160064 B) is over the 10GB limit, not saving cache.')
|
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Cache size of ~11264 MB (11811160064 B) is over the 10GB limit, not saving cache.')
|
||||||
|
|
||||||
const archiveFolder = '/foo/bar'
|
const archiveFolder = '/foo/bar'
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ test('save with large cache outputs should fail in GHES with error message', asy
|
||||||
const cacheId = await saveCache([filePath], primaryKey)
|
const cacheId = await saveCache([filePath], primaryKey)
|
||||||
expect(cacheId).toBe(-1)
|
expect(cacheId).toBe(-1)
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
||||||
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Error: The cache filesize must be between 0 and 1073741824 bytes')
|
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: The cache filesize must be between 0 and 1073741824 bytes')
|
||||||
|
|
||||||
const archiveFolder = '/foo/bar'
|
const archiveFolder = '/foo/bar'
|
||||||
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
||||||
|
@ -158,7 +158,7 @@ test('save with large cache outputs should fail in GHES without error message',
|
||||||
const cacheId = await saveCache([filePath], primaryKey)
|
const cacheId = await saveCache([filePath], primaryKey)
|
||||||
expect(cacheId).toBe(-1)
|
expect(cacheId).toBe(-1)
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
||||||
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Error: Cache size of ~11264 MB (11811160064 B) is over the data cap limit, not saving cache.')
|
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Cache size of ~11264 MB (11811160064 B) is over the data cap limit, not saving cache.')
|
||||||
|
|
||||||
const archiveFolder = '/foo/bar'
|
const archiveFolder = '/foo/bar'
|
||||||
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
||||||
|
@ -174,7 +174,7 @@ test('save with large cache outputs should fail in GHES without error message',
|
||||||
test('save with reserve cache failure should fail', async () => {
|
test('save with reserve cache failure should fail', async () => {
|
||||||
const paths = ['node_modules']
|
const paths = ['node_modules']
|
||||||
const primaryKey = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
|
const primaryKey = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
|
||||||
const logWarningMock = jest.spyOn(core, "warning");
|
const logInfoMock = jest.spyOn(core, "info");
|
||||||
|
|
||||||
const reserveCacheMock = jest
|
const reserveCacheMock = jest
|
||||||
.spyOn(cacheHttpClient, 'reserveCache')
|
.spyOn(cacheHttpClient, 'reserveCache')
|
||||||
|
@ -196,8 +196,8 @@ test('save with reserve cache failure should fail', async () => {
|
||||||
|
|
||||||
const cacheId = await saveCache(paths, primaryKey)
|
const cacheId = await saveCache(paths, primaryKey)
|
||||||
expect(cacheId).toBe(-1)
|
expect(cacheId).toBe(-1)
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
expect(logInfoMock).toHaveBeenCalledTimes(1)
|
||||||
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: ReserveCacheError: Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.')
|
expect(logInfoMock).toHaveBeenCalledWith(`Fail to save: Unable to reserve cache with key ${primaryKey}, another job may be creating this cache. More details: undefined`)
|
||||||
|
|
||||||
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
||||||
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey, paths, {
|
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey, paths, {
|
||||||
|
@ -239,7 +239,7 @@ test('save with server error should fail', async () => {
|
||||||
|
|
||||||
await saveCache([filePath], primaryKey)
|
await saveCache([filePath], primaryKey)
|
||||||
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
expect(logWarningMock).toHaveBeenCalledTimes(1)
|
||||||
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: Error: HTTP Error Occurred')
|
expect(logWarningMock).toHaveBeenCalledWith('Fail to save: HTTP Error Occurred')
|
||||||
|
|
||||||
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
expect(reserveCacheMock).toHaveBeenCalledTimes(1)
|
||||||
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey, [filePath], {
|
expect(reserveCacheMock).toHaveBeenCalledWith(primaryKey, [filePath], {
|
||||||
|
|
|
@ -225,7 +225,12 @@ export async function saveCache(
|
||||||
core.debug(`Saving Cache (ID: ${cacheId})`)
|
core.debug(`Saving Cache (ID: ${cacheId})`)
|
||||||
await cacheHttpClient.saveCache(cacheId, archivePath, options)
|
await cacheHttpClient.saveCache(cacheId, archivePath, options)
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
core.warning(`Fail to save: ${error}`)
|
const typedError = error as Error;
|
||||||
|
if (typedError.name === ReserveCacheError.name) {
|
||||||
|
core.info(`Fail to save: ${typedError.message}`)
|
||||||
|
} else {
|
||||||
|
core.warning(`Fail to save: ${typedError.message}`)
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue