Invoke cleanup in analyze Action

This commit is contained in:
Henry Mercer 2024-05-21 21:12:45 +01:00
parent 4fd6c0d4f1
commit 0b4214972e
6 changed files with 32 additions and 11 deletions

View file

@ -32,7 +32,11 @@ import {
getActionsStatus,
StatusReportBase,
} from "./status-report";
import { getTotalCacheSize, uploadTrapCaches } from "./trap-caching";
import {
cleanupTrapCaches,
getTotalCacheSize,
uploadTrapCaches,
} from "./trap-caching";
import * as uploadLib from "./upload-lib";
import { UploadResult } from "./upload-lib";
import * as util from "./util";
@ -311,6 +315,9 @@ async function run() {
didUploadTrapCaches = await uploadTrapCaches(codeql, config, logger);
trapCacheUploadTime = performance.now() - trapCacheUploadStartTime;
// Clean up TRAP caches
await cleanupTrapCaches(config, logger);
// We don't upload results in test mode, so don't wait for processing
if (util.isInTestMode()) {
logger.debug("In test mode. Waiting for processing is disabled.");

View file

@ -161,11 +161,17 @@ export async function uploadTrapCaches(
return true;
}
export async function cleanupTrapCaches(language: Language, logger: Logger) {
export async function cleanupTrapCaches(config: Config, logger: Logger) {
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return;
try {
const matchingCaches = await getTrapCachesForLanguage(language);
for (const cache of matchingCaches) {
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
for (const language of config.languages) {
if (config.trapCaches[language]) {
const matchingCaches = await getTrapCachesForLanguage(language);
for (const cache of matchingCaches) {
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
}
}
}
} catch (e) {
logger.info(`Failed to cleanup trap caches, continuing. Details: ${e}`);