Skip to content

Commit 00434f0

Browse files
committed
Include action/post-action suffix in getDisplayActionName
1 parent 64ec5d5 commit 00434f0

4 files changed

Lines changed: 31 additions & 27 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/action-common.test.ts‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ import { getErrorMessage } from "./util";
1919

2020
setupTests(test);
2121

22-
for (const [key, displayName] of Object.entries(
23-
statusReport.ACTION_DISPLAY_NAMES,
24-
)) {
25-
test(`getDisplayActionName - '${displayName}' instead of '${key}'`, (t) => {
22+
const expectedActionDisplayNames: Record<ActionName, string> = {
23+
[ActionName.Analyze]: "analyze action",
24+
[ActionName.AnalyzePost]: "analyze post-action",
25+
[ActionName.Autobuild]: "autobuild action",
26+
[ActionName.Init]: "init action",
27+
[ActionName.InitPost]: "init post-action",
28+
[ActionName.ResolveEnvironment]: "resolve-environment action",
29+
[ActionName.SetupCodeQL]: "setup-codeql action",
30+
[ActionName.StartProxy]: "start-proxy action",
31+
[ActionName.StartProxyPost]: "start-proxy post-action",
32+
[ActionName.UploadSarif]: "upload-sarif action",
33+
[ActionName.UploadSarifPost]: "upload-sarif post-action",
34+
};
35+
36+
for (const [key, displayName] of Object.entries(expectedActionDisplayNames)) {
37+
test(`getDisplayActionName - '${displayName}' for '${key}'`, (t) => {
2638
t.is(statusReport.getDisplayActionName(key as ActionName), displayName);
2739
});
2840
}
2941

30-
test("getDisplayActionName - returns action name", (t) => {
31-
for (const actionName of Object.values(ActionName)) {
32-
if (statusReport.ACTION_DISPLAY_NAMES[actionName]) {
33-
continue;
34-
}
35-
36-
t.is(statusReport.getDisplayActionName(actionName), actionName);
37-
}
38-
});
39-
4042
interface RunInActionsTestOpts {
4143
runFn?: () => Promise<any>;
4244
expectedErrorMessage?: string;
@@ -109,7 +111,7 @@ const runInActionsMacro = makeMacro({
109111
if (expectFailure) {
110112
t.true(
111113
setFailed.calledOnceWithExactly(
112-
`${statusReport.getDisplayActionName(name)} action failed: ${opts?.expectedErrorMessage}`,
114+
`${statusReport.getDisplayActionName(name)} failed: ${opts?.expectedErrorMessage}`,
113115
),
114116
);
115117
t.true(

‎src/action-common.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export async function runInActions(action: Action) {
192192
await action.run(actionState);
193193
} catch (error) {
194194
core.setFailed(
195-
`${getDisplayActionName(action.name)} action failed: ${getErrorMessage(error)}`,
195+
`${getDisplayActionName(action.name)} failed: ${getErrorMessage(error)}`,
196196
);
197197

198198
const statusReportError =

‎src/status-report.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ export enum ActionName {
6767
/** A partial mapping from `ActionName` to names for actions whose display name is not the `ActionName` value. */
6868
export const ACTION_DISPLAY_NAMES: Partial<Record<ActionName, string>> = {
6969
[ActionName.Analyze]: "analyze",
70-
[ActionName.AnalyzePost]: "analyze post-action",
71-
[ActionName.InitPost]: "init post",
72-
[ActionName.StartProxyPost]: "start-proxy post-action",
73-
[ActionName.UploadSarifPost]: "upload-sarif post-action",
70+
[ActionName.AnalyzePost]: "analyze",
71+
[ActionName.InitPost]: "init",
72+
[ActionName.StartProxyPost]: "start-proxy",
73+
[ActionName.UploadSarifPost]: "upload-sarif",
7474
};
7575

7676
/** Decides if {@link name} refers to a post-action. */
@@ -83,9 +83,10 @@ export function isPostAction(name: ActionName) {
8383
* for actions which have a different display name in {@link ACTION_DISPLAY_NAMES}.
8484
*/
8585
export function getDisplayActionName(actionName: ActionName): string {
86+
const suffix = isPostAction(actionName) ? "post-action" : "action";
8687
const displayName = ACTION_DISPLAY_NAMES[actionName];
8788

88-
return displayName ?? actionName;
89+
return `${displayName ?? actionName} ${suffix}`;
8990
}
9091

9192
/**

0 commit comments

Comments
 (0)