mirror of
https://github.com/github/codeql-action.git
synced 2025-12-12 02:34:39 +08:00
Compare commits
2 Commits
codeql-bun
...
henrymerce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73219afa86 | ||
|
|
ccf0dd6f24 |
2
lib/analyze-action.js
generated
2
lib/analyze-action.js
generated
@@ -163,7 +163,7 @@ async function run() {
|
|||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||||
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
||||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"], logger);
|
||||||
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
||||||
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, features);
|
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, features);
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
lib/init-action.js
generated
2
lib/init-action.js
generated
@@ -173,7 +173,7 @@ async function run() {
|
|||||||
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
||||||
// for details.
|
// for details.
|
||||||
core.exportVariable("CODEQL_RAM", process.env["CODEQL_RAM"] ||
|
core.exportVariable("CODEQL_RAM", process.env["CODEQL_RAM"] ||
|
||||||
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
|
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram"), logger).toString());
|
||||||
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
|
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
|
||||||
// Disable Kotlin extractor if feature flag set
|
// Disable Kotlin extractor if feature flag set
|
||||||
if (await features.getValue(feature_flags_1.Feature.DisableKotlinAnalysisEnabled)) {
|
if (await features.getValue(feature_flags_1.Feature.DisableKotlinAnalysisEnabled)) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
14
lib/util.js
generated
14
lib/util.js
generated
@@ -152,7 +152,7 @@ exports.getMemoryFlagValueForPlatform = getMemoryFlagValueForPlatform;
|
|||||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||||
* by cgroups on Linux.
|
* by cgroups on Linux.
|
||||||
*/
|
*/
|
||||||
function getTotalMemoryAvailable() {
|
function getTotalMemoryAvailable(logger) {
|
||||||
if (os.platform() === "linux") {
|
if (os.platform() === "linux") {
|
||||||
// Respect constraints imposed by Linux cgroups v1 and v2
|
// Respect constraints imposed by Linux cgroups v1 and v2
|
||||||
for (const limitFile of [
|
for (const limitFile of [
|
||||||
@@ -160,8 +160,10 @@ function getTotalMemoryAvailable() {
|
|||||||
"/sys/fs/cgroup/memory.max",
|
"/sys/fs/cgroup/memory.max",
|
||||||
]) {
|
]) {
|
||||||
if (fs.existsSync(limitFile)) {
|
if (fs.existsSync(limitFile)) {
|
||||||
const limit = Number(fs.readFileSync(limitFile, "utf8"));
|
const contents = fs.readFileSync(limitFile, "utf8");
|
||||||
|
const limit = Number(contents);
|
||||||
if (Number.isInteger(limit)) {
|
if (Number.isInteger(limit)) {
|
||||||
|
logger.info(`While resolving RAM, found cgroup limit of ${limit / (1024 * 1024)} MiB based on file contents "${contents}" in ${limitFile}.`);
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,8 +178,8 @@ function getTotalMemoryAvailable() {
|
|||||||
*
|
*
|
||||||
* @returns {number} the amount of RAM to use, in megabytes
|
* @returns {number} the amount of RAM to use, in megabytes
|
||||||
*/
|
*/
|
||||||
function getMemoryFlagValue(userInput) {
|
function getMemoryFlagValue(userInput, logger) {
|
||||||
return getMemoryFlagValueForPlatform(userInput, getTotalMemoryAvailable(), process.platform);
|
return getMemoryFlagValueForPlatform(userInput, getTotalMemoryAvailable(logger), process.platform);
|
||||||
}
|
}
|
||||||
exports.getMemoryFlagValue = getMemoryFlagValue;
|
exports.getMemoryFlagValue = getMemoryFlagValue;
|
||||||
/**
|
/**
|
||||||
@@ -187,8 +189,8 @@ exports.getMemoryFlagValue = getMemoryFlagValue;
|
|||||||
*
|
*
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
function getMemoryFlag(userInput) {
|
function getMemoryFlag(userInput, logger) {
|
||||||
const megabytes = getMemoryFlagValue(userInput);
|
const megabytes = getMemoryFlagValue(userInput, logger);
|
||||||
return `--ram=${megabytes}`;
|
return `--ram=${megabytes}`;
|
||||||
}
|
}
|
||||||
exports.getMemoryFlag = getMemoryFlag;
|
exports.getMemoryFlag = getMemoryFlag;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2
lib/util.test.js
generated
2
lib/util.test.js
generated
@@ -97,7 +97,7 @@ for (const { input, totalMemoryMb, platform, expectedMemoryValue, reservedPercen
|
|||||||
}
|
}
|
||||||
(0, ava_1.default)("getMemoryFlag() throws if the ram input is < 0 or NaN", async (t) => {
|
(0, ava_1.default)("getMemoryFlag() throws if the ram input is < 0 or NaN", async (t) => {
|
||||||
for (const input of ["-1", "hello!"]) {
|
for (const input of ["-1", "hello!"]) {
|
||||||
t.throws(() => util.getMemoryFlag(input));
|
t.throws(() => util.getMemoryFlag(input, (0, logging_1.getRunnerLogger)(true)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getAddSnippetsFlag() should return the correct flag", (t) => {
|
(0, ava_1.default)("getAddSnippetsFlag() should return the correct flag", (t) => {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -233,6 +233,7 @@ async function run() {
|
|||||||
|
|
||||||
const memory = util.getMemoryFlag(
|
const memory = util.getMemoryFlag(
|
||||||
actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"],
|
actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"],
|
||||||
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
await runAutobuildIfLegacyGoWorkflow(config, logger);
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ async function run() {
|
|||||||
core.exportVariable(
|
core.exportVariable(
|
||||||
"CODEQL_RAM",
|
"CODEQL_RAM",
|
||||||
process.env["CODEQL_RAM"] ||
|
process.env["CODEQL_RAM"] ||
|
||||||
getMemoryFlagValue(getOptionalInput("ram")).toString(),
|
getMemoryFlagValue(getOptionalInput("ram"), logger).toString(),
|
||||||
);
|
);
|
||||||
core.exportVariable(
|
core.exportVariable(
|
||||||
"CODEQL_THREADS",
|
"CODEQL_THREADS",
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ for (const {
|
|||||||
|
|
||||||
test("getMemoryFlag() throws if the ram input is < 0 or NaN", async (t) => {
|
test("getMemoryFlag() throws if the ram input is < 0 or NaN", async (t) => {
|
||||||
for (const input of ["-1", "hello!"]) {
|
for (const input of ["-1", "hello!"]) {
|
||||||
t.throws(() => util.getMemoryFlag(input));
|
t.throws(() => util.getMemoryFlag(input, getRunnerLogger(true)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
24
src/util.ts
24
src/util.ts
@@ -215,7 +215,7 @@ export function getMemoryFlagValueForPlatform(
|
|||||||
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
* Get the total amount of memory available to the Action, taking into account constraints imposed
|
||||||
* by cgroups on Linux.
|
* by cgroups on Linux.
|
||||||
*/
|
*/
|
||||||
function getTotalMemoryAvailable(): number {
|
function getTotalMemoryAvailable(logger: Logger): number {
|
||||||
if (os.platform() === "linux") {
|
if (os.platform() === "linux") {
|
||||||
// Respect constraints imposed by Linux cgroups v1 and v2
|
// Respect constraints imposed by Linux cgroups v1 and v2
|
||||||
for (const limitFile of [
|
for (const limitFile of [
|
||||||
@@ -223,8 +223,14 @@ function getTotalMemoryAvailable(): number {
|
|||||||
"/sys/fs/cgroup/memory.max",
|
"/sys/fs/cgroup/memory.max",
|
||||||
]) {
|
]) {
|
||||||
if (fs.existsSync(limitFile)) {
|
if (fs.existsSync(limitFile)) {
|
||||||
const limit = Number(fs.readFileSync(limitFile, "utf8"));
|
const contents = fs.readFileSync(limitFile, "utf8");
|
||||||
|
const limit = Number(contents);
|
||||||
if (Number.isInteger(limit)) {
|
if (Number.isInteger(limit)) {
|
||||||
|
logger.info(
|
||||||
|
`While resolving RAM, found cgroup limit of ${
|
||||||
|
limit / (1024 * 1024)
|
||||||
|
} MiB based on file contents "${contents}" in ${limitFile}.`,
|
||||||
|
);
|
||||||
return limit;
|
return limit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,10 +246,13 @@ function getTotalMemoryAvailable(): number {
|
|||||||
*
|
*
|
||||||
* @returns {number} the amount of RAM to use, in megabytes
|
* @returns {number} the amount of RAM to use, in megabytes
|
||||||
*/
|
*/
|
||||||
export function getMemoryFlagValue(userInput: string | undefined): number {
|
export function getMemoryFlagValue(
|
||||||
|
userInput: string | undefined,
|
||||||
|
logger: Logger,
|
||||||
|
): number {
|
||||||
return getMemoryFlagValueForPlatform(
|
return getMemoryFlagValueForPlatform(
|
||||||
userInput,
|
userInput,
|
||||||
getTotalMemoryAvailable(),
|
getTotalMemoryAvailable(logger),
|
||||||
process.platform,
|
process.platform,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -255,8 +264,11 @@ export function getMemoryFlagValue(userInput: string | undefined): number {
|
|||||||
*
|
*
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export function getMemoryFlag(userInput: string | undefined): string {
|
export function getMemoryFlag(
|
||||||
const megabytes = getMemoryFlagValue(userInput);
|
userInput: string | undefined,
|
||||||
|
logger: Logger,
|
||||||
|
): string {
|
||||||
|
const megabytes = getMemoryFlagValue(userInput, logger);
|
||||||
return `--ram=${megabytes}`;
|
return `--ram=${megabytes}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user