mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 14:40:10 +08:00
Merge branch 'main' into retrying-fix
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
runAnalyze,
|
||||
CodeQLAnalysisError,
|
||||
QueriesStatusReport,
|
||||
runCleanup,
|
||||
} from "./analyze";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { getActionsLogger } from "./logging";
|
||||
@@ -89,6 +90,20 @@ async function run() {
|
||||
logger
|
||||
);
|
||||
|
||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
||||
await runCleanup(
|
||||
config,
|
||||
actionsUtil.getOptionalInput("cleanup-level") || "brutal",
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
const dbLocations: { [lang: string]: string } = {};
|
||||
for (const language of config.languages) {
|
||||
dbLocations[language] = util.getCodeQLDatabasePath(config, language);
|
||||
}
|
||||
core.setOutput("db-locations", dbLocations);
|
||||
|
||||
if (actionsUtil.getRequiredInput("upload") === "true") {
|
||||
const uploadStats = await upload_lib.uploadFromActions(
|
||||
outputDir,
|
||||
|
||||
@@ -322,6 +322,19 @@ export async function runAnalyze(
|
||||
return { ...queriesStats };
|
||||
}
|
||||
|
||||
export async function runCleanup(
|
||||
config: configUtils.Config,
|
||||
cleanupLevel: string,
|
||||
logger: Logger
|
||||
): Promise<void> {
|
||||
logger.info("Cleaning up databases...");
|
||||
for (const language of config.languages) {
|
||||
const codeql = getCodeQL(config.codeQLCmd);
|
||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||
await codeql.databaseCleanup(databasePath, cleanupLevel);
|
||||
}
|
||||
}
|
||||
|
||||
async function injectLinesOfCode(
|
||||
sarifFile: string,
|
||||
language: Language,
|
||||
|
||||
@@ -101,6 +101,10 @@ export interface CodeQL {
|
||||
threadsFlag: string,
|
||||
automationDetailsId: string | undefined
|
||||
): Promise<string>;
|
||||
/**
|
||||
* Run 'codeql database cleanup'.
|
||||
*/
|
||||
databaseCleanup(databasePath: string, cleanupLevel: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ResolveLanguagesOutput {
|
||||
@@ -481,6 +485,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
||||
resolveLanguages: resolveFunction(partialCodeql, "resolveLanguages"),
|
||||
resolveQueries: resolveFunction(partialCodeql, "resolveQueries"),
|
||||
databaseAnalyze: resolveFunction(partialCodeql, "databaseAnalyze"),
|
||||
databaseCleanup: resolveFunction(partialCodeql, "databaseCleanup"),
|
||||
};
|
||||
return cachedCodeQL;
|
||||
}
|
||||
@@ -722,6 +727,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
||||
"--min-disk-free=1024", // Try to leave at least 1GB free
|
||||
"--format=sarif-latest",
|
||||
"--sarif-multicause-markdown",
|
||||
"--sarif-group-rules-by-pack",
|
||||
`--output=${sarifFile}`,
|
||||
addSnippetsFlag,
|
||||
// Enable progress verbosity so we log each query as it's interpreted. This aids debugging
|
||||
@@ -747,6 +753,18 @@ function getCodeQLForCmd(cmd: string): CodeQL {
|
||||
}).exec();
|
||||
return output;
|
||||
},
|
||||
async databaseCleanup(
|
||||
databasePath: string,
|
||||
cleanupLevel: string
|
||||
): Promise<void> {
|
||||
const args = [
|
||||
"database",
|
||||
"cleanup",
|
||||
databasePath,
|
||||
`--mode=${cleanupLevel}`,
|
||||
];
|
||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user