Skip to content

Commit 6ab762c

Browse files
committed
Use the common entry point for setup-codeql
1 parent a3a1cdd commit 6ab762c

2 files changed

Lines changed: 68 additions & 80 deletions

File tree

lib/entry-points.js

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

src/setup-codeql-action.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from "@actions/core";
22
import { v4 as uuidV4 } from "uuid";
33

4+
import { Action, ActionState, runInActions } from "./action-common";
45
import {
56
getActionVersion,
67
getOptionalInput,
@@ -14,7 +15,7 @@ import { getRawLanguagesNoAutodetect } from "./config-utils";
1415
import { EnvVar } from "./environment";
1516
import { initFeatures } from "./feature-flags";
1617
import { initCodeQL } from "./init";
17-
import { getActionsLogger, Logger } from "./logging";
18+
import { Logger } from "./logging";
1819
import { getRepositoryNwo } from "./repository";
1920
import { ToolsSource } from "./setup-codeql";
2021
import {
@@ -24,7 +25,6 @@ import {
2425
createStatusReportBase,
2526
getActionsStatus,
2627
sendStatusReport,
27-
sendUnhandledErrorStatusReport,
2828
} from "./status-report";
2929
import { ToolsDownloadStatusReport } from "./tools-download";
3030
import {
@@ -36,7 +36,6 @@ import {
3636
ConfigurationError,
3737
wrapError,
3838
checkActionVersion,
39-
getErrorMessage,
4039
} from "./util";
4140

4241
/**
@@ -88,12 +87,13 @@ async function sendCompletedStatusReport(
8887
}
8988

9089
/** The main behaviour of this action. */
91-
async function run(startedAt: Date): Promise<void> {
90+
async function run({
91+
startedAt,
92+
logger,
93+
}: ActionState<["Logger"]>): Promise<void> {
9294
// To capture errors appropriately, keep as much code within the try-catch as
9395
// possible, and only use safe functions outside.
9496

95-
const logger = getActionsLogger();
96-
9797
let codeql: CodeQL;
9898
let toolsDownloadStatusReport: ToolsDownloadStatusReport | undefined;
9999
let toolsFeatureFlagsValid: boolean | undefined;
@@ -195,20 +195,14 @@ async function run(startedAt: Date): Promise<void> {
195195
);
196196
}
197197

198+
/** Defines the `setup-codeql` Action. */
199+
const setupCodeQL: Action = {
200+
name: ActionName.SetupCodeQL,
201+
run,
202+
};
203+
198204
/** Run the action and catch any unhandled errors. */
199205
export async function runWrapper(): Promise<void> {
200-
const startedAt = new Date();
201-
const logger = getActionsLogger();
202-
try {
203-
await run(startedAt);
204-
} catch (error) {
205-
core.setFailed(`setup-codeql action failed: ${getErrorMessage(error)}`);
206-
await sendUnhandledErrorStatusReport(
207-
ActionName.SetupCodeQL,
208-
startedAt,
209-
error,
210-
logger,
211-
);
212-
}
206+
await runInActions(setupCodeQL);
213207
await checkForTimeout();
214208
}

0 commit comments

Comments
 (0)