Merge branch 'main' into mbg/deprecate-getRunnerLogger

This commit is contained in:
Michael B. Gale
2026-10-21 19:30:29 +01:00
11 changed files with 61 additions and 337 deletions

110
lib/entry-points.js generated
View File

@@ -170161,7 +170161,7 @@ function getDiffRangesJsonFilePath(env = getEnv()) {
return path2.join(getTemporaryDirectory(env), PR_DIFF_RANGE_JSON_FILENAME);
}
function getActionVersion() {
return "4.39.1";
return "4.39.2";
}
function getWorkflowEventName(env = getEnv()) {
return env.getRequired("GITHUB_EVENT_NAME" /* GITHUB_EVENT_NAME */);
@@ -170886,14 +170886,6 @@ async function listActionsCaches(keyPrefix, ref) {
}
);
}
async function deleteActionsCache(id) {
const repositoryNwo = getRepositoryNwo();
await getApiClient().rest.actions.deleteActionsCacheById({
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
cache_id: id
});
}
async function getRepositoryProperties(repositoryNwo) {
return getApiClient().request("GET /repos/:owner/:repo/properties/values", {
owner: repositoryNwo.owner,
@@ -171951,11 +171943,6 @@ var featureConfig = {
envVar: "CODEQL_ACTION_ALLOW_MULTIPLE_ANALYSIS_KINDS",
minimumVersion: void 0
},
["cleanup_trap_caches" /* CleanupTrapCaches */]: {
defaultValue: false,
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
minimumVersion: void 0
},
["config_file_repository_property" /* ConfigFileRepositoryProperty */]: {
defaultValue: false,
envVar: "CODEQL_ACTION_CONFIG_FILE_REPOSITORY_PROPERTY",
@@ -174264,83 +174251,16 @@ async function uploadTrapCaches(codeql, config, logger2) {
}
return true;
}
async function cleanupTrapCaches(config, features, logger2) {
const env = getEnv();
if (!await features.getValue("cleanup_trap_caches" /* CleanupTrapCaches */)) {
return {
trap_cache_cleanup_skipped_because: "feature disabled"
};
}
logger2.warning(
"TRAP cache cleanup is deprecated and will be removed in May 2026. We recommend instead disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action."
);
if (!await isAnalyzingDefaultBranch(env, config.repositoryRoot)) {
return {
trap_cache_cleanup_skipped_because: "not analyzing default branch"
};
}
try {
let totalBytesCleanedUp = 0;
const allCaches = await listActionsCaches(
CODEQL_TRAP_CACHE_PREFIX,
await getRef(env, config.repositoryRoot)
function warnIfTrapCacheCleanupEnvVarIsSet({
env,
logger: logger2
}) {
if (env.getOptional("CODEQL_ACTION_CLEANUP_TRAP_CACHES") !== void 0) {
logger2.warning(
"TRAP cache cleanup has been removed, so the CODEQL_ACTION_CLEANUP_TRAP_CACHES environment variable no longer has any effect and can be removed from your workflow. If you used TRAP cache cleanup to limit Actions cache usage, we recommend disabling TRAP caching instead by passing the `trap-caching: false` input to the `init` Action."
);
for (const language of config.languages) {
if (config.trapCaches[language]) {
const cachesToRemove = await getTrapCachesForLanguage(
allCaches,
language,
logger2
);
cachesToRemove.sort((a, b) => a.created_at.localeCompare(b.created_at));
const mostRecentCache = cachesToRemove.pop();
logger2.debug(
`Keeping most recent TRAP cache (${JSON.stringify(mostRecentCache)})`
);
if (cachesToRemove.length === 0) {
logger2.info(`No TRAP caches to clean up for ${language}.`);
continue;
}
for (const cache of cachesToRemove) {
logger2.debug(`Cleaning up TRAP cache (${JSON.stringify(cache)})`);
await deleteActionsCache(cache.id);
}
const bytesCleanedUp = cachesToRemove.reduce(
(acc, item) => acc + item.size_in_bytes,
0
);
totalBytesCleanedUp += bytesCleanedUp;
const megabytesCleanedUp = (bytesCleanedUp / (1024 * 1024)).toFixed(2);
logger2.info(
`Cleaned up ${megabytesCleanedUp} MiB of old TRAP caches for ${language}.`
);
}
}
return { trap_cache_cleanup_size_bytes: totalBytesCleanedUp };
} catch (e) {
if (asHTTPError(e)?.status === 403) {
logger2.warning(
`Could not cleanup TRAP caches as the token did not have the required permissions. To clean up TRAP caches, ensure the token has the "actions:write" permission. See ${"https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs" /* ASSIGNING_PERMISSIONS_TO_JOBS */} for more information.`
);
} else {
logger2.info(`Failed to cleanup TRAP caches, continuing. Details: ${e}`);
}
return { trap_cache_cleanup_error: getErrorMessage(e) };
}
}
async function getTrapCachesForLanguage(allCaches, language, logger2) {
logger2.debug(`Listing TRAP caches for ${language}`);
for (const cache of allCaches) {
if (!cache.created_at || !cache.id || !cache.key || !cache.size_in_bytes) {
throw new Error(
`An unexpected cache item was returned from the API that was missing one or more required fields: ${JSON.stringify(cache)}`
);
}
}
return allCaches.filter((cache) => {
return cache.key?.includes(`-${language}-`);
});
}
async function getLanguagesSupportingCaching(codeql, languages, logger2) {
const result = [];
const resolveResult = await codeql.resolveLanguages();
@@ -180678,7 +180598,7 @@ async function postProcessAndUploadSarif(logger2, features, config, uploadKind,
}
// src/analyze-action.ts
async function sendStatusReport2(startedAt, config, stats, error3, trapCacheUploadTime, dbCreationTimings, didUploadTrapCaches, trapCacheCleanup, dependencyCacheResults, databaseUploadResults, logger2) {
async function sendStatusReport2(startedAt, config, stats, error3, trapCacheUploadTime, dbCreationTimings, didUploadTrapCaches, dependencyCacheResults, databaseUploadResults, logger2) {
const status = getActionsStatus(error3, stats?.analyze_failure_language);
const statusReportBase = await createStatusReportBase(
"finish" /* Analyze */,
@@ -180695,7 +180615,6 @@ async function sendStatusReport2(startedAt, config, stats, error3, trapCacheUplo
...statusReportBase,
...stats || {},
...dbCreationTimings || {},
...trapCacheCleanup || {},
dependency_caching_upload_results: dependencyCacheResults,
database_upload_results: databaseUploadResults
};
@@ -180779,7 +180698,6 @@ async function run(action) {
let uploadResults = void 0;
let runStats = void 0;
let config = void 0;
let trapCacheCleanupTelemetry = void 0;
let trapCacheUploadTime = void 0;
let dbCreationTimings = void 0;
let didUploadTrapCaches = false;
@@ -180816,6 +180734,7 @@ async function run(action) {
"The 'cleanup-level' input is ignored since the CodeQL Action now automatically manages database cleanup. This input can safely be removed from your workflow."
);
}
warnIfTrapCacheCleanupEnvVarIsSet(action);
const apiDetails = getApiDetails();
const outputDir = getRequiredInput("output");
action.env.export("CODEQL_ACTION_SARIF_RESULTS_OUTPUT_DIR" /* SARIF_RESULTS_OUTPUT_DIR */, outputDir);
@@ -180924,11 +180843,6 @@ async function run(action) {
const trapCacheUploadStartTime = import_perf_hooks6.performance.now();
didUploadTrapCaches = await uploadTrapCaches(codeql, config, logger2);
trapCacheUploadTime = import_perf_hooks6.performance.now() - trapCacheUploadStartTime;
trapCacheCleanupTelemetry = await cleanupTrapCaches(
config,
features,
logger2
);
if (shouldStoreCache(config.dependencyCachingEnabled)) {
dependencyCacheResults = await uploadDependencyCaches(
codeql,
@@ -180967,7 +180881,6 @@ async function run(action) {
trapCacheUploadTime,
dbCreationTimings,
didUploadTrapCaches,
trapCacheCleanupTelemetry,
dependencyCacheResults,
databaseUploadResults,
logger2
@@ -180986,7 +180899,6 @@ async function run(action) {
trapCacheUploadTime,
dbCreationTimings,
didUploadTrapCaches,
trapCacheCleanupTelemetry,
dependencyCacheResults,
databaseUploadResults,
logger2
@@ -181000,7 +180912,6 @@ async function run(action) {
trapCacheUploadTime,
dbCreationTimings,
didUploadTrapCaches,
trapCacheCleanupTelemetry,
dependencyCacheResults,
databaseUploadResults,
logger2
@@ -181014,7 +180925,6 @@ async function run(action) {
trapCacheUploadTime,
dbCreationTimings,
didUploadTrapCaches,
trapCacheCleanupTelemetry,
dependencyCacheResults,
databaseUploadResults,
logger2