Skip to content

Commit 6136b93

Browse files
committed
Use the common entry point for init
1 parent 6ab762c commit 6136b93

1 file changed

Lines changed: 12 additions & 19 deletions

File tree

src/init-action.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import * as io from "@actions/io";
77
import * as semver from "semver";
88
import { v4 as uuidV4 } from "uuid";
99

10+
import { Action, ActionState, runInActions } from "./action-common";
1011
import {
1112
FileCmdNotFoundError,
12-
getActionsEnv,
1313
getActionVersion,
1414
getFileType,
1515
getOptionalInput,
@@ -56,7 +56,7 @@ import {
5656
runDatabaseInitCluster,
5757
} from "./init";
5858
import { JavaEnvVars, BuiltInLanguage } from "./languages";
59-
import { getActionsLogger, Logger, withGroupAsync } from "./logging";
59+
import { Logger, withGroupAsync } from "./logging";
6060
import {
6161
downloadOverlayBaseDatabaseFromCache,
6262
OverlayBaseDatabaseDownloadStats,
@@ -73,7 +73,6 @@ import {
7373
createStatusReportBase,
7474
getActionsStatus,
7575
sendStatusReport,
76-
sendUnhandledErrorStatusReport,
7776
} from "./status-report";
7877
import { ZstdAvailability } from "./tar";
7978
import { ToolsDownloadStatusReport } from "./tools-download";
@@ -204,12 +203,12 @@ async function sendCompletedStatusReport(
204203
}
205204
}
206205

207-
async function run(startedAt: Date) {
206+
async function run(actionState: ActionState<["Logger", "Actions"]>) {
208207
// To capture errors appropriately, keep as much code within the try-catch as
209208
// possible, and only use safe functions outside.
210209

211-
const logger = getActionsLogger();
212-
const actionsEnv = getActionsEnv();
210+
const startedAt = actionState.startedAt;
211+
const logger = actionState.logger;
213212

214213
let apiDetails: GitHubApiCombinedDetails;
215214
let config: configUtils.Config | undefined;
@@ -854,19 +853,13 @@ async function recordZstdAvailability(
854853
);
855854
}
856855

856+
/** Defines the `init` Action. */
857+
const init: Action = {
858+
name: ActionName.Init,
859+
run,
860+
};
861+
857862
export async function runWrapper() {
858-
const startedAt = new Date();
859-
const logger = getActionsLogger();
860-
try {
861-
await run(startedAt);
862-
} catch (error) {
863-
core.setFailed(`init action failed: ${getErrorMessage(error)}`);
864-
await sendUnhandledErrorStatusReport(
865-
ActionName.Init,
866-
startedAt,
867-
error,
868-
logger,
869-
);
870-
}
863+
await runInActions(init);
871864
await checkForTimeout();
872865
}

0 commit comments

Comments
 (0)