Stop warning when cache is not found (#40)

The cache not being found is a common situation so very visible warning
is a little too much.
This commit is contained in:
Birunthan Mohanathas 2019-11-04 10:03:18 -06:00 committed by Josh Gross
parent 57f889e86e
commit ce4a52af49
2 changed files with 11 additions and 7 deletions

View File

@ -10,7 +10,7 @@ import { ArtifactCacheEntry } from "./contracts";
export async function getCacheEntry( export async function getCacheEntry(
keys: string[] keys: string[]
): Promise<ArtifactCacheEntry> { ): Promise<ArtifactCacheEntry | null> {
const cacheUrl = getCacheUrl(); const cacheUrl = getCacheUrl();
const token = process.env["ACTIONS_RUNTIME_TOKEN"] || ""; const token = process.env["ACTIONS_RUNTIME_TOKEN"] || "";
const bearerCredentialHandler = new BearerCredentialHandler(token); const bearerCredentialHandler = new BearerCredentialHandler(token);
@ -28,9 +28,7 @@ export async function getCacheEntry(
getRequestOptions() getRequestOptions()
); );
if (response.statusCode === 204) { if (response.statusCode === 204) {
throw new Error( return null;
`Cache not found for input keys: ${JSON.stringify(keys)}.`
);
} }
if (response.statusCode !== 200) { if (response.statusCode !== 200) {
throw new Error(`Cache service responded with ${response.statusCode}`); throw new Error(`Cache service responded with ${response.statusCode}`);

View File

@ -49,14 +49,20 @@ async function run() {
} }
try { try {
const cacheEntry = await cacheHttpClient.getCacheEntry(keys);
if (!cacheEntry) {
core.info(
`Cache not found for input keys: ${JSON.stringify(keys)}.`
);
return;
}
let archivePath = path.join( let archivePath = path.join(
await utils.createTempDirectory(), await utils.createTempDirectory(),
"cache.tgz" "cache.tgz"
); );
core.debug(`Archive Path: ${archivePath}`); core.debug(`Archive Path: ${archivePath}`);
const cacheEntry = await cacheHttpClient.getCacheEntry(keys);
// Store the cache result // Store the cache result
utils.setCacheState(cacheEntry); utils.setCacheState(cacheEntry);