Record the stack trace if applicable
This commit is contained in:
parent
dc9c1c1a51
commit
118e294bb9
3 changed files with 90 additions and 54 deletions
33
lib/init-action-post-helper.js
generated
33
lib/init-action-post-helper.js
generated
|
|
@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.run = exports.uploadFailedSarif = void 0;
|
||||
exports.run = exports.uploadSarifIfRunFailed = exports.uploadFailedSarif = void 0;
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const codeql_1 = require("./codeql");
|
||||
|
|
@ -29,6 +29,12 @@ const shared_environment_1 = require("./shared-environment");
|
|||
const uploadLib = __importStar(require("./upload-lib"));
|
||||
const util_1 = require("./util");
|
||||
const workflow_1 = require("./workflow");
|
||||
function createFailedUploadFailedSarifResult(error) {
|
||||
return {
|
||||
upload_failed_run_error: error instanceof Error ? error.message : String(error),
|
||||
upload_failed_run_stack_trace: error instanceof Error ? error.stack : undefined,
|
||||
};
|
||||
}
|
||||
async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logger) {
|
||||
var _a, _b;
|
||||
if (!config.codeQLCmd) {
|
||||
|
|
@ -61,18 +67,12 @@ async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logge
|
|||
};
|
||||
}
|
||||
exports.uploadFailedSarif = uploadFailedSarif;
|
||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||
return;
|
||||
}
|
||||
async function uploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger) {
|
||||
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||
const expectFailedSarifUpload = process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||
let uploadFailedSarifResult;
|
||||
if (process.env[shared_environment_1.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||
try {
|
||||
uploadFailedSarifResult = await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||
return await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||
}
|
||||
catch (e) {
|
||||
if (expectFailedSarifUpload) {
|
||||
|
|
@ -80,19 +80,26 @@ async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, p
|
|||
`the following error: ${e}`);
|
||||
}
|
||||
logger.info(`Failed to upload a SARIF file for the failed run. Error: ${e}`);
|
||||
uploadFailedSarifResult = {
|
||||
upload_failed_run_error: e instanceof Error ? e.message : String(e),
|
||||
};
|
||||
return createFailedUploadFailedSarifResult(e);
|
||||
}
|
||||
}
|
||||
else if (expectFailedSarifUpload) {
|
||||
throw new Error("Expected to upload a SARIF file for the failed run, but didn't.");
|
||||
}
|
||||
else {
|
||||
uploadFailedSarifResult = {
|
||||
return {
|
||||
upload_failed_run_skipped_because: "SARIF file already uploaded",
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.uploadSarifIfRunFailed = uploadSarifIfRunFailed;
|
||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||
return;
|
||||
}
|
||||
const uploadFailedSarifResult = await uploadSarifIfRunFailed(config, repositoryNwo, featureEnablement, logger);
|
||||
// Upload appropriate Actions artifacts for debugging
|
||||
if (config.debugMode) {
|
||||
core.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue