Fall back to partial database bundle if CLI command fails
This commit is contained in:
parent
80d7a6c8d4
commit
bbd7c801a0
3 changed files with 34 additions and 20 deletions
23
lib/debug-artifacts.js
generated
23
lib/debug-artifacts.js
generated
|
|
@ -87,21 +87,25 @@ function tryGetSarifResultPath(config, language, logger) {
|
|||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to find SARIF results path for ${language}. ${(0, util_1.wrapError)(e).message}`);
|
||||
logger.warning(`Failed to find SARIF results path for ${language}. Reason: ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
async function tryBundleDatabase(config, language, logger) {
|
||||
try {
|
||||
if (!(0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
return [await createPartialDatabaseBundle(config, language)];
|
||||
}
|
||||
else {
|
||||
return [await createDatabaseBundleCli(config, language)];
|
||||
if ((0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
try {
|
||||
return [await createDatabaseBundleCli(config, language)];
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to bundle database for ${language} using the CLI. ` +
|
||||
`Falling back to a partial bundle. Reason: ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
}
|
||||
return [await createPartialDatabaseBundle(config, language)];
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to bundle database for ${language}. ${(0, util_1.wrapError)(e).message}`);
|
||||
logger.warning(`Failed to bundle database for ${language}. Reason: ${(0, util_1.wrapError)(e).message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -127,7 +131,7 @@ async function uploadAllAvailableDebugArtifacts(config, logger) {
|
|||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to upload debug artifacts: ${(0, util_1.wrapError)(e).message}`);
|
||||
logger.warning(`Failed to upload debug artifacts. Reason: ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
}
|
||||
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||
|
|
@ -154,7 +158,7 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
|||
}
|
||||
catch (e) {
|
||||
// A failure to upload debug artifacts should not fail the entire action.
|
||||
core.warning(`Failed to upload debug artifacts: ${e}`);
|
||||
core.warning(`Failed to upload debug artifacts. Reason: ${(0, util_1.wrapError)(e).message}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
@ -179,7 +183,6 @@ async function createPartialDatabaseBundle(config, language) {
|
|||
* 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;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -94,7 +94,7 @@ function tryGetSarifResultPath(
|
|||
}
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to find SARIF results path for ${language}. ${
|
||||
`Failed to find SARIF results path for ${language}. Reason: ${
|
||||
wrapError(e).message
|
||||
}`,
|
||||
);
|
||||
|
|
@ -108,14 +108,22 @@ async function tryBundleDatabase(
|
|||
logger: Logger,
|
||||
): Promise<string[]> {
|
||||
try {
|
||||
if (!dbIsFinalized(config, language, logger)) {
|
||||
return [await createPartialDatabaseBundle(config, language)];
|
||||
} else {
|
||||
return [await createDatabaseBundleCli(config, language)];
|
||||
if (dbIsFinalized(config, language, logger)) {
|
||||
try {
|
||||
return [await createDatabaseBundleCli(config, language)];
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to bundle database for ${language} using the CLI. ` +
|
||||
`Falling back to a partial bundle. Reason: ${wrapError(e).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return [await createPartialDatabaseBundle(config, language)];
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to bundle database for ${language}. ${wrapError(e).message}`,
|
||||
`Failed to bundle database for ${language}. Reason: ${
|
||||
wrapError(e).message
|
||||
}`,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
|
@ -159,7 +167,9 @@ export async function uploadAllAvailableDebugArtifacts(
|
|||
config.debugArtifactName,
|
||||
);
|
||||
} catch (e) {
|
||||
logger.warning(`Failed to upload debug artifacts: ${wrapError(e).message}`);
|
||||
logger.warning(
|
||||
`Failed to upload debug artifacts. Reason: ${wrapError(e).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +209,9 @@ export async function uploadDebugArtifacts(
|
|||
);
|
||||
} catch (e) {
|
||||
// A failure to upload debug artifacts should not fail the entire action.
|
||||
core.warning(`Failed to upload debug artifacts: ${e}`);
|
||||
core.warning(
|
||||
`Failed to upload debug artifacts. Reason: ${wrapError(e).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +249,6 @@ async function createDatabaseBundleCli(
|
|||
config: Config,
|
||||
language: Language,
|
||||
): Promise<string> {
|
||||
// Otherwise run `codeql database bundle` command.
|
||||
const databaseBundlePath = await bundleDb(
|
||||
config,
|
||||
language,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue