Continue after CLI errors
This commit is contained in:
parent
f239f49a62
commit
899b5a286f
3 changed files with 43 additions and 17 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue