Upload debug artifacts for upload-sarif
This commit is contained in:
parent
7e30c622b0
commit
2bbafcdd7f
7 changed files with 173 additions and 0 deletions
55
lib/upload-sarif-action-post-helper.js
generated
Normal file
55
lib/upload-sarif-action-post-helper.js
generated
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.run = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
async function run(uploadDebugArtifacts) {
|
||||
const tempDir = actionsUtil.getTemporaryDirectory();
|
||||
// Upload Actions SARIF artifacts for debugging
|
||||
if (core.isDebug()) {
|
||||
core.info("Debug mode is on. Uploading available combined SARIF files as Actions debugging artifact...");
|
||||
const baseTempDir = path.resolve(tempDir, "combined-sarif");
|
||||
const toUpload = [];
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.run = run;
|
||||
//# sourceMappingURL=upload-sarif-action-post-helper.js.map
|
||||
1
lib/upload-sarif-action-post-helper.js.map
Normal file
1
lib/upload-sarif-action-post-helper.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"upload-sarif-action-post-helper.js","sourceRoot":"","sources":["../src/upload-sarif-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAsC;AAEtC,4DAA8C;AAEvC,KAAK,UAAU,GAAG,CACvB,oBAIkB;IAElB,MAAM,OAAO,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC;IAEpD,+CAA+C;IAC/C,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,CACP,6FAA6F,CAC9F,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAE5D,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAE/C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,MAAM,UAAU,GAAG,EAAE;qBAClB,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;qBACjD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAEvC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;oBACnC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,oBAAoB,CACxB,QAAQ,EACR,WAAW,EACX,wBAAwB,CACzB,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAzCD,kBAyCC"}
|
||||
44
lib/upload-sarif-action-post.js
generated
Normal file
44
lib/upload-sarif-action-post.js
generated
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||
const uploadSarifActionPostHelper = __importStar(require("./upload-sarif-action-post-helper"));
|
||||
const util_1 = require("./util");
|
||||
async function runWrapper() {
|
||||
try {
|
||||
await uploadSarifActionPostHelper.run(debugArtifacts.uploadDebugArtifacts);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`upload-sarif post-action step failed: ${(0, util_1.wrapError)(error).message}`);
|
||||
}
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=upload-sarif-action-post.js.map
|
||||
1
lib/upload-sarif-action-post.js.map
Normal file
1
lib/upload-sarif-action-post.js.map
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"upload-sarif-action-post.js","sourceRoot":"","sources":["../src/upload-sarif-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,kEAAoD;AACpD,+FAAiF;AACjF,iCAAmC;AAEnC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,2BAA2B,CAAC,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;IAC7E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,yCAAyC,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CACpE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
49
src/upload-sarif-action-post-helper.ts
Normal file
49
src/upload-sarif-action-post-helper.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
|
||||
export async function run(
|
||||
uploadDebugArtifacts: (
|
||||
toUpload: string[],
|
||||
rootDir: string,
|
||||
artifactName: string,
|
||||
) => Promise<void>,
|
||||
) {
|
||||
const tempDir = actionsUtil.getTemporaryDirectory();
|
||||
|
||||
// Upload Actions SARIF artifacts for debugging
|
||||
if (core.isDebug()) {
|
||||
core.info(
|
||||
"Debug mode is on. 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",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/upload-sarif-action-post.ts
Normal file
22
src/upload-sarif-action-post.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* 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.run(debugArtifacts.uploadDebugArtifacts);
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
`upload-sarif post-action step failed: ${wrapError(error).message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void runWrapper();
|
||||
|
|
@ -38,3 +38,4 @@ outputs:
|
|||
runs:
|
||||
using: node20
|
||||
main: '../lib/upload-sarif-action.js'
|
||||
post: '../lib/upload-sarif-action-post.js'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue