Invoke cleanup in analyze Action
This commit is contained in:
parent
4fd6c0d4f1
commit
0b4214972e
6 changed files with 32 additions and 11 deletions
2
lib/analyze-action.js
generated
2
lib/analyze-action.js
generated
|
|
@ -196,6 +196,8 @@ async function run() {
|
||||||
const trapCacheUploadStartTime = perf_hooks_1.performance.now();
|
const trapCacheUploadStartTime = perf_hooks_1.performance.now();
|
||||||
didUploadTrapCaches = await (0, trap_caching_1.uploadTrapCaches)(codeql, config, logger);
|
didUploadTrapCaches = await (0, trap_caching_1.uploadTrapCaches)(codeql, config, logger);
|
||||||
trapCacheUploadTime = perf_hooks_1.performance.now() - trapCacheUploadStartTime;
|
trapCacheUploadTime = perf_hooks_1.performance.now() - trapCacheUploadStartTime;
|
||||||
|
// Clean up TRAP caches
|
||||||
|
await (0, trap_caching_1.cleanupTrapCaches)(config, logger);
|
||||||
// We don't upload results in test mode, so don't wait for processing
|
// We don't upload results in test mode, so don't wait for processing
|
||||||
if (util.isInTestMode()) {
|
if (util.isInTestMode()) {
|
||||||
logger.debug("In test mode. Waiting for processing is disabled.");
|
logger.debug("In test mode. Waiting for processing is disabled.");
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
8
lib/trap-caching.js
generated
8
lib/trap-caching.js
generated
|
|
@ -132,13 +132,19 @@ async function uploadTrapCaches(codeql, config, logger) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
exports.uploadTrapCaches = uploadTrapCaches;
|
exports.uploadTrapCaches = uploadTrapCaches;
|
||||||
async function cleanupTrapCaches(language, logger) {
|
async function cleanupTrapCaches(config, logger) {
|
||||||
|
if (!(await actionsUtil.isAnalyzingDefaultBranch()))
|
||||||
|
return;
|
||||||
try {
|
try {
|
||||||
|
for (const language of config.languages) {
|
||||||
|
if (config.trapCaches[language]) {
|
||||||
const matchingCaches = await getTrapCachesForLanguage(language);
|
const matchingCaches = await getTrapCachesForLanguage(language);
|
||||||
for (const cache of matchingCaches) {
|
for (const cache of matchingCaches) {
|
||||||
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
|
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.info(`Failed to cleanup trap caches, continuing. Details: ${e}`);
|
logger.info(`Failed to cleanup trap caches, continuing. Details: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -32,7 +32,11 @@ import {
|
||||||
getActionsStatus,
|
getActionsStatus,
|
||||||
StatusReportBase,
|
StatusReportBase,
|
||||||
} from "./status-report";
|
} from "./status-report";
|
||||||
import { getTotalCacheSize, uploadTrapCaches } from "./trap-caching";
|
import {
|
||||||
|
cleanupTrapCaches,
|
||||||
|
getTotalCacheSize,
|
||||||
|
uploadTrapCaches,
|
||||||
|
} from "./trap-caching";
|
||||||
import * as uploadLib from "./upload-lib";
|
import * as uploadLib from "./upload-lib";
|
||||||
import { UploadResult } from "./upload-lib";
|
import { UploadResult } from "./upload-lib";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
@ -311,6 +315,9 @@ async function run() {
|
||||||
didUploadTrapCaches = await uploadTrapCaches(codeql, config, logger);
|
didUploadTrapCaches = await uploadTrapCaches(codeql, config, logger);
|
||||||
trapCacheUploadTime = performance.now() - trapCacheUploadStartTime;
|
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
|
// We don't upload results in test mode, so don't wait for processing
|
||||||
if (util.isInTestMode()) {
|
if (util.isInTestMode()) {
|
||||||
logger.debug("In test mode. Waiting for processing is disabled.");
|
logger.debug("In test mode. Waiting for processing is disabled.");
|
||||||
|
|
|
||||||
|
|
@ -161,12 +161,18 @@ export async function uploadTrapCaches(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function cleanupTrapCaches(language: Language, logger: Logger) {
|
export async function cleanupTrapCaches(config: Config, logger: Logger) {
|
||||||
|
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
for (const language of config.languages) {
|
||||||
|
if (config.trapCaches[language]) {
|
||||||
const matchingCaches = await getTrapCachesForLanguage(language);
|
const matchingCaches = await getTrapCachesForLanguage(language);
|
||||||
for (const cache of matchingCaches) {
|
for (const cache of matchingCaches) {
|
||||||
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
|
logger.info(`Matched Actions cache ${JSON.stringify(cache)}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.info(`Failed to cleanup trap caches, continuing. Details: ${e}`);
|
logger.info(`Failed to cleanup trap caches, continuing. Details: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue