mirror of https://github.com/actions/toolkit
Attempt to fix the test
parent
1413cd0e32
commit
b3c8e19a7a
|
@ -77,6 +77,12 @@
|
||||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
||||||
},
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "3.8.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
|
||||||
|
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"uuid": {
|
"uuid": {
|
||||||
"version": "3.4.0",
|
"version": "3.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
"uuid": "^3.3.3"
|
"uuid": "^3.3.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"typescript": "^3.8.3",
|
||||||
"@types/uuid": "^3.4.5"
|
"@types/uuid": "^3.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,23 @@ import * as cacheHttpClient from './internal/cacheHttpClient'
|
||||||
import {createTar, extractTar} from './internal/tar'
|
import {createTar, extractTar} from './internal/tar'
|
||||||
import {UploadOptions} from './options'
|
import {UploadOptions} from './options'
|
||||||
|
|
||||||
|
export class ValidationError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message)
|
||||||
|
this.name = 'ValidationError'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReserveCacheError extends Error {
|
||||||
|
constructor(message: string) {
|
||||||
|
super(message)
|
||||||
|
this.name = 'ReserveCacheError'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkPaths(paths: string[]): void {
|
function checkPaths(paths: string[]): void {
|
||||||
if (!paths || paths.length === 0) {
|
if (!paths || paths.length === 0) {
|
||||||
throw new Error(
|
throw new ValidationError(
|
||||||
`Path Validation Error: At least one directory or file path is required`
|
`Path Validation Error: At least one directory or file path is required`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -15,13 +29,15 @@ function checkPaths(paths: string[]): void {
|
||||||
|
|
||||||
function checkKey(key: string): void {
|
function checkKey(key: string): void {
|
||||||
if (key.length > 512) {
|
if (key.length > 512) {
|
||||||
throw new Error(
|
throw new ValidationError(
|
||||||
`Key Validation Error: ${key} cannot be larger than 512 characters.`
|
`Key Validation Error: ${key} cannot be larger than 512 characters.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const regex = /^[^,]*$/
|
const regex = /^[^,]*$/
|
||||||
if (!regex.test(key)) {
|
if (!regex.test(key)) {
|
||||||
throw new Error(`Key Validation Error: ${key} cannot contain commas.`)
|
throw new ValidationError(
|
||||||
|
`Key Validation Error: ${key} cannot contain commas.`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +63,7 @@ export async function restoreCache(
|
||||||
core.debug(JSON.stringify(keys))
|
core.debug(JSON.stringify(keys))
|
||||||
|
|
||||||
if (keys.length > 10) {
|
if (keys.length > 10) {
|
||||||
throw new Error(
|
throw new ValidationError(
|
||||||
`Key Validation Error: Keys are limited to a maximum of 10.`
|
`Key Validation Error: Keys are limited to a maximum of 10.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -121,13 +137,13 @@ export async function saveCache(
|
||||||
compressionMethod
|
compressionMethod
|
||||||
})
|
})
|
||||||
if (cacheId === -1) {
|
if (cacheId === -1) {
|
||||||
throw new Error(
|
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.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
core.debug(`Cache ID: ${cacheId}`)
|
core.debug(`Cache ID: ${cacheId}`)
|
||||||
const cachePaths = await utils.resolvePaths(paths)
|
|
||||||
|
|
||||||
|
const cachePaths = await utils.resolvePaths(paths)
|
||||||
core.debug('Cache Paths:')
|
core.debug('Cache Paths:')
|
||||||
core.debug(`${JSON.stringify(cachePaths)}`)
|
core.debug(`${JSON.stringify(cachePaths)}`)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import * as utils from './cacheUtils'
|
||||||
import {CompressionMethod, SocketTimeout} from './constants'
|
import {CompressionMethod, SocketTimeout} from './constants'
|
||||||
import {
|
import {
|
||||||
ArtifactCacheEntry,
|
ArtifactCacheEntry,
|
||||||
CacheOptions,
|
InternalCacheOptions,
|
||||||
CommitCacheRequest,
|
CommitCacheRequest,
|
||||||
ReserveCacheRequest,
|
ReserveCacheRequest,
|
||||||
ReserveCacheResponse
|
ReserveCacheResponse
|
||||||
|
@ -180,7 +180,7 @@ export async function retryHttpClientResponse<T>(
|
||||||
export async function getCacheEntry(
|
export async function getCacheEntry(
|
||||||
keys: string[],
|
keys: string[],
|
||||||
paths: string[],
|
paths: string[],
|
||||||
options?: CacheOptions
|
options?: InternalCacheOptions
|
||||||
): Promise<ArtifactCacheEntry | null> {
|
): Promise<ArtifactCacheEntry | null> {
|
||||||
const httpClient = createHttpClient()
|
const httpClient = createHttpClient()
|
||||||
const version = getCacheVersion(paths, options?.compressionMethod)
|
const version = getCacheVersion(paths, options?.compressionMethod)
|
||||||
|
@ -258,7 +258,7 @@ export async function downloadCache(
|
||||||
export async function reserveCache(
|
export async function reserveCache(
|
||||||
key: string,
|
key: string,
|
||||||
paths: string[],
|
paths: string[],
|
||||||
options?: CacheOptions
|
options?: InternalCacheOptions
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const httpClient = createHttpClient()
|
const httpClient = createHttpClient()
|
||||||
const version = getCacheVersion(paths, options?.compressionMethod)
|
const version = getCacheVersion(paths, options?.compressionMethod)
|
||||||
|
|
|
@ -20,6 +20,6 @@ export interface ReserveCacheResponse {
|
||||||
cacheId: number
|
cacheId: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CacheOptions {
|
export interface InternalCacheOptions {
|
||||||
compressionMethod?: CompressionMethod
|
compressionMethod?: CompressionMethod
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue