mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Handle failures in writeTemporaryDiagnosticFile
This commit is contained in:
22
lib/entry-points.js
generated
22
lib/entry-points.js
generated
@@ -173008,10 +173008,10 @@ function addDiagnostic(config, language, diagnostic, logger2 = getActionsLogger(
|
||||
logger2.debug(
|
||||
`Writing a diagnostic for ${language}, but the database at ${databasePath} does not exist yet.`
|
||||
);
|
||||
writeTemporaryDiagnosticFile(config.tempDir, language, diagnostic);
|
||||
writeTemporaryDiagnosticFile(logger2, config.tempDir, language, diagnostic);
|
||||
}
|
||||
}
|
||||
function addNoLanguageDiagnostic(config, diagnostic) {
|
||||
function addNoLanguageDiagnostic(config, diagnostic, logger2 = getActionsLogger()) {
|
||||
if (config !== void 0) {
|
||||
addDiagnostic(
|
||||
config,
|
||||
@@ -173021,17 +173021,29 @@ function addNoLanguageDiagnostic(config, diagnostic) {
|
||||
diagnostic
|
||||
);
|
||||
} else {
|
||||
logger2.debug(
|
||||
`Writing a diagnostic not associated with any language, but we have no configuration to tell us where the database is yet.`
|
||||
);
|
||||
writeTemporaryDiagnosticFile(
|
||||
logger2,
|
||||
getTemporaryDirectory(),
|
||||
void 0,
|
||||
diagnostic
|
||||
);
|
||||
}
|
||||
}
|
||||
function writeTemporaryDiagnosticFile(tempDir, language, diagnostic) {
|
||||
function writeTemporaryDiagnosticFile(logger2, tempDir, language, diagnostic) {
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
try {
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
} catch (err) {
|
||||
logger2.warning(
|
||||
`Unable to write temporary diagnostic to '${tempDiagnosticsPath}': ${getErrorMessage(err)}
|
||||
|
||||
${JSON.stringify(diagnostic)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
function writeDiagnosticFile(diagnosticsPath, diagnostic) {
|
||||
fs7.mkdirSync(diagnosticsPath, { recursive: true });
|
||||
|
||||
@@ -175,7 +175,7 @@ export function addDiagnostic(
|
||||
);
|
||||
|
||||
// Write the diagnostic to a temporary location.
|
||||
writeTemporaryDiagnosticFile(config.tempDir, language, diagnostic);
|
||||
writeTemporaryDiagnosticFile(logger, config.tempDir, language, diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ export function addDiagnostic(
|
||||
export function addNoLanguageDiagnostic(
|
||||
config: Config | undefined,
|
||||
diagnostic: DiagnosticMessage,
|
||||
logger: Logger = getActionsLogger(),
|
||||
) {
|
||||
if (config !== undefined) {
|
||||
addDiagnostic(
|
||||
@@ -193,8 +194,13 @@ export function addNoLanguageDiagnostic(
|
||||
diagnostic,
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
`Writing a diagnostic not associated with any language, but we have no configuration to tell us where the database is yet.`,
|
||||
);
|
||||
|
||||
// Write the diagnostic to a temporary location.
|
||||
writeTemporaryDiagnosticFile(
|
||||
logger,
|
||||
getTemporaryDirectory(),
|
||||
undefined,
|
||||
diagnostic,
|
||||
@@ -207,16 +213,24 @@ export function addNoLanguageDiagnostic(
|
||||
* and tracks it as a diagnostic that was written to a temporary location.
|
||||
*/
|
||||
function writeTemporaryDiagnosticFile(
|
||||
logger: Logger,
|
||||
tempDir: string,
|
||||
language: Language | undefined,
|
||||
diagnostic: DiagnosticMessage,
|
||||
) {
|
||||
// Write the diagnostic to a temporary location.
|
||||
const tempDiagnosticsPath = getTempDiagnosticPath(tempDir, language);
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
|
||||
// Track the temporary file.
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
try {
|
||||
// Write the diagnostic to a temporary location.
|
||||
const diagnosticPath = writeDiagnosticFile(tempDiagnosticsPath, diagnostic);
|
||||
|
||||
// Track the temporary file.
|
||||
temporaryDiagnostics.push({ path: diagnosticPath, language });
|
||||
} catch (err) {
|
||||
logger.warning(
|
||||
`Unable to write temporary diagnostic to '${tempDiagnosticsPath}': ${getErrorMessage(err)}\n\n${JSON.stringify(diagnostic)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user