mirror of https://github.com/actions/toolkit
Address review comments
parent
a735d9bcd4
commit
aaac0e6c98
|
@ -115,20 +115,7 @@ export async function getCacheEntry(
|
||||||
const cacheDownloadUrl = cacheResult?.archiveLocation
|
const cacheDownloadUrl = cacheResult?.archiveLocation
|
||||||
if (!cacheDownloadUrl) {
|
if (!cacheDownloadUrl) {
|
||||||
// List cache for primary key only if cache miss occurs
|
// List cache for primary key only if cache miss occurs
|
||||||
const resource = `caches?key=${encodeURIComponent(keys[0])}`
|
await listCache(keys[0], httpClient, version)
|
||||||
const response = await httpClient.getJson<ArtifactCacheList>(getCacheApiUrl(resource))
|
|
||||||
if(response.statusCode === 204) {
|
|
||||||
const cacheListResult = response.result
|
|
||||||
const totalCount = cacheListResult?.totalCount
|
|
||||||
if(totalCount && totalCount > 0) {
|
|
||||||
core.info(`Cache miss occurred on the cache key '${keys[0]}' and version '${version} but there is ${totalCount} existing version of the cache for this key. More info on versioning can be found here: https://github.com/actions/cache#cache-version`)
|
|
||||||
core.debug(`Other versions are as follows:`)
|
|
||||||
cacheListResult?.artifactCaches?.forEach(cacheEntry => {
|
|
||||||
core.debug(`Cache Key: ${cacheEntry?.cacheKey}, Cache Version: ${cacheEntry?.cacheVersion}, Cache Scope: ${cacheEntry?.scope}, Cache Created: ${cacheEntry?.creationTime}`)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error('Cache not found.')
|
throw new Error('Cache not found.')
|
||||||
}
|
}
|
||||||
core.setSecret(cacheDownloadUrl)
|
core.setSecret(cacheDownloadUrl)
|
||||||
|
@ -138,6 +125,32 @@ export async function getCacheEntry(
|
||||||
return cacheResult
|
return cacheResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function listCache(
|
||||||
|
key: string,
|
||||||
|
httpClient: HttpClient,
|
||||||
|
version: string
|
||||||
|
): Promise<void> {
|
||||||
|
const resource = `caches?key=${encodeURIComponent(key)}`
|
||||||
|
const response = await retryTypedResponse('listCache', async () =>
|
||||||
|
httpClient.getJson<ArtifactCacheList>(getCacheApiUrl(resource))
|
||||||
|
)
|
||||||
|
if (response.statusCode === 204) {
|
||||||
|
const cacheListResult = response.result
|
||||||
|
const totalCount = cacheListResult?.totalCount
|
||||||
|
if (totalCount && totalCount > 0) {
|
||||||
|
core.info(
|
||||||
|
`Cache miss occurred on the cache key '${key}' and version '${version} but there is ${totalCount} existing version of the cache for this key. More info on versioning can be found here: https://github.com/actions/cache#cache-version`
|
||||||
|
)
|
||||||
|
core.debug(`Other versions are as follows:`)
|
||||||
|
cacheListResult?.artifactCaches?.forEach(cacheEntry => {
|
||||||
|
core.debug(
|
||||||
|
`Cache Key: ${cacheEntry?.cacheKey}, Cache Version: ${cacheEntry?.cacheVersion}, Cache Scope: ${cacheEntry?.scope}, Cache Created: ${cacheEntry?.creationTime}`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function downloadCache(
|
export async function downloadCache(
|
||||||
archiveLocation: string,
|
archiveLocation: string,
|
||||||
archivePath: string,
|
archivePath: string,
|
||||||
|
|
Loading…
Reference in New Issue