Skip to content

Commit 772e8e9

Browse files
committed
Use the common entry point for autobuild
1 parent fcd9f6c commit 772e8e9

2 files changed

Lines changed: 41 additions & 56 deletions

File tree

lib/entry-points.js

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

src/autobuild-action.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as core from "@actions/core";
22

3+
import { Action, ActionState, runInActions } from "./action-common";
34
import {
45
getActionVersion,
56
getOptionalInput,
@@ -11,13 +12,12 @@ import { getCodeQL } from "./codeql";
1112
import { Config, getConfig } from "./config-utils";
1213
import { EnvVar } from "./environment";
1314
import { Language } from "./languages";
14-
import { Logger, getActionsLogger } from "./logging";
15+
import { Logger } from "./logging";
1516
import {
1617
StatusReportBase,
1718
getActionsStatus,
1819
createStatusReportBase,
1920
sendStatusReport,
20-
sendUnhandledErrorStatusReport,
2121
ActionName,
2222
} from "./status-report";
2323
import { endTracingForCluster } from "./tracer-config";
@@ -26,7 +26,6 @@ import {
2626
checkDiskUsage,
2727
checkGitHubVersionInRange,
2828
ConfigurationError,
29-
getErrorMessage,
3029
initializeEnvironment,
3130
wrapError,
3231
} from "./util";
@@ -69,11 +68,10 @@ async function sendCompletedStatusReport(
6968
}
7069
}
7170

72-
async function run(startedAt: Date) {
71+
async function run({ startedAt, logger }: ActionState<["Logger"]>) {
7372
// To capture errors appropriately, keep as much code within the try-catch as
7473
// possible, and only use safe functions outside.
7574

76-
const logger = getActionsLogger();
7775
let config: Config | undefined;
7876
let currentLanguage: Language | undefined;
7977
let languages: Language[] | undefined;
@@ -142,18 +140,12 @@ async function run(startedAt: Date) {
142140
await sendCompletedStatusReport(config, logger, startedAt, languages ?? []);
143141
}
144142

143+
/** Defines the `autobuild` Action. */
144+
const autobuild: Action = {
145+
name: ActionName.Autobuild,
146+
run,
147+
};
148+
145149
export async function runWrapper() {
146-
const startedAt = new Date();
147-
const logger = getActionsLogger();
148-
try {
149-
await run(startedAt);
150-
} catch (error) {
151-
core.setFailed(`autobuild action failed. ${getErrorMessage(error)}`);
152-
await sendUnhandledErrorStatusReport(
153-
ActionName.Autobuild,
154-
startedAt,
155-
error,
156-
logger,
157-
);
158-
}
150+
await runInActions(autobuild);
159151
}

0 commit comments

Comments
 (0)