mirror of
https://github.com/github/codeql-action.git
synced 2025-12-21 14:50:08 +08:00
Address review comments
This commit is contained in:
31
lib/debug-artifacts.js
generated
31
lib/debug-artifacts.js
generated
@@ -99,9 +99,9 @@ exports.uploadLogsDebugArtifact = uploadLogsDebugArtifact;
|
||||
/**
|
||||
* If a database has not been finalized, we cannot run the `codeql database bundle`
|
||||
* command in the CLI because it will return an error. Instead we directly zip
|
||||
* all files in the database folder and upload it as an artifact.
|
||||
* all files in the database folder and return the path.
|
||||
*/
|
||||
async function uploadPartialDatabaseBundle(config, language) {
|
||||
async function createPartialDatabaseBundle(config, language) {
|
||||
const databasePath = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const databaseBundlePath = path.resolve(config.dbLocation, `${config.debugDatabaseName}-${language}-partial.zip`);
|
||||
core.info(`${config.debugDatabaseName}-${language} is not finalized. Uploading partial database bundle at ${databaseBundlePath}...`);
|
||||
@@ -112,21 +112,30 @@ async function uploadPartialDatabaseBundle(config, language) {
|
||||
const zip = new adm_zip_1.default();
|
||||
zip.addLocalFolder(databasePath);
|
||||
zip.writeZip(databaseBundlePath);
|
||||
await uploadDebugArtifacts([databaseBundlePath], config.dbLocation, config.debugArtifactName);
|
||||
return databaseBundlePath;
|
||||
}
|
||||
/**
|
||||
* Runs `codeql database bundle` command and returns the path.
|
||||
*/
|
||||
async function createDatabaseBundleCli(config, language) {
|
||||
// Otherwise run `codeql database bundle` command.
|
||||
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
|
||||
return databaseBundlePath;
|
||||
}
|
||||
async function uploadDatabaseBundleDebugArtifact(config, logger) {
|
||||
for (const language of config.languages) {
|
||||
if (!(0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
await uploadPartialDatabaseBundle(config, language);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// Otherwise run `codeql database bundle` command.
|
||||
const bundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
|
||||
await uploadDebugArtifacts([bundlePath], config.dbLocation, config.debugArtifactName);
|
||||
let databaseBundlePath;
|
||||
if (!(0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
databaseBundlePath = await createPartialDatabaseBundle(config, language);
|
||||
}
|
||||
else {
|
||||
databaseBundlePath = await createDatabaseBundleCli(config, language);
|
||||
}
|
||||
await uploadDebugArtifacts([databaseBundlePath], config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (error) {
|
||||
core.info(`Failed to upload database debug bundles for ${config.debugDatabaseName}-${language}: ${error}`);
|
||||
core.info(`Failed to upload database debug bundle for ${config.debugDatabaseName}-${language}: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user