Skip to content

Commit 899b5a2

Browse files
committed
Continue after CLI errors
1 parent f239f49 commit 899b5a2

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

lib/resolve-environment-action.js

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

lib/resolve-environment-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resolve-environment-action.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import {
99
sendStatusReport,
1010
} from "./actions-util";
1111
import { getGitHubVersion } from "./api-client";
12+
import { CommandInvocationError } from "./codeql";
1213
import * as configUtils from "./config-utils";
1314
import { Language, resolveAlias } from "./languages";
1415
import { getActionsLogger } from "./logging";
1516
import { runResolveBuildEnvironment } from "./resolve-environment";
1617
import { checkForTimeout, checkGitHubVersionInRange, wrapError } from "./util";
1718

1819
const ACTION_NAME = "resolve-environment";
20+
const ENVIRONMENT_OUTPUT_NAME = "environment";
1921

2022
async function run() {
2123
const startedAt = new Date();
@@ -48,21 +50,34 @@ async function run() {
4850
workingDirectory,
4951
language
5052
);
51-
core.setOutput("environment", result);
53+
core.setOutput(ENVIRONMENT_OUTPUT_NAME, result);
5254
} catch (unwrappedError) {
5355
const error = wrapError(unwrappedError);
54-
core.setFailed(
55-
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
56-
);
57-
await sendStatusReport(
58-
await createStatusReportBase(
59-
ACTION_NAME,
60-
getActionsStatus(error),
61-
startedAt,
62-
error.message,
63-
error.stack
64-
)
65-
);
56+
57+
if (error instanceof CommandInvocationError) {
58+
// If the CLI failed to run successfully for whatever reason,
59+
// we just return an empty JSON object and proceed with the workflow.
60+
core.setOutput(ENVIRONMENT_OUTPUT_NAME, {});
61+
logger.warning(
62+
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
63+
);
64+
} else {
65+
// For any other error types, something has more seriously gone wrong and we fail.
66+
core.setFailed(
67+
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`
68+
);
69+
70+
await sendStatusReport(
71+
await createStatusReportBase(
72+
ACTION_NAME,
73+
getActionsStatus(error),
74+
startedAt,
75+
error.message,
76+
error.stack
77+
)
78+
);
79+
}
80+
6681
return;
6782
}
6883

0 commit comments

Comments
 (0)