@@ -67,15 +67,15 @@ export async function uploadCombinedSarifArtifacts() {
67
67
}
68
68
69
69
/**
70
- * Try to get the SARIF result path for the given language.
70
+ * Try to prepare a SARIF result debug artifact for the given language.
71
71
*
72
- * If an error occurs, log it and return an empty list .
72
+ * @return The path to that debug artifact, or undefined if an error occurs .
73
73
*/
74
- function tryGetSarifResultPath (
74
+ function tryPrepareSarifDebugArtifact (
75
75
config : Config ,
76
76
language : Language ,
77
77
logger : Logger ,
78
- ) : string [ ] {
78
+ ) : string | undefined {
79
79
try {
80
80
const analyzeActionOutputDir = process . env [ EnvVar . SARIF_RESULTS_OUTPUT_DIR ] ;
81
81
if (
@@ -94,7 +94,7 @@ function tryGetSarifResultPath(
94
94
`${ language } .sarif` ,
95
95
) ;
96
96
fs . copyFileSync ( sarifFile , sarifInDbLocation ) ;
97
- return [ sarifInDbLocation ] ;
97
+ return sarifInDbLocation ;
98
98
}
99
99
}
100
100
} catch ( e ) {
@@ -104,39 +104,38 @@ function tryGetSarifResultPath(
104
104
) } `,
105
105
) ;
106
106
}
107
- return [ ] ;
107
+ return undefined ;
108
108
}
109
109
110
110
/**
111
- * Try to bundle the database for the given language. Return a list containing
112
- * the path to the database bundle.
111
+ * Try to bundle the database for the given language.
113
112
*
114
- * If an error occurs, log it and return an empty list .
113
+ * @return The path to the database bundle, or undefined if an error occurs .
115
114
*/
116
115
async function tryBundleDatabase (
117
116
config : Config ,
118
117
language : Language ,
119
118
logger : Logger ,
120
- ) : Promise < string [ ] > {
119
+ ) : Promise < string | undefined > {
121
120
try {
122
121
if ( dbIsFinalized ( config , language , logger ) ) {
123
122
try {
124
- return [ await createDatabaseBundleCli ( config , language ) ] ;
123
+ return await createDatabaseBundleCli ( config , language ) ;
125
124
} catch ( e ) {
126
125
logger . warning (
127
126
`Failed to bundle database for ${ language } using the CLI. ` +
128
127
`Falling back to a partial bundle. Reason: ${ getErrorMessage ( e ) } ` ,
129
128
) ;
130
129
}
131
130
}
132
- return [ await createPartialDatabaseBundle ( config , language ) ] ;
131
+ return await createPartialDatabaseBundle ( config , language ) ;
133
132
} catch ( e ) {
134
133
logger . warning (
135
134
`Failed to bundle database for ${ language } . Reason: ${ getErrorMessage (
136
135
e ,
137
136
) } `,
138
137
) ;
139
- return [ ] ;
138
+ return undefined ;
140
139
}
141
140
}
142
141
@@ -153,7 +152,14 @@ export async function tryUploadAllAvailableDebugArtifacts(
153
152
const filesToUpload : string [ ] = [ ] ;
154
153
155
154
for ( const language of config . languages ) {
156
- filesToUpload . push ( ...tryGetSarifResultPath ( config , language , logger ) ) ;
155
+ const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact (
156
+ config ,
157
+ language ,
158
+ logger ,
159
+ ) ;
160
+ if ( sarifResultDebugArtifact ) {
161
+ filesToUpload . push ( sarifResultDebugArtifact ) ;
162
+ }
157
163
158
164
// Add any log files
159
165
const databaseDirectory = getCodeQLDatabasePath ( config , language ) ;
@@ -172,9 +178,10 @@ export async function tryUploadAllAvailableDebugArtifacts(
172
178
}
173
179
174
180
// Add database bundle
175
- filesToUpload . push (
176
- ...( await tryBundleDatabase ( config , language , logger ) ) ,
177
- ) ;
181
+ const databaseBundle = await tryBundleDatabase ( config , language , logger ) ;
182
+ if ( databaseBundle ) {
183
+ filesToUpload . push ( databaseBundle ) ;
184
+ }
178
185
}
179
186
180
187
await uploadDebugArtifacts (
0 commit comments