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) {
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
async function tryBundleDatabase(config, language, logger) {
|
async function tryBundleDatabase(config, language, logger) {
|
||||||
try {
|
try {
|
||||||
if (!(0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
if ((0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||||
return [await createPartialDatabaseBundle(config, language)];
|
try {
|
||||||
}
|
return [await createDatabaseBundleCli(config, language)];
|
||||||
else {
|
}
|
||||||
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) {
|
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 [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +131,7 @@ async function uploadAllAvailableDebugArtifacts(config, logger) {
|
||||||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||||
}
|
}
|
||||||
catch (e) {
|
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) {
|
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||||
|
|
@ -154,7 +158,7 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// A failure to upload debug artifacts should not fail the entire action.
|
// 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.
|
* Runs `codeql database bundle` command and returns the path.
|
||||||
*/
|
*/
|
||||||
async function createDatabaseBundleCli(config, language) {
|
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}`);
|
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
|
||||||
return databaseBundlePath;
|
return databaseBundlePath;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -94,7 +94,7 @@ function tryGetSarifResultPath(
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
`Failed to find SARIF results path for ${language}. ${
|
`Failed to find SARIF results path for ${language}. Reason: ${
|
||||||
wrapError(e).message
|
wrapError(e).message
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
|
|
@ -108,14 +108,22 @@ async function tryBundleDatabase(
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
try {
|
try {
|
||||||
if (!dbIsFinalized(config, language, logger)) {
|
if (dbIsFinalized(config, language, logger)) {
|
||||||
return [await createPartialDatabaseBundle(config, language)];
|
try {
|
||||||
} else {
|
return [await createDatabaseBundleCli(config, language)];
|
||||||
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) {
|
} catch (e) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
`Failed to bundle database for ${language}. ${wrapError(e).message}`,
|
`Failed to bundle database for ${language}. Reason: ${
|
||||||
|
wrapError(e).message
|
||||||
|
}`,
|
||||||
);
|
);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +167,9 @@ export async function uploadAllAvailableDebugArtifacts(
|
||||||
config.debugArtifactName,
|
config.debugArtifactName,
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} 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) {
|
} catch (e) {
|
||||||
// A failure to upload debug artifacts should not fail the entire action.
|
// 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,
|
config: Config,
|
||||||
language: Language,
|
language: Language,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// Otherwise run `codeql database bundle` command.
|
|
||||||
const databaseBundlePath = await bundleDb(
|
const databaseBundlePath = await bundleDb(
|
||||||
config,
|
config,
|
||||||
language,
|
language,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue