TRAP Caching: Re-introduce workaround for download timeout

This commit is contained in:
Edoardo Pirovano 2022-11-16 11:20:47 +00:00
parent c939e6615d
commit bfc56625b0
No known key found for this signature in database
GPG key ID: 047556B5D93FFE28
6 changed files with 16 additions and 12 deletions

1
lib/init-action.js generated
View file

@ -177,6 +177,7 @@ async function runWrapper() {
core.setFailed(`init action failed: ${error}`); core.setFailed(`init action failed: ${error}`);
console.log(error); console.log(error);
} }
await (0, util_1.checkForTimeout)();
} }
void runWrapper(); void runWrapper();
//# sourceMappingURL=init-action.js.map //# sourceMappingURL=init-action.js.map

File diff suppressed because one or more lines are too long

6
lib/trap-caching.js generated
View file

@ -100,11 +100,11 @@ async function downloadTrapCaches(codeql, languages, logger) {
// The SHA from the base of the PR is the most similar commit we might have a cache for // The SHA from the base of the PR is the most similar commit we might have a cache for
const preferredKey = await cacheKey(codeql, language, baseSha); const preferredKey = await cacheKey(codeql, language, baseSha);
logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`); logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`);
const found = await cache.restoreCache([cacheDir], preferredKey, [ const found = await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.restoreCache([cacheDir], preferredKey, [
// Fall back to any cache with the right key prefix // Fall back to any cache with the right key prefix
await cachePrefix(codeql, language), await cachePrefix(codeql, language),
], { ]), () => {
segmentTimeoutInMs: MAX_CACHE_OPERATION_MS, logger.info(`Timed out downloading cache for ${language}, will continue without it`);
}); });
if (found === undefined) { if (found === undefined) {
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is // We didn't find a TRAP cache in the Actions cache, so the directory on disk is

File diff suppressed because one or more lines are too long

View file

@ -29,6 +29,7 @@ import { parseRepositoryNwo } from "./repository";
import { getTotalCacheSize } from "./trap-caching"; import { getTotalCacheSize } from "./trap-caching";
import { import {
checkActionVersion, checkActionVersion,
checkForTimeout,
checkGitHubVersionInRange, checkGitHubVersionInRange,
codeQlVersionAbove, codeQlVersionAbove,
DEFAULT_DEBUG_ARTIFACT_NAME, DEFAULT_DEBUG_ARTIFACT_NAME,
@ -332,6 +333,7 @@ async function runWrapper() {
core.setFailed(`init action failed: ${error}`); core.setFailed(`init action failed: ${error}`);
console.log(error); console.log(error);
} }
await checkForTimeout();
} }
void runWrapper(); void runWrapper();

View file

@ -113,15 +113,16 @@ export async function downloadTrapCaches(
logger.info( logger.info(
`Looking in Actions cache for TRAP cache with key ${preferredKey}` `Looking in Actions cache for TRAP cache with key ${preferredKey}`
); );
const found = await cache.restoreCache( const found = await withTimeout(
[cacheDir], MAX_CACHE_OPERATION_MS,
preferredKey, cache.restoreCache([cacheDir], preferredKey, [
[
// Fall back to any cache with the right key prefix // Fall back to any cache with the right key prefix
await cachePrefix(codeql, language), await cachePrefix(codeql, language),
], ]),
{ () => {
segmentTimeoutInMs: MAX_CACHE_OPERATION_MS, logger.info(
`Timed out downloading cache for ${language}, will continue without it`
);
} }
); );
if (found === undefined) { if (found === undefined) {