From 8d91fa189dd7a678f4f9b218f0e255362f1097d8 Mon Sep 17 00:00:00 2001 From: Kasper Svendsen Date: Thu, 27 Nov 2025 15:39:50 +0100 Subject: [PATCH] Rename getMemoryFlagValue --- lib/analyze-action.js | 4 ++-- lib/init-action.js | 6 +++--- src/config-utils.test.ts | 2 +- src/config-utils.ts | 4 ++-- src/init-action.ts | 4 ++-- src/util.ts | 10 +++++----- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/analyze-action.js b/lib/analyze-action.js index f4d98a7ff..2ba02a47b 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -87093,7 +87093,7 @@ function getCgroupMemoryLimitBytes(limitFile, logger) { ); return limit; } -function getMemoryFlagValue(userInput, logger) { +function getCodeQLMemoryLimit(userInput, logger) { return getMemoryFlagValueForPlatform( userInput, getTotalMemoryBytes(logger), @@ -87101,7 +87101,7 @@ function getMemoryFlagValue(userInput, logger) { ); } function getMemoryFlag(userInput, logger) { - const megabytes = getMemoryFlagValue(userInput, logger); + const megabytes = getCodeQLMemoryLimit(userInput, logger); return `--ram=${megabytes}`; } function getThreadsFlagValue(userInput, logger) { diff --git a/lib/init-action.js b/lib/init-action.js index 7fc57970e..a5dd93847 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -84396,7 +84396,7 @@ function getCgroupMemoryLimitBytes(limitFile, logger) { ); return limit; } -function getMemoryFlagValue(userInput, logger) { +function getCodeQLMemoryLimit(userInput, logger) { return getMemoryFlagValueForPlatform( userInput, getTotalMemoryBytes(logger), @@ -86935,7 +86935,7 @@ async function runnerSupportsOverlayAnalysis(ramInput, logger) { ); return false; } - const memoryFlagValue = getMemoryFlagValue(ramInput, logger); + const memoryFlagValue = getCodeQLMemoryLimit(ramInput, logger); if (memoryFlagValue < OVERLAY_MINIMUM_MEMORY_MB) { logger.info( `Setting overlay database mode to ${"none" /* None */} due to insufficient memory for CodeQL analysis (${memoryFlagValue} MB).` @@ -90176,7 +90176,7 @@ exec ${goBinaryPath} "$@"` } core13.exportVariable( "CODEQL_RAM", - process.env["CODEQL_RAM"] || getMemoryFlagValue(getOptionalInput("ram"), logger).toString() + process.env["CODEQL_RAM"] || getCodeQLMemoryLimit(getOptionalInput("ram"), logger).toString() ); core13.exportVariable( "CODEQL_THREADS", diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index d07aacde2..9f4fb8f13 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -1040,7 +1040,7 @@ const getOverlayDatabaseModeMacro = test.macro({ .stub(actionsUtil, "isAnalyzingPullRequest") .returns(setup.isPullRequest); - sinon.stub(util, "getMemoryFlagValue").returns(setup.memoryFlagValue); + sinon.stub(util, "getCodeQLMemoryLimit").returns(setup.memoryFlagValue); // Set up CodeQL mock const codeql = mockCodeQLVersion(setup.codeqlVersion); diff --git a/src/config-utils.ts b/src/config-utils.ts index 15f56a350..34d625773 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -44,7 +44,7 @@ import { cloneObject, isDefined, checkDiskUsage, - getMemoryFlagValue, + getCodeQLMemoryLimit, } from "./util"; export * from "./config/db-config"; @@ -664,7 +664,7 @@ async function runnerSupportsOverlayAnalysis( return false; } - const memoryFlagValue = getMemoryFlagValue(ramInput, logger); + const memoryFlagValue = getCodeQLMemoryLimit(ramInput, logger); if (memoryFlagValue < OVERLAY_MINIMUM_MEMORY_MB) { logger.info( `Setting overlay database mode to ${OverlayDatabaseMode.None} ` + diff --git a/src/init-action.ts b/src/init-action.ts index 692f0370d..8fa7899d8 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -75,7 +75,7 @@ import { codeQlVersionAtLeast, DEFAULT_DEBUG_ARTIFACT_NAME, DEFAULT_DEBUG_DATABASE_NAME, - getMemoryFlagValue, + getCodeQLMemoryLimit, getRequiredEnvParam, getThreadsFlagValue, initializeEnvironment, @@ -538,7 +538,7 @@ async function run() { core.exportVariable( "CODEQL_RAM", process.env["CODEQL_RAM"] || - getMemoryFlagValue(getOptionalInput("ram"), logger).toString(), + getCodeQLMemoryLimit(getOptionalInput("ram"), logger).toString(), ); core.exportVariable( "CODEQL_THREADS", diff --git a/src/util.ts b/src/util.ts index aefcc5a2a..7bcdb4162 100644 --- a/src/util.ts +++ b/src/util.ts @@ -309,13 +309,13 @@ function getCgroupMemoryLimitBytes( } /** - * Get the value of the codeql `--ram` flag as configured by the `ram` input. - * If no value was specified, the total available memory will be used minus a + * Get the maximum amount of memory CodeQL is allowed to use. If no limit has been + * configured by the user, then the total available memory will be used minus a * threshold reserved for the OS. * - * @returns {number} the amount of RAM to use, in megabytes + * @returns {number} the amount of RAM CodeQL is allowed to use, in megabytes */ -export function getMemoryFlagValue( +export function getCodeQLMemoryLimit( userInput: string | undefined, logger: Logger, ): number { @@ -337,7 +337,7 @@ export function getMemoryFlag( userInput: string | undefined, logger: Logger, ): string { - const megabytes = getMemoryFlagValue(userInput, logger); + const megabytes = getCodeQLMemoryLimit(userInput, logger); return `--ram=${megabytes}`; }