mirror of
https://github.com/github/codeql-action.git
synced 2026-01-01 20:20:07 +08:00
Continue after CLI errors
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
sendStatusReport,
|
||||
} from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CommandInvocationError } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { Language, resolveAlias } from "./languages";
|
||||
import { getActionsLogger } from "./logging";
|
||||
@@ -16,6 +17,7 @@ import { runResolveBuildEnvironment } from "./resolve-environment";
|
||||
import { checkForTimeout, checkGitHubVersionInRange, wrapError } from "./util";
|
||||
|
||||
const ACTION_NAME = "resolve-environment";
|
||||
const ENVIRONMENT_OUTPUT_NAME = "environment";
|
||||
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
@@ -48,21 +50,34 @@ async function run() {
|
||||
workingDirectory,
|
||||
language
|
||||
);
|
||||
core.setOutput("environment", result);
|
||||
core.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
core.setFailed(
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
|
||||
);
|
||||
await sendStatusReport(
|
||||
await createStatusReportBase(
|
||||
ACTION_NAME,
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
error.message,
|
||||
error.stack
|
||||
)
|
||||
);
|
||||
|
||||
if (error instanceof CommandInvocationError) {
|
||||
// If the CLI failed to run successfully for whatever reason,
|
||||
// we just return an empty JSON object and proceed with the workflow.
|
||||
core.setOutput(ENVIRONMENT_OUTPUT_NAME, {});
|
||||
logger.warning(
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
|
||||
);
|
||||
} else {
|
||||
// For any other error types, something has more seriously gone wrong and we fail.
|
||||
core.setFailed(
|
||||
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
|
||||
);
|
||||
|
||||
await sendStatusReport(
|
||||
await createStatusReportBase(
|
||||
ACTION_NAME,
|
||||
getActionsStatus(error),
|
||||
startedAt,
|
||||
error.message,
|
||||
error.stack
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user