,
+) {
+ const tempDir = actionsUtil.getTemporaryDirectory();
+
+ // Upload Actions SARIF artifacts for debugging when environment variable is set
+ if (process.env["CODEQL_ACTION_DEBUG_COMBINED_SARIF"] === "true") {
+ core.info(
+ "Uploading available combined SARIF files as Actions debugging artifact...",
+ );
+
+ const baseTempDir = path.resolve(tempDir, "combined-sarif");
+
+ const toUpload: string[] = [];
+
+ if (fs.existsSync(baseTempDir)) {
+ const outputDirs = fs.readdirSync(baseTempDir);
+
+ for (const outputDir of outputDirs) {
+ const sarifFiles = fs
+ .readdirSync(path.resolve(baseTempDir, outputDir))
+ .filter((f) => f.endsWith(".sarif"));
+
+ for (const sarifFile of sarifFiles) {
+ toUpload.push(path.resolve(baseTempDir, outputDir, sarifFile));
+ }
+ }
+ }
+
+ if (toUpload.length > 0) {
+ await uploadDebugArtifacts(
+ toUpload,
+ baseTempDir,
+ "upload-debug-artifacts",
+ );
+ }
+ }
+}
diff --git a/src/upload-sarif-action-post.ts b/src/upload-sarif-action-post.ts
new file mode 100644
index 0000000000..6ddee543c6
--- /dev/null
+++ b/src/upload-sarif-action-post.ts
@@ -0,0 +1,24 @@
+/**
+ * This file is the entry point for the `post:` hook of `upload-sarif-action.yml`.
+ * It will run after the all steps in this job, in reverse order in relation to
+ * other `post:` hooks.
+ */
+import * as core from "@actions/core";
+
+import * as debugArtifacts from "./debug-artifacts";
+import * as uploadSarifActionPostHelper from "./upload-sarif-action-post-helper";
+import { wrapError } from "./util";
+
+async function runWrapper() {
+ try {
+ await uploadSarifActionPostHelper.uploadArtifacts(
+ debugArtifacts.uploadDebugArtifacts,
+ );
+ } catch (error) {
+ core.setFailed(
+ `upload-sarif post-action step failed: ${wrapError(error).message}`,
+ );
+ }
+}
+
+void runWrapper();
diff --git a/src/upload-sarif-action.ts b/src/upload-sarif-action.ts
index 71ce81c817..386e583fa2 100644
--- a/src/upload-sarif-action.ts
+++ b/src/upload-sarif-action.ts
@@ -41,11 +41,13 @@ async function sendSuccessStatusReport(
await checkDiskUsage(),
logger,
);
- const statusReport: UploadSarifStatusReport = {
- ...statusReportBase,
- ...uploadStats,
- };
- await sendStatusReport(statusReport);
+ if (statusReportBase !== undefined) {
+ const statusReport: UploadSarifStatusReport = {
+ ...statusReportBase,
+ ...uploadStats,
+ };
+ await sendStatusReport(statusReport);
+ }
}
async function run() {
@@ -56,16 +58,17 @@ async function run() {
const gitHubVersion = await getGitHubVersion();
checkActionVersion(getActionVersion(), gitHubVersion);
- await sendStatusReport(
- await createStatusReportBase(
- ActionName.UploadSarif,
- "starting",
- startedAt,
- undefined,
- await checkDiskUsage(),
- logger,
- ),
+ const startingStatusReportBase = await createStatusReportBase(
+ ActionName.UploadSarif,
+ "starting",
+ startedAt,
+ undefined,
+ await checkDiskUsage(),
+ logger,
);
+ if (startingStatusReportBase !== undefined) {
+ await sendStatusReport(startingStatusReportBase);
+ }
try {
const uploadResult = await upload_lib.uploadFromActions(
@@ -96,18 +99,20 @@ async function run() {
const message = error.message;
core.setFailed(message);
console.log(error);
- await sendStatusReport(
- await createStatusReportBase(
- ActionName.UploadSarif,
- getActionsStatus(error),
- startedAt,
- undefined,
- await checkDiskUsage(),
- logger,
- message,
- error.stack,
- ),
+
+ const errorStatusReportBase = await createStatusReportBase(
+ ActionName.UploadSarif,
+ getActionsStatus(error),
+ startedAt,
+ undefined,
+ await checkDiskUsage(),
+ logger,
+ message,
+ error.stack,
);
+ if (errorStatusReportBase !== undefined) {
+ await sendStatusReport(errorStatusReportBase);
+ }
return;
}
}
diff --git a/upload-sarif/action.yml b/upload-sarif/action.yml
index cf7ce68a4e..a6b74bbfc0 100644
--- a/upload-sarif/action.yml
+++ b/upload-sarif/action.yml
@@ -38,3 +38,4 @@ outputs:
runs:
using: node20
main: '../lib/upload-sarif-action.js'
+ post: '../lib/upload-sarif-action-post.js'
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy