Include diagnostics in bundle

This commit is contained in:
Henry Mercer
2026-02-17 13:38:09 +00:00
parent 554b93127b
commit 5c583bbb19
13 changed files with 81 additions and 27 deletions

View File

@@ -162177,14 +162177,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

15
lib/analyze-action.js generated
View File

@@ -106084,7 +106084,7 @@ async function codeQlVersionAtLeast(codeql, requiredVersion) {
function getBaseDatabaseOidsFilePath(config) {
return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME);
}
async function bundleDb(config, language, codeql, dbName) {
async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) {
const databasePath = getCodeQLDatabasePath(config, language);
const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`);
if (fs.existsSync(databaseBundlePath)) {
@@ -106103,6 +106103,7 @@ async function bundleDb(config, language, codeql, dbName) {
databasePath,
databaseBundlePath,
dbName,
includeDiagnostics,
additionalFiles
);
return databaseBundlePath;
@@ -109870,14 +109871,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(
@@ -110786,7 +110791,9 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai
for (const language of config.languages) {
let bundledDbSize = void 0;
try {
const bundledDb = await bundleDb(config, language, codeql, language);
const bundledDb = await bundleDb(config, language, codeql, language, {
includeDiagnostics: false
});
bundledDbSize = fs13.statSync(bundledDb).size;
const bundledDbReadStream = fs13.createReadStream(bundledDb);
const commitOid = await getCommitOid(

View File

@@ -104898,14 +104898,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

View File

@@ -163662,7 +163662,7 @@ async function codeQlVersionAtLeast(codeql, requiredVersion) {
function getBaseDatabaseOidsFilePath(config) {
return path.join(config.dbLocation, BASE_DATABASE_OIDS_FILE_NAME);
}
async function bundleDb(config, language, codeql, dbName) {
async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) {
const databasePath = getCodeQLDatabasePath(config, language);
const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`);
if (fs.existsSync(databaseBundlePath)) {
@@ -163681,6 +163681,7 @@ async function bundleDb(config, language, codeql, dbName) {
databasePath,
databaseBundlePath,
dbName,
includeDiagnostics,
additionalFiles
);
return databaseBundlePath;
@@ -166993,14 +166994,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(
@@ -167758,7 +167763,8 @@ async function createDatabaseBundleCli(codeql, config, language) {
config,
language,
codeql,
`${config.debugDatabaseName}-${language}`
`${config.debugDatabaseName}-${language}`,
{ includeDiagnostics: true }
);
return databaseBundlePath;
}

14
lib/init-action.js generated
View File

@@ -105715,8 +105715,8 @@ async function shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger) {
return false;
}
if (status.attemptedToBuildOverlayBaseDatabase && !status.builtOverlayBaseDatabase) {
logger.info(
"Cached overlay status indicates that building an overlay base database was unsuccessful, so will skip overlay analysis."
logger.debug(
"Cached overlay status indicates that building an overlay base database was unsuccessful."
);
return true;
}
@@ -106178,7 +106178,7 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b
);
if (diskUsage && await features.getValue("overlay_analysis_status_check" /* OverlayAnalysisStatusCheck */) && await shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger)) {
logger.info(
`Setting overlay database mode to ${"none" /* None */} because overlay analysis previously failed with this combination of languages, disk space, and CodeQL version. Consider running CodeQL analysis on a larger runner.`
`Setting overlay database mode to ${"none" /* None */} because overlay analysis previously failed with this combination of languages, disk space, and CodeQL version.`
);
overlayDatabaseMode = "none" /* None */;
skippedDueToCachedStatus = true;
@@ -108334,14 +108334,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

View File

@@ -104575,14 +104575,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

View File

@@ -105985,14 +105985,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

8
lib/upload-lib.js generated
View File

@@ -108733,14 +108733,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

View File

@@ -109284,14 +109284,18 @@ ${output}`
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName, alsoIncludeRelativePaths) {
async databaseBundle(databasePath, outputFilePath, databaseName, includeDiagnostics, alsoIncludeRelativePaths) {
const includeDiagnosticsArgs = includeDiagnostics ? ["--include-diagnostics"] : [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"])
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs
})
];
if (await this.supportsFeature("bundleSupportsIncludeOption" /* BundleSupportsIncludeOption */)) {
args.push(

View File

@@ -160,6 +160,7 @@ export interface CodeQL {
databasePath: string,
outputFilePath: string,
dbName: string,
includeDiagnostics: boolean,
alsoIncludeRelativePaths: string[],
): Promise<void>;
/**
@@ -912,15 +913,22 @@ async function getCodeQLForCmd(
databasePath: string,
outputFilePath: string,
databaseName: string,
includeDiagnostics: boolean,
alsoIncludeRelativePaths: string[],
): Promise<void> {
const includeDiagnosticsArgs = includeDiagnostics
? ["--include-diagnostics"]
: [];
const args = [
"database",
"bundle",
databasePath,
`--output=${outputFilePath}`,
`--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"]),
...includeDiagnosticsArgs,
...getExtraOptionsFromEnv(["database", "bundle"], {
ignoringOptions: includeDiagnosticsArgs,
}),
];
if (
await this.supportsFeature(ToolsFeature.BundleSupportsIncludeOption)

View File

@@ -101,7 +101,9 @@ export async function cleanupAndUploadDatabases(
// Although we are uploading arbitrary file contents to the API, it's worth
// noting that it's the API's job to validate that the contents is acceptable.
// This API method is available to anyone with write access to the repo.
const bundledDb = await bundleDb(config, language, codeql, language);
const bundledDb = await bundleDb(config, language, codeql, language, {
includeDiagnostics: false,
});
bundledDbSize = fs.statSync(bundledDb).size;
const bundledDbReadStream = fs.createReadStream(bundledDb);
const commitOid = await gitUtils.getCommitOid(

View File

@@ -429,6 +429,7 @@ async function createDatabaseBundleCli(
language,
codeql,
`${config.debugDatabaseName}-${language}`,
{ includeDiagnostics: true },
);
return databaseBundlePath;
}

View File

@@ -744,6 +744,7 @@ export async function bundleDb(
language: Language,
codeql: CodeQL,
dbName: string,
{ includeDiagnostics }: { includeDiagnostics: boolean },
) {
const databasePath = getCodeQLDatabasePath(config, language);
const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`);
@@ -774,6 +775,7 @@ export async function bundleDb(
databasePath,
databaseBundlePath,
dbName,
includeDiagnostics,
additionalFiles,
);
return databaseBundlePath;