Include action/post-action suffix in getDisplayActionName

This commit is contained in:
Michael B. Gale
2026-10-21 16:45:27 +01:00
parent 64ec5d5f67
commit 00434f00f4
4 changed files with 31 additions and 27 deletions

13
lib/entry-points.js generated
View File

@@ -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(

View File

@@ -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, string> = {
[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<any>;
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(

View File

@@ -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 =

View File

@@ -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<Record<ActionName, string>> = {
[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}`;
}
/**