mirror of
https://github.com/github/codeql-action.git
synced 2025-12-09 17:28:06 +08:00
Add --ram and --threads args
This commit is contained in:
22
lib/util.js
generated
22
lib/util.js
generated
@@ -304,13 +304,12 @@ exports.withTmpDir = withTmpDir;
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
function getMemoryFlag() {
|
||||
function getMemoryFlag(userInput) {
|
||||
let memoryToUseMegaBytes;
|
||||
const memoryToUseString = core.getInput("ram");
|
||||
if (memoryToUseString) {
|
||||
memoryToUseMegaBytes = Number(memoryToUseString);
|
||||
if (userInput) {
|
||||
memoryToUseMegaBytes = Number(userInput);
|
||||
if (Number.isNaN(memoryToUseMegaBytes) || memoryToUseMegaBytes <= 0) {
|
||||
throw new Error("Invalid RAM setting \"" + memoryToUseString + "\", specified.");
|
||||
throw new Error("Invalid RAM setting \"" + userInput + "\", specified.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -330,22 +329,21 @@ exports.getMemoryFlag = getMemoryFlag;
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
function getThreadsFlag() {
|
||||
function getThreadsFlag(userInput, logger) {
|
||||
let numThreads;
|
||||
const numThreadsString = core.getInput("threads");
|
||||
const maxThreads = os.cpus().length;
|
||||
if (numThreadsString) {
|
||||
numThreads = Number(numThreadsString);
|
||||
if (userInput) {
|
||||
numThreads = Number(userInput);
|
||||
if (Number.isNaN(numThreads)) {
|
||||
throw new Error(`Invalid threads setting "${numThreadsString}", specified.`);
|
||||
throw new Error(`Invalid threads setting "${userInput}", specified.`);
|
||||
}
|
||||
if (numThreads > maxThreads) {
|
||||
core.info(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
|
||||
logger.info(`Clamping desired number of threads (${numThreads}) to max available (${maxThreads}).`);
|
||||
numThreads = maxThreads;
|
||||
}
|
||||
const minThreads = -maxThreads;
|
||||
if (numThreads < minThreads) {
|
||||
core.info(`Clamping desired number of free threads (${numThreads}) to max available (${minThreads}).`);
|
||||
logger.info(`Clamping desired number of free threads (${numThreads}) to max available (${minThreads}).`);
|
||||
numThreads = minThreads;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user