Skip to content

Commit

Permalink
Fall back to partial database bundle if CLI command fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Sep 16, 2024
1 parent 80d7a6c commit bbd7c80
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
23 changes: 13 additions & 10 deletions lib/debug-artifacts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/debug-artifacts.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions src/debug-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}`,
);
Expand All @@ -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 [];
}
Expand Down Expand Up @@ -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}`,
);
}
}

Expand Down Expand Up @@ -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}`,
);
}
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit bbd7c80

Please sign in to comment.