build: refresh js files

This commit is contained in:
Chuan-kai Lin 2024-12-09 14:44:56 -08:00
parent b2c41ecd38
commit 300d251cd6
28 changed files with 706 additions and 641 deletions

9
lib/trap-caching.js generated
View file

@ -44,6 +44,7 @@ const actionsUtil = __importStar(require("./actions-util"));
const apiClient = __importStar(require("./api-client"));
const doc_url_1 = require("./doc-url");
const feature_flags_1 = require("./feature-flags");
const gitUtils = __importStar(require("./git-utils"));
const util_1 = require("./util");
// This constant should be bumped if we make a breaking change
// to how the CodeQL Action stores or retrieves the TRAP cache,
@ -80,7 +81,7 @@ async function downloadTrapCaches(codeql, languages, logger) {
fs.mkdirSync(cacheDir, { recursive: true });
result[language] = cacheDir;
}
if (await actionsUtil.isAnalyzingDefaultBranch()) {
if (await gitUtils.isAnalyzingDefaultBranch()) {
logger.info("Analyzing default branch. Skipping downloading of TRAP caches.");
return result;
}
@ -122,7 +123,7 @@ async function downloadTrapCaches(codeql, languages, logger) {
* @returns Whether the TRAP caches were uploaded.
*/
async function uploadTrapCaches(codeql, config, logger) {
if (!(await actionsUtil.isAnalyzingDefaultBranch()))
if (!(await gitUtils.isAnalyzingDefaultBranch()))
return false; // Only upload caches from the default branch
for (const language of config.languages) {
const cacheDir = config.trapCaches[language];
@ -151,14 +152,14 @@ async function cleanupTrapCaches(config, features, logger) {
trap_cache_cleanup_skipped_because: "feature disabled",
};
}
if (!(await actionsUtil.isAnalyzingDefaultBranch())) {
if (!(await gitUtils.isAnalyzingDefaultBranch())) {
return {
trap_cache_cleanup_skipped_because: "not analyzing default branch",
};
}
try {
let totalBytesCleanedUp = 0;
const allCaches = await apiClient.listActionsCaches(CODEQL_TRAP_CACHE_PREFIX, await actionsUtil.getRef());
const allCaches = await apiClient.listActionsCaches(CODEQL_TRAP_CACHE_PREFIX, await gitUtils.getRef());
for (const language of config.languages) {
if (config.trapCaches[language]) {
const cachesToRemove = await getTrapCachesForLanguage(allCaches, language, logger);