Update tests to expect warnings instead of errors for non-5xx cache failures

Co-authored-by: Link- <568794+Link-@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-07-14 12:07:37 +00:00
parent 513216f1dd
commit cf3aaeb491
20 changed files with 90693 additions and 18 deletions
+1166
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
893710042127256768
+20961
View File
File diff suppressed because it is too large Load Diff
+21535
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
{
"run": {
"command": "lerna run tsc",
"startTime": "2025-07-14T11:59:59.917Z",
"endTime": "2025-07-14T12:00:02.973Z",
"inner": false
},
"tasks": [
{
"taskId": "@actions/io:tsc",
"target": "tsc",
"projectName": "@actions/io",
"hash": "6383941984474854638",
"startTime": "2025-07-14T11:59:59.945Z",
"endTime": "2025-07-14T12:00:02.841Z",
"params": "",
"cacheStatus": "cache-miss",
"status": 1
},
{
"taskId": "@actions/http-client:tsc",
"target": "tsc",
"projectName": "@actions/http-client",
"hash": "18096640051185404072",
"startTime": "2025-07-14T11:59:59.945Z",
"endTime": "2025-07-14T12:00:02.972Z",
"params": "",
"cacheStatus": "cache-miss",
"status": 1
}
]
}
+42
View File
@@ -0,0 +1,42 @@
> @actions/http-client@2.2.3 tsc
> tsc
src/auth.ts(1,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
src/auth.ts(18,49): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/auth.ts(74,49): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(3,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
src/index.ts(4,24): error TS2307: Cannot find module 'https' or its corresponding type declarations.
src/index.ts(6,22): error TS2307: Cannot find module 'net' or its corresponding type declarations.
src/index.ts(8,25): error TS2307: Cannot find module 'tunnel' or its corresponding type declarations.
src/index.ts(9,26): error TS2307: Cannot find module 'undici' or its corresponding type declarations.
src/index.ts(95,20): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(97,39): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(98,18): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(107,36): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(108,24): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(109,21): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(111,39): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(116,17): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(241,13): error TS2503: Cannot find namespace 'NodeJS'.
src/index.ts(347,20): error TS2503: Cannot find namespace 'NodeJS'.
src/index.ts(359,48): error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
src/index.ts(395,27): error TS2550: Property 'includes' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
src/index.ts(438,33): error TS2550: Property 'includes' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.
src/index.ts(473,20): error TS2503: Cannot find namespace 'NodeJS'.
src/index.ts(499,20): error TS2503: Cannot find namespace 'NodeJS'.
src/index.ts(506,48): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/index.ts(729,25): error TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/interfaces.ts(1,23): error TS2307: Cannot find module 'http' or its corresponding type declarations.
src/interfaces.ts(2,24): error TS2307: Cannot find module 'https' or its corresponding type declarations.
src/interfaces.ts(36,13): error TS2503: Cannot find namespace 'NodeJS'.
src/interfaces.ts(42,20): error TS2503: Cannot find namespace 'NodeJS'.
src/interfaces.ts(47,20): error TS2503: Cannot find namespace 'NodeJS'.
src/interfaces.ts(51,20): error TS2503: Cannot find namespace 'NodeJS'.
src/interfaces.ts(62,20): error TS2503: Cannot find namespace 'NodeJS'.
src/proxy.ts(10,14): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/proxy.ts(10,44): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/proxy.ts(12,14): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/proxy.ts(12,43): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/proxy.ts(38,19): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/proxy.ts(38,46): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
+18
View File
@@ -0,0 +1,18 @@
> @actions/io@1.1.3 tsc
> tsc
src/io-util.ts(1,21): error TS2307: Cannot find module 'fs' or its corresponding type declarations.
src/io-util.ts(2,23): error TS2307: Cannot find module 'path' or its corresponding type declarations.
src/io-util.ts(20,27): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io-util.ts(171,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io-util.ts(172,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io-util.ts(174,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io-util.ts(175,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io-util.ts(181,10): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io.ts(1,18): error TS2307: Cannot find module 'assert' or its corresponding type declarations.
src/io.ts(2,23): error TS2307: Cannot find module 'path' or its corresponding type declarations.
src/io.ts(200,28): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io.ts(201,29): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io.ts(232,7): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
src/io.ts(233,21): error TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
13182328228597024267
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -50,7 +50,7 @@ test('save with large cache outputs should fail', async () => {
const cachePaths = [path.resolve(filePath)]
const createTarMock = jest.spyOn(tar, 'createTar')
const logErrorMock = jest.spyOn(core, 'error')
const logWarningMock = jest.spyOn(core, 'warning')
const cacheSize = 11 * 1024 * 1024 * 1024 //~11GB, over the 10GB limit
jest
@@ -63,8 +63,8 @@ test('save with large cache outputs should fail', async () => {
const cacheId = await saveCache([filePath], primaryKey)
expect(cacheId).toBe(-1)
expect(logErrorMock).toHaveBeenCalledTimes(1)
expect(logErrorMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledTimes(1)
expect(logWarningMock).toHaveBeenCalledWith(
'Failed to save: Cache size of ~11264 MB (11811160064 B) is over the 10GB limit, not saving cache.'
)
@@ -85,7 +85,7 @@ test('save with large cache outputs should fail in GHES with error message', asy
const cachePaths = [path.resolve(filePath)]
const createTarMock = jest.spyOn(tar, 'createTar')
const logErrorMock = jest.spyOn(core, 'error')
const logWarningMock = jest.spyOn(core, 'warning')
const cacheSize = 11 * 1024 * 1024 * 1024 //~11GB, over the 10GB limit
jest
@@ -115,8 +115,8 @@ test('save with large cache outputs should fail in GHES with error message', asy
const cacheId = await saveCache([filePath], primaryKey)
expect(cacheId).toBe(-1)
expect(logErrorMock).toHaveBeenCalledTimes(1)
expect(logErrorMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledTimes(1)
expect(logWarningMock).toHaveBeenCalledWith(
'Failed to save: The cache filesize must be between 0 and 1073741824 bytes'
)
@@ -137,7 +137,7 @@ test('save with large cache outputs should fail in GHES without error message',
const cachePaths = [path.resolve(filePath)]
const createTarMock = jest.spyOn(tar, 'createTar')
const logErrorMock = jest.spyOn(core, 'error')
const logWarningMock = jest.spyOn(core, 'warning')
const cacheSize = 11 * 1024 * 1024 * 1024 //~11GB, over the 10GB limit
jest
@@ -163,8 +163,8 @@ test('save with large cache outputs should fail in GHES without error message',
const cacheId = await saveCache([filePath], primaryKey)
expect(cacheId).toBe(-1)
expect(logErrorMock).toHaveBeenCalledTimes(1)
expect(logErrorMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledTimes(1)
expect(logWarningMock).toHaveBeenCalledWith(
'Failed to save: Cache size of ~11264 MB (11811160064 B) is over the data cap limit, not saving cache.'
)
+4 -4
View File
@@ -65,7 +65,7 @@ test('save with large cache outputs should fail using', async () => {
const cachePaths = [path.resolve(paths)]
const createTarMock = jest.spyOn(tar, 'createTar')
const logErrorMock = jest.spyOn(core, 'error')
const logWarningMock = jest.spyOn(core, 'warning')
const cacheSize = 11 * 1024 * 1024 * 1024 //~11GB, over the 10GB limit
jest
@@ -78,7 +78,7 @@ test('save with large cache outputs should fail using', async () => {
const cacheId = await saveCache([paths], key)
expect(cacheId).toBe(-1)
expect(logErrorMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledWith(
'Failed to save: Cache size of ~11264 MB (11811160064 B) is over the 10GB limit, not saving cache.'
)
@@ -227,7 +227,7 @@ test('finalize save cache failure', async () => {
const paths = 'node_modules'
const key = 'Linux-node-bb828da54c148048dd17899ba9fda624811cfb43'
const cachePaths = [path.resolve(paths)]
const logErrorMock = jest.spyOn(core, 'error')
const logWarningMock = jest.spyOn(core, 'warning')
const signedUploadURL = 'https://blob-storage.local?signed=true'
const archiveFileSize = 1024
const options: UploadOptions = {
@@ -292,7 +292,7 @@ test('finalize save cache failure', async () => {
})
expect(cacheId).toBe(-1)
expect(logErrorMock).toHaveBeenCalledWith(
expect(logWarningMock).toHaveBeenCalledWith(
`Failed to save: Unable to finalize cache with key ${key}, another job may be finalizing this cache.`
)
})
+16 -5
View File
@@ -13,6 +13,8 @@ import {
GetCacheEntryDownloadURLRequest
} from './generated/results/api/v1/cache'
import {CacheFileSizeLimit} from './internal/constants'
import {isServerErrorStatusCode} from './internal/requestUtils'
import {HttpClientError} from '@actions/http-client'
export class ValidationError extends Error {
constructor(message: string) {
super(message)
@@ -29,6 +31,15 @@ export class ReserveCacheError extends Error {
}
}
function logCacheError(message: string, error: Error): void {
// Log server errors (5xx) as errors, all other errors as warnings
if (error instanceof HttpClientError && isServerErrorStatusCode(error.statusCode)) {
core.error(message)
} else {
core.warning(message)
}
}
function checkPaths(paths: string[]): void {
if (!paths || paths.length === 0) {
throw new ValidationError(
@@ -199,8 +210,8 @@ async function restoreCacheV1(
if (typedError.name === ValidationError.name) {
throw error
} else {
// Log cache related errors
core.error(`Failed to restore: ${(error as Error).message}`)
// warn on cache restore failure and continue build
core.warning(`Failed to restore: ${(error as Error).message}`)
}
} finally {
// Try to delete the archive to save space
@@ -318,7 +329,7 @@ async function restoreCacheV2(
throw error
} else {
// Log cache related errors
core.error(`Failed to restore: ${(error as Error).message}`)
logCacheError(`Failed to restore: ${(error as Error).message}`, typedError)
}
} finally {
try {
@@ -450,7 +461,7 @@ async function saveCacheV1(
} else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`)
} else {
core.error(`Failed to save: ${typedError.message}`)
core.warning(`Failed to save: ${typedError.message}`)
}
} finally {
// Try to delete the archive to save space
@@ -589,7 +600,7 @@ async function saveCacheV2(
} else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`)
} else {
core.error(`Failed to save: ${typedError.message}`)
logCacheError(`Failed to save: ${typedError.message}`, typedError)
}
} finally {
// Try to delete the archive to save space