mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Use runInActions for the resolve-environment action
This commit is contained in:
52
lib/entry-points.js
generated
52
lib/entry-points.js
generated
@@ -21649,7 +21649,7 @@ var require_core = __commonJS({
|
||||
exports2.getBooleanInput = getBooleanInput;
|
||||
exports2.setOutput = setOutput7;
|
||||
exports2.setCommandEcho = setCommandEcho;
|
||||
exports2.setFailed = setFailed10;
|
||||
exports2.setFailed = setFailed9;
|
||||
exports2.isDebug = isDebug4;
|
||||
exports2.debug = debug6;
|
||||
exports2.error = error3;
|
||||
@@ -21733,7 +21733,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||||
function setCommandEcho(enabled) {
|
||||
(0, command_1.issue)("echo", enabled ? "on" : "off");
|
||||
}
|
||||
function setFailed10(message) {
|
||||
function setFailed9(message) {
|
||||
process.exitCode = ExitCode.Failure;
|
||||
error3(message);
|
||||
}
|
||||
@@ -145643,11 +145643,11 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||||
(0, command_1.issue)("echo", enabled ? "on" : "off");
|
||||
}
|
||||
exports2.setCommandEcho = setCommandEcho;
|
||||
function setFailed10(message) {
|
||||
function setFailed9(message) {
|
||||
process.exitCode = ExitCode.Failure;
|
||||
error3(message);
|
||||
}
|
||||
exports2.setFailed = setFailed10;
|
||||
exports2.setFailed = setFailed9;
|
||||
function isDebug4() {
|
||||
return process.env["RUNNER_DEBUG"] === "1";
|
||||
}
|
||||
@@ -187378,14 +187378,14 @@ async function runResolveBuildEnvironment(cmd, logger2, workingDir, language) {
|
||||
|
||||
// src/resolve-environment-action.ts
|
||||
var ENVIRONMENT_OUTPUT_NAME = "environment";
|
||||
async function run6(startedAt) {
|
||||
const logger2 = getActionsLogger();
|
||||
async function run6(action) {
|
||||
const logger2 = action.logger;
|
||||
let config;
|
||||
try {
|
||||
const statusReportBase2 = await createStatusReportBase(
|
||||
"resolve-environment" /* ResolveEnvironment */,
|
||||
action.name,
|
||||
"starting",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger2),
|
||||
logger2
|
||||
@@ -187402,12 +187402,12 @@ async function run6(startedAt) {
|
||||
"Config file could not be found at expected location. Has the 'init' action been called?"
|
||||
);
|
||||
}
|
||||
const workingDirectory = getOptionalInput("working-directory");
|
||||
const workingDirectory = action.actions.getOptionalInput("working-directory");
|
||||
const result = await runResolveBuildEnvironment(
|
||||
config.codeQLCmd,
|
||||
logger2,
|
||||
workingDirectory,
|
||||
getRequiredInput("language")
|
||||
action.actions.getRequiredInput("language")
|
||||
);
|
||||
core19.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
|
||||
} catch (unwrappedError) {
|
||||
@@ -187418,13 +187418,13 @@ async function run6(startedAt) {
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error3.message}`
|
||||
);
|
||||
} else {
|
||||
core19.setFailed(
|
||||
action.actions.setFailed(
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error3.message}`
|
||||
);
|
||||
const statusReportBase2 = await createStatusReportBase(
|
||||
"resolve-environment" /* ResolveEnvironment */,
|
||||
action.name,
|
||||
getActionsStatus(error3),
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger2),
|
||||
logger2,
|
||||
@@ -187438,9 +187438,9 @@ async function run6(startedAt) {
|
||||
return;
|
||||
}
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"resolve-environment" /* ResolveEnvironment */,
|
||||
action.name,
|
||||
"success",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger2),
|
||||
logger2
|
||||
@@ -187449,24 +187449,12 @@ async function run6(startedAt) {
|
||||
await sendStatusReport(statusReportBase);
|
||||
}
|
||||
}
|
||||
var resolveEnvironmentAction = {
|
||||
name: "resolve-environment" /* ResolveEnvironment */,
|
||||
run: run6
|
||||
};
|
||||
async function runWrapper6() {
|
||||
const startedAt = /* @__PURE__ */ new Date();
|
||||
const logger2 = getActionsLogger();
|
||||
try {
|
||||
await run6(startedAt);
|
||||
} catch (error3) {
|
||||
core19.setFailed(
|
||||
`${"resolve-environment" /* ResolveEnvironment */} action failed: ${getErrorMessage(
|
||||
error3
|
||||
)}`
|
||||
);
|
||||
await sendUnhandledErrorStatusReport(
|
||||
"resolve-environment" /* ResolveEnvironment */,
|
||||
startedAt,
|
||||
error3,
|
||||
logger2
|
||||
);
|
||||
}
|
||||
await runInActions(resolveEnvironmentAction);
|
||||
await checkForTimeout();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import {
|
||||
getActionVersion,
|
||||
getOptionalInput,
|
||||
getRequiredInput,
|
||||
getTemporaryDirectory,
|
||||
} from "./actions-util";
|
||||
import { runInActions, type Action, type ActionState } from "./action-common";
|
||||
import { getActionVersion, getTemporaryDirectory } from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CliError } from "./cli-errors";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { runResolveBuildEnvironment } from "./resolve-environment";
|
||||
import {
|
||||
sendStatusReport,
|
||||
sendUnhandledErrorStatusReport,
|
||||
createStatusReportBase,
|
||||
getActionsStatus,
|
||||
ActionName,
|
||||
@@ -24,25 +18,28 @@ import {
|
||||
checkForTimeout,
|
||||
checkGitHubVersionInRange,
|
||||
ConfigurationError,
|
||||
getErrorMessage,
|
||||
wrapError,
|
||||
} from "./util";
|
||||
|
||||
const ENVIRONMENT_OUTPUT_NAME = "environment";
|
||||
|
||||
async function run(startedAt: Date) {
|
||||
/**
|
||||
* The main functionality of the `resolve-environment` action is implemented by this function.
|
||||
* This is called once by {@link runInActions} after it is called in {@link runWrapper}.
|
||||
*/
|
||||
async function run(action: ActionState<["Base", "Logger", "Actions"]>) {
|
||||
// To capture errors appropriately, keep as much code within the try-catch as
|
||||
// possible, and only use safe functions outside.
|
||||
|
||||
const logger = getActionsLogger();
|
||||
const logger = action.logger;
|
||||
|
||||
let config: Config | undefined;
|
||||
|
||||
try {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.ResolveEnvironment,
|
||||
action.name,
|
||||
"starting",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
@@ -62,12 +59,13 @@ async function run(startedAt: Date) {
|
||||
);
|
||||
}
|
||||
|
||||
const workingDirectory = getOptionalInput("working-directory");
|
||||
const workingDirectory =
|
||||
action.actions.getOptionalInput("working-directory");
|
||||
const result = await runResolveBuildEnvironment(
|
||||
config.codeQLCmd,
|
||||
logger,
|
||||
workingDirectory,
|
||||
getRequiredInput("language"),
|
||||
action.actions.getRequiredInput("language"),
|
||||
);
|
||||
core.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
|
||||
} catch (unwrappedError) {
|
||||
@@ -82,14 +80,14 @@ async function run(startedAt: Date) {
|
||||
);
|
||||
} else {
|
||||
// For any other error types, something has more seriously gone wrong and we fail.
|
||||
core.setFailed(
|
||||
action.actions.setFailed(
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`,
|
||||
);
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.ResolveEnvironment,
|
||||
action.name,
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
@@ -105,9 +103,9 @@ async function run(startedAt: Date) {
|
||||
}
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.ResolveEnvironment,
|
||||
action.name,
|
||||
"success",
|
||||
startedAt,
|
||||
action.startedAt,
|
||||
config,
|
||||
await checkDiskUsage(logger),
|
||||
logger,
|
||||
@@ -117,23 +115,14 @@ async function run(startedAt: Date) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Defines the `resolve-environment` action. */
|
||||
const resolveEnvironmentAction: Action = {
|
||||
name: ActionName.ResolveEnvironment,
|
||||
run,
|
||||
};
|
||||
|
||||
/** The main entry point for the `resolve-environment` action. */
|
||||
export async function runWrapper() {
|
||||
const startedAt = new Date();
|
||||
const logger = getActionsLogger();
|
||||
try {
|
||||
await run(startedAt);
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
`${ActionName.ResolveEnvironment} action failed: ${getErrorMessage(
|
||||
error,
|
||||
)}`,
|
||||
);
|
||||
await sendUnhandledErrorStatusReport(
|
||||
ActionName.ResolveEnvironment,
|
||||
startedAt,
|
||||
error,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
await runInActions(resolveEnvironmentAction);
|
||||
await checkForTimeout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user