Merge pull request #959 from cklin/report-runner-os-arch

Add runner OS and arch to status report
This commit is contained in:
Chuan-kai Lin 2022-03-03 14:59:41 -08:00 committed by GitHub
commit 939659ccd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

8
lib/actions-util.js generated
View file

@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
@ -498,6 +499,8 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
workflowStartedAt = actionStartedAt.toISOString();
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
}
const runnerOs = (0, util_1.getRequiredEnvParam)("RUNNER_OS");
const runnerArch = (0, util_1.getRequiredEnvParam)("RUNNER_ARCH");
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
// See https://github.com/actions/runner/issues/803
const actionRef = isRunningLocalAction()
@ -516,6 +519,8 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
started_at: workflowStartedAt,
action_started_at: actionStartedAt.toISOString(),
status,
runner_os: runnerOs,
runner_arch: runnerArch,
};
// Add optional parameters
if (cause) {
@ -534,6 +539,9 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
if (matrix) {
statusReport.matrix_vars = matrix;
}
if (runnerOs === "Windows" || runnerOs === "macOS") {
statusReport.runner_os_release = os.release();
}
return statusReport;
}
exports.createStatusReportBase = createStatusReportBase;

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,5 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as core from "@actions/core";
@ -596,6 +597,12 @@ export interface StatusReportBase {
cause?: string;
/** Stack trace of the failure (or undefined if status is not failure). */
exception?: string;
/** Action runner operating system (context runner.os). */
runner_os: string;
/** Action runner hardware architecture (context runner.arch). */
runner_arch: string;
/** Action runner operating system release (x.y.z from os.release()). */
runner_os_release?: string;
}
export function getActionsStatus(
@ -643,6 +650,9 @@ export async function createStatusReportBase(
workflowStartedAt
);
}
const runnerOs = getRequiredEnvParam("RUNNER_OS");
const runnerArch = getRequiredEnvParam("RUNNER_ARCH");
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
// See https://github.com/actions/runner/issues/803
const actionRef = isRunningLocalAction()
@ -662,6 +672,8 @@ export async function createStatusReportBase(
started_at: workflowStartedAt,
action_started_at: actionStartedAt.toISOString(),
status,
runner_os: runnerOs,
runner_arch: runnerArch,
};
// Add optional parameters
@ -683,6 +695,9 @@ export async function createStatusReportBase(
if (matrix) {
statusReport.matrix_vars = matrix;
}
if (runnerOs === "Windows" || runnerOs === "macOS") {
statusReport.runner_os_release = os.release();
}
return statusReport;
}