11import * as core from "@actions/core" ;
22import { v4 as uuidV4 } from "uuid" ;
33
4+ import { Action , ActionState , runInActions } from "./action-common" ;
45import {
56 getActionVersion ,
67 getOptionalInput ,
@@ -14,7 +15,7 @@ import { getRawLanguagesNoAutodetect } from "./config-utils";
1415import { EnvVar } from "./environment" ;
1516import { initFeatures } from "./feature-flags" ;
1617import { initCodeQL } from "./init" ;
17- import { getActionsLogger , Logger } from "./logging" ;
18+ import { Logger } from "./logging" ;
1819import { getRepositoryNwo } from "./repository" ;
1920import { ToolsSource } from "./setup-codeql" ;
2021import {
@@ -24,7 +25,6 @@ import {
2425 createStatusReportBase ,
2526 getActionsStatus ,
2627 sendStatusReport ,
27- sendUnhandledErrorStatusReport ,
2828} from "./status-report" ;
2929import { ToolsDownloadStatusReport } from "./tools-download" ;
3030import {
@@ -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. */
199205export 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