@@ -9,13 +9,15 @@ import {
9
9
sendStatusReport ,
10
10
} from "./actions-util" ;
11
11
import { getGitHubVersion } from "./api-client" ;
12
+ import { CommandInvocationError } from "./codeql" ;
12
13
import * as configUtils from "./config-utils" ;
13
14
import { Language , resolveAlias } from "./languages" ;
14
15
import { getActionsLogger } from "./logging" ;
15
16
import { runResolveBuildEnvironment } from "./resolve-environment" ;
16
17
import { checkForTimeout , checkGitHubVersionInRange , wrapError } from "./util" ;
17
18
18
19
const ACTION_NAME = "resolve-environment" ;
20
+ const ENVIRONMENT_OUTPUT_NAME = "environment" ;
19
21
20
22
async function run ( ) {
21
23
const startedAt = new Date ( ) ;
@@ -48,21 +50,34 @@ async function run() {
48
50
workingDirectory ,
49
51
language
50
52
) ;
51
- core . setOutput ( "environment" , result ) ;
53
+ core . setOutput ( ENVIRONMENT_OUTPUT_NAME , result ) ;
52
54
} catch ( unwrappedError ) {
53
55
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
+
66
81
return ;
67
82
}
68
83
0 commit comments