Skip to content

Commit 5fa9c0c

Browse files
committed
Add and use getDisplayActionName for log message
1 parent eba9d55 commit 5fa9c0c

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

lib/entry-points.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/action-common.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import { ActionsEnv, getActionsEnv } from "./actions-util";
44
import { Env } from "./environment";
55
import { FeatureEnablement } from "./feature-flags";
66
import { getActionsLogger, Logger } from "./logging";
7-
import { ActionName, sendUnhandledErrorStatusReport } from "./status-report";
7+
import {
8+
ActionName,
9+
getDisplayActionName,
10+
sendUnhandledErrorStatusReport,
11+
} from "./status-report";
812
import { getEnv, getErrorMessage } from "./util";
913

1014
/** Common state that is always available in `ActionState`. */
@@ -83,7 +87,9 @@ export async function runInActions(action: Action) {
8387
actions: actionsEnv,
8488
});
8589
} catch (error) {
86-
core.setFailed(`${action.name} action failed: ${getErrorMessage(error)}`);
90+
core.setFailed(
91+
`${getDisplayActionName(action.name)} action failed: ${getErrorMessage(error)}`,
92+
);
8793
await sendUnhandledErrorStatusReport(action.name, startedAt, error, logger);
8894
}
8995
}

src/status-report.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ export enum ActionName {
4646
UploadSarif = "upload-sarif",
4747
}
4848

49+
/**
50+
* Maps an `ActionName` to its display name. Usually that is the same, except
51+
* for `ActionName.Analyze` where it is `"analyze"` instead of `"finish"`.
52+
*/
53+
export function getDisplayActionName(actionName: ActionName): string {
54+
if (actionName === ActionName.Analyze) {
55+
return "analyze";
56+
}
57+
return actionName;
58+
}
59+
4960
/**
5061
* @returns a boolean indicating whether the analysis is considered to be first party.
5162
*

0 commit comments

Comments
 (0)