Refactoring: Convert ActionName to enum
This commit is contained in:
parent
e12a8cc5eb
commit
c0917251d4
27 changed files with 123 additions and 111 deletions
28
lib/status-report.js
generated
28
lib/status-report.js
generated
|
|
@ -23,13 +23,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.JobStatus = void 0;
|
||||
exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.JobStatus = exports.isFirstPartyAnalysis = exports.ActionName = void 0;
|
||||
const os = __importStar(require("os"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const environment_1 = require("./environment");
|
||||
const util_1 = require("./util");
|
||||
var ActionName;
|
||||
(function (ActionName) {
|
||||
ActionName["Autobuild"] = "autobuild";
|
||||
ActionName["Analyze"] = "finish";
|
||||
ActionName["Init"] = "init";
|
||||
ActionName["InitPost"] = "init-post";
|
||||
ActionName["ResolveEnvironment"] = "resolve-environment";
|
||||
ActionName["UploadSarif"] = "upload-sarif";
|
||||
})(ActionName || (exports.ActionName = ActionName = {}));
|
||||
/**
|
||||
* @returns a boolean indicating whether the analysis is considered to be first party.
|
||||
*
|
||||
* This is based on whether the init action has been used, which is only used for first party analysis.
|
||||
* When a SARIF file has been generated by other means and submitted using the upload action, this is
|
||||
* considered to be a third party analysis and is treated differently when calculating SLOs. To ensure
|
||||
* misconfigured workflows are not treated as third party, only the upload-sarif action can return false.
|
||||
*/
|
||||
function isFirstPartyAnalysis(actionName) {
|
||||
if (actionName !== ActionName.UploadSarif) {
|
||||
return true;
|
||||
}
|
||||
return process.env[environment_1.EnvVar.INIT_ACTION_HAS_RUN] === "true";
|
||||
}
|
||||
exports.isFirstPartyAnalysis = isFirstPartyAnalysis;
|
||||
/** Overall status of the entire job. String values match the Hydro schema. */
|
||||
var JobStatus;
|
||||
(function (JobStatus) {
|
||||
|
|
@ -101,7 +125,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, confi
|
|||
analysis_key,
|
||||
build_mode: config?.buildMode,
|
||||
commit_oid: commitOid,
|
||||
first_party_analysis: (0, actions_util_1.isFirstPartyAnalysis)(actionName),
|
||||
first_party_analysis: isFirstPartyAnalysis(actionName),
|
||||
job_name: jobName,
|
||||
job_run_uuid: jobRunUUID,
|
||||
ref,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue