From 00434f00f4bbeecbf055fcb3812142038d5fa9a9 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 21 Oct 2026 16:45:27 +0100 Subject: [PATCH] Include `action`/`post-action` suffix in `getDisplayActionName` --- lib/entry-points.js | 13 +++++++------ src/action-common.test.ts | 32 +++++++++++++++++--------------- src/action-common.ts | 2 +- src/status-report.ts | 11 ++++++----- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 9fbf311f2..da54da44e 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -171438,17 +171438,18 @@ function getAddressString(address) { // src/status-report.ts var ACTION_DISPLAY_NAMES = { ["finish" /* Analyze */]: "analyze", - ["analyze-post" /* AnalyzePost */]: "analyze post-action", - ["init-post" /* InitPost */]: "init post", - ["start-proxy-post" /* StartProxyPost */]: "start-proxy post-action", - ["upload-sarif-post" /* UploadSarifPost */]: "upload-sarif post-action" + ["analyze-post" /* AnalyzePost */]: "analyze", + ["init-post" /* InitPost */]: "init", + ["start-proxy-post" /* StartProxyPost */]: "start-proxy", + ["upload-sarif-post" /* UploadSarifPost */]: "upload-sarif" }; function isPostAction(name) { return name.endsWith("-post"); } function getDisplayActionName(actionName) { + const suffix = isPostAction(actionName) ? "post-action" : "action"; const displayName = ACTION_DISPLAY_NAMES[actionName]; - return displayName ?? actionName; + return `${displayName ?? actionName} ${suffix}`; } function getJobUUID(action) { const existingJobRunUuid = action.env.getOptional("CODEQL_ACTION_JOB_RUN_UUID" /* JOB_RUN_UUID */); @@ -171794,7 +171795,7 @@ async function runInActions(action) { await action.run(actionState); } catch (error3) { core9.setFailed( - `${getDisplayActionName(action.name)} action failed: ${getErrorMessage(error3)}` + `${getDisplayActionName(action.name)} failed: ${getErrorMessage(error3)}` ); const statusReportError = action.transformTelemetryError !== void 0 ? action.transformTelemetryError(wrapError(error3)) : error3; await sendUnhandledErrorStatusReport( diff --git a/src/action-common.test.ts b/src/action-common.test.ts index 449300a8d..415eeb682 100644 --- a/src/action-common.test.ts +++ b/src/action-common.test.ts @@ -19,24 +19,26 @@ import { getErrorMessage } from "./util"; setupTests(test); -for (const [key, displayName] of Object.entries( - statusReport.ACTION_DISPLAY_NAMES, -)) { - test(`getDisplayActionName - '${displayName}' instead of '${key}'`, (t) => { +const expectedActionDisplayNames: Record = { + [ActionName.Analyze]: "analyze action", + [ActionName.AnalyzePost]: "analyze post-action", + [ActionName.Autobuild]: "autobuild action", + [ActionName.Init]: "init action", + [ActionName.InitPost]: "init post-action", + [ActionName.ResolveEnvironment]: "resolve-environment action", + [ActionName.SetupCodeQL]: "setup-codeql action", + [ActionName.StartProxy]: "start-proxy action", + [ActionName.StartProxyPost]: "start-proxy post-action", + [ActionName.UploadSarif]: "upload-sarif action", + [ActionName.UploadSarifPost]: "upload-sarif post-action", +}; + +for (const [key, displayName] of Object.entries(expectedActionDisplayNames)) { + test(`getDisplayActionName - '${displayName}' for '${key}'`, (t) => { t.is(statusReport.getDisplayActionName(key as ActionName), displayName); }); } -test("getDisplayActionName - returns action name", (t) => { - for (const actionName of Object.values(ActionName)) { - if (statusReport.ACTION_DISPLAY_NAMES[actionName]) { - continue; - } - - t.is(statusReport.getDisplayActionName(actionName), actionName); - } -}); - interface RunInActionsTestOpts { runFn?: () => Promise; expectedErrorMessage?: string; @@ -109,7 +111,7 @@ const runInActionsMacro = makeMacro({ if (expectFailure) { t.true( setFailed.calledOnceWithExactly( - `${statusReport.getDisplayActionName(name)} action failed: ${opts?.expectedErrorMessage}`, + `${statusReport.getDisplayActionName(name)} failed: ${opts?.expectedErrorMessage}`, ), ); t.true( diff --git a/src/action-common.ts b/src/action-common.ts index e2dc0d199..e62fb9645 100644 --- a/src/action-common.ts +++ b/src/action-common.ts @@ -192,7 +192,7 @@ export async function runInActions(action: Action) { await action.run(actionState); } catch (error) { core.setFailed( - `${getDisplayActionName(action.name)} action failed: ${getErrorMessage(error)}`, + `${getDisplayActionName(action.name)} failed: ${getErrorMessage(error)}`, ); const statusReportError = diff --git a/src/status-report.ts b/src/status-report.ts index 7b13269ed..9d831dd78 100644 --- a/src/status-report.ts +++ b/src/status-report.ts @@ -67,10 +67,10 @@ export enum ActionName { /** A partial mapping from `ActionName` to names for actions whose display name is not the `ActionName` value. */ export const ACTION_DISPLAY_NAMES: Partial> = { [ActionName.Analyze]: "analyze", - [ActionName.AnalyzePost]: "analyze post-action", - [ActionName.InitPost]: "init post", - [ActionName.StartProxyPost]: "start-proxy post-action", - [ActionName.UploadSarifPost]: "upload-sarif post-action", + [ActionName.AnalyzePost]: "analyze", + [ActionName.InitPost]: "init", + [ActionName.StartProxyPost]: "start-proxy", + [ActionName.UploadSarifPost]: "upload-sarif", }; /** Decides if {@link name} refers to a post-action. */ @@ -83,9 +83,10 @@ export function isPostAction(name: ActionName) { * for actions which have a different display name in {@link ACTION_DISPLAY_NAMES}. */ export function getDisplayActionName(actionName: ActionName): string { + const suffix = isPostAction(actionName) ? "post-action" : "action"; const displayName = ACTION_DISPLAY_NAMES[actionName]; - return displayName ?? actionName; + return `${displayName ?? actionName} ${suffix}`; } /**