Improve logging for debug artifacts
This commit is contained in:
parent
78d398ebc6
commit
d0a3cf2152
6 changed files with 94 additions and 50 deletions
51
lib/debug-artifacts.js
generated
51
lib/debug-artifacts.js
generated
|
|
@ -40,6 +40,7 @@ const actions_util_1 = require("./actions-util");
|
|||
const analyze_1 = require("./analyze");
|
||||
const codeql_1 = require("./codeql");
|
||||
const environment_1 = require("./environment");
|
||||
const logging_1 = require("./logging");
|
||||
const util_1 = require("./util");
|
||||
function sanitizeArtifactName(name) {
|
||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||
|
|
@ -128,27 +129,37 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) {
|
|||
try {
|
||||
const filesToUpload = [];
|
||||
for (const language of config.languages) {
|
||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger);
|
||||
if (sarifResultDebugArtifact) {
|
||||
filesToUpload.push(sarifResultDebugArtifact);
|
||||
}
|
||||
// Add any log files
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
||||
}
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
||||
}
|
||||
// Add database bundle
|
||||
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
||||
if (databaseBundle) {
|
||||
filesToUpload.push(databaseBundle);
|
||||
}
|
||||
await (0, logging_1.withGroup)(`Uploading debug artifacts for ${language}`, async () => {
|
||||
logger.info("Preparing SARIF result debug artifact...");
|
||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger);
|
||||
if (sarifResultDebugArtifact) {
|
||||
filesToUpload.push(sarifResultDebugArtifact);
|
||||
logger.info("SARIF result debug artifact ready for upload.");
|
||||
}
|
||||
logger.info("Preparing database logs debug artifact...");
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(logsDirectory));
|
||||
logger.info("Database logs debug artifact ready for upload.");
|
||||
}
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
logger.info("Preparing database cluster logs debug artifact...");
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
||||
logger.info("Database cluster logs debug artifact ready for upload.");
|
||||
}
|
||||
// Add database bundle
|
||||
logger.info("Preparing database bundle debug artifact...");
|
||||
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
||||
if (databaseBundle) {
|
||||
filesToUpload.push(databaseBundle);
|
||||
logger.info("Database bundle debug artifact ready for upload.");
|
||||
}
|
||||
});
|
||||
}
|
||||
logger.info("Uploading debug artifacts...");
|
||||
await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
10
lib/logging.js
generated
10
lib/logging.js
generated
|
|
@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getActionsLogger = getActionsLogger;
|
||||
exports.getRunnerLogger = getRunnerLogger;
|
||||
exports.withGroup = withGroup;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
function getActionsLogger() {
|
||||
return core;
|
||||
|
|
@ -44,4 +45,13 @@ function getRunnerLogger(debugMode) {
|
|||
endGroup: () => undefined,
|
||||
};
|
||||
}
|
||||
function withGroup(groupName, f) {
|
||||
core.startGroup(groupName);
|
||||
try {
|
||||
return f();
|
||||
}
|
||||
finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=logging.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAhCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC"}
|
||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAED,8BAOC;AAzCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED,SAAgB,SAAS,CAAI,SAAiB,EAAE,CAAU;IACxD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,CAAC,EAAE,CAAC;IACb,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"}
|
||||
|
|
@ -12,7 +12,7 @@ import { getCodeQL } from "./codeql";
|
|||
import { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { Logger, withGroup } from "./logging";
|
||||
import {
|
||||
bundleDb,
|
||||
doesDirectoryExist,
|
||||
|
|
@ -152,38 +152,52 @@ export async function tryUploadAllAvailableDebugArtifacts(
|
|||
const filesToUpload: string[] = [];
|
||||
|
||||
for (const language of config.languages) {
|
||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(
|
||||
config,
|
||||
language,
|
||||
logger,
|
||||
);
|
||||
if (sarifResultDebugArtifact) {
|
||||
filesToUpload.push(sarifResultDebugArtifact);
|
||||
}
|
||||
await withGroup(`Uploading debug artifacts for ${language}`, async () => {
|
||||
logger.info("Preparing SARIF result debug artifact...");
|
||||
const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(
|
||||
config,
|
||||
language,
|
||||
logger,
|
||||
);
|
||||
if (sarifResultDebugArtifact) {
|
||||
filesToUpload.push(sarifResultDebugArtifact);
|
||||
logger.info("SARIF result debug artifact ready for upload.");
|
||||
}
|
||||
|
||||
// Add any log files
|
||||
const databaseDirectory = getCodeQLDatabasePath(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if (doesDirectoryExist(logsDirectory)) {
|
||||
filesToUpload.push(...listFolder(logsDirectory));
|
||||
}
|
||||
logger.info("Preparing database logs debug artifact...");
|
||||
const databaseDirectory = getCodeQLDatabasePath(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if (doesDirectoryExist(logsDirectory)) {
|
||||
filesToUpload.push(...listFolder(logsDirectory));
|
||||
logger.info("Database logs debug artifact ready for upload.");
|
||||
}
|
||||
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(
|
||||
config.dbLocation,
|
||||
"log",
|
||||
);
|
||||
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
|
||||
}
|
||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||
logger.info("Preparing database cluster logs debug artifact...");
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(
|
||||
config.dbLocation,
|
||||
"log",
|
||||
);
|
||||
if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) {
|
||||
filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory));
|
||||
logger.info("Database cluster logs debug artifact ready for upload.");
|
||||
}
|
||||
|
||||
// Add database bundle
|
||||
const databaseBundle = await tryBundleDatabase(config, language, logger);
|
||||
if (databaseBundle) {
|
||||
filesToUpload.push(databaseBundle);
|
||||
}
|
||||
// Add database bundle
|
||||
logger.info("Preparing database bundle debug artifact...");
|
||||
const databaseBundle = await tryBundleDatabase(
|
||||
config,
|
||||
language,
|
||||
logger,
|
||||
);
|
||||
if (databaseBundle) {
|
||||
filesToUpload.push(databaseBundle);
|
||||
logger.info("Database bundle debug artifact ready for upload.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
logger.info("Uploading debug artifacts...");
|
||||
await uploadDebugArtifacts(
|
||||
filesToUpload,
|
||||
config.dbLocation,
|
||||
|
|
|
|||
|
|
@ -31,3 +31,12 @@ export function getRunnerLogger(debugMode: boolean): Logger {
|
|||
endGroup: () => undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function withGroup<T>(groupName: string, f: () => T): T {
|
||||
core.startGroup(groupName);
|
||||
try {
|
||||
return f();
|
||||
} finally {
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue