Add event name to status report
This commit is contained in:
parent
e4a536270d
commit
60465730fb
24 changed files with 83 additions and 38 deletions
|
|
@ -69,6 +69,7 @@ async function sendStatusReport(
|
|||
startedAt,
|
||||
config,
|
||||
await util.checkDiskUsage(),
|
||||
logger,
|
||||
error?.message,
|
||||
error?.stack,
|
||||
);
|
||||
|
|
@ -195,6 +196,7 @@ async function run() {
|
|||
startedAt,
|
||||
undefined,
|
||||
await util.checkDiskUsage(logger),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ async function sendCompletedStatusReport(
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
cause?.message,
|
||||
cause?.stack,
|
||||
);
|
||||
|
|
@ -75,6 +76,7 @@ async function run() {
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ interface InitPostStatusReport
|
|||
initActionPostHelper.JobStatusReport {}
|
||||
|
||||
async function runWrapper() {
|
||||
const logger = getActionsLogger();
|
||||
const startedAt = new Date();
|
||||
let config: Config | undefined;
|
||||
let uploadFailedSarifResult:
|
||||
| initActionPostHelper.UploadFailedSarifResult
|
||||
| undefined;
|
||||
try {
|
||||
const logger = getActionsLogger();
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
|
||||
|
|
@ -81,6 +81,7 @@ async function runWrapper() {
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
error.message,
|
||||
error.stack,
|
||||
),
|
||||
|
|
@ -93,6 +94,7 @@ async function runWrapper() {
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
);
|
||||
const statusReport: InitPostStatusReport = {
|
||||
...statusReportBase,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ async function sendCompletedStatusReport(
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
error?.message,
|
||||
error?.stack,
|
||||
);
|
||||
|
|
@ -232,6 +233,7 @@ async function run() {
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -315,6 +317,7 @@ async function run() {
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
error.message,
|
||||
error.stack,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ async function run() {
|
|||
"starting",
|
||||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(logger),
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -86,6 +87,7 @@ async function run() {
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
error.message,
|
||||
error.stack,
|
||||
),
|
||||
|
|
@ -102,6 +104,7 @@ async function run() {
|
|||
startedAt,
|
||||
config,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import * as actionsUtil from "./actions-util";
|
|||
import { BuildMode } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { createStatusReportBase } from "./status-report";
|
||||
import {
|
||||
setupTests,
|
||||
|
|
@ -19,6 +20,7 @@ function setupEnvironmentAndStub(tmpDir: string) {
|
|||
setupActionsVars(tmpDir, tmpDir);
|
||||
|
||||
process.env["CODEQL_ACTION_ANALYSIS_KEY"] = "analysis-key";
|
||||
process.env["GITHUB_EVENT_NAME"] = "dynamic";
|
||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
||||
process.env["GITHUB_REPOSITORY"] = "octocat/HelloWorld";
|
||||
process.env["GITHUB_RUN_ATTEMPT"] = "2";
|
||||
|
|
@ -45,6 +47,7 @@ test("createStatusReportBase", async (t) => {
|
|||
languages: [Language.java, Language.swift],
|
||||
}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
);
|
||||
|
|
@ -56,6 +59,7 @@ test("createStatusReportBase", async (t) => {
|
|||
statusReport.action_started_at,
|
||||
new Date("May 19, 2023 05:19:00").toISOString(),
|
||||
);
|
||||
t.is(statusReport.actions_event_name, "dynamic");
|
||||
t.is(statusReport.analysis_key, "analysis-key");
|
||||
t.is(statusReport.build_mode, BuildMode.None);
|
||||
t.is(statusReport.cause, "failure cause");
|
||||
|
|
@ -88,6 +92,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
@ -103,6 +108,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
@ -119,6 +125,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
@ -134,6 +141,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
@ -150,6 +158,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
@ -165,6 +174,7 @@ test("createStatusReportBase_firstParty", async (t) => {
|
|||
new Date("May 19, 2023 05:19:00"),
|
||||
createTestConfig({}),
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
import { getAnalysisKey, getApiClient } from "./api-client";
|
||||
import { BuildMode, Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Logger } from "./logging";
|
||||
import {
|
||||
ConfigurationError,
|
||||
isHTTPError,
|
||||
|
|
@ -52,6 +53,8 @@ export interface StatusReportBase {
|
|||
action_started_at: string;
|
||||
/** Action version (x.y.z from package.json). */
|
||||
action_version: string;
|
||||
/** The name of the Actions event that triggered the workflow. */
|
||||
actions_event_name?: string;
|
||||
/** Analysis key, normally composed from the workflow path and job name. */
|
||||
analysis_key: string;
|
||||
/** Build mode, if specified. */
|
||||
|
|
@ -199,6 +202,7 @@ export async function createStatusReportBase(
|
|||
actionStartedAt: Date,
|
||||
config: Config | undefined,
|
||||
diskInfo: DiskUsage | undefined,
|
||||
logger: Logger,
|
||||
cause?: string,
|
||||
exception?: string,
|
||||
): Promise<StatusReportBase> {
|
||||
|
|
@ -247,6 +251,12 @@ export async function createStatusReportBase(
|
|||
workflow_run_id: workflowRunID,
|
||||
};
|
||||
|
||||
try {
|
||||
statusReport.actions_event_name = getWorkflowEventName();
|
||||
} catch (e) {
|
||||
logger.warning(`Could not determine the workflow event name: ${e}.`);
|
||||
}
|
||||
|
||||
if (config) {
|
||||
statusReport.languages = config.languages.join(" ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import * as core from "@actions/core";
|
|||
import * as actionsUtil from "./actions-util";
|
||||
import { getActionVersion } from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { Logger, getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import {
|
||||
createStatusReportBase,
|
||||
|
|
@ -28,6 +28,7 @@ interface UploadSarifStatusReport
|
|||
async function sendSuccessStatusReport(
|
||||
startedAt: Date,
|
||||
uploadStats: upload_lib.UploadStatusReport,
|
||||
logger: Logger,
|
||||
) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"upload-sarif",
|
||||
|
|
@ -35,6 +36,7 @@ async function sendSuccessStatusReport(
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
);
|
||||
const statusReport: UploadSarifStatusReport = {
|
||||
...statusReportBase,
|
||||
|
|
@ -58,6 +60,7 @@ async function run() {
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
),
|
||||
);
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ async function run() {
|
|||
logger,
|
||||
);
|
||||
}
|
||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport, logger);
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
const message = error.message;
|
||||
|
|
@ -94,6 +97,7 @@ async function run() {
|
|||
startedAt,
|
||||
undefined,
|
||||
await checkDiskUsage(),
|
||||
logger,
|
||||
message,
|
||||
error.stack,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue