@@ -214,37 +214,81 @@ test.serial(
214214 } ,
215215) ;
216216
217- test . serial ( "Don't crash if uploading a database fails" , async ( t ) => {
218- await withTmpDir ( async ( tmpDir ) => {
219- setupActionsVars ( tmpDir , tmpDir ) ;
220- sinon
221- . stub ( actionsUtil , "getRequiredInput" )
222- . withArgs ( "upload-database" )
223- . returns ( "true" ) ;
224- sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
217+ test . serial (
218+ "Don't crash if uploading a database fails with a non-retryable error" ,
219+ async ( t ) => {
220+ await withTmpDir ( async ( tmpDir ) => {
221+ setupActionsVars ( tmpDir , tmpDir ) ;
222+ sinon
223+ . stub ( actionsUtil , "getRequiredInput" )
224+ . withArgs ( "upload-database" )
225+ . returns ( "true" ) ;
226+ sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
225227
226- await mockHttpRequests ( 500 ) ;
228+ await mockHttpRequests ( 422 ) ;
227229
228- const loggedMessages = [ ] as LoggedMessage [ ] ;
229- await cleanupAndUploadDatabases (
230- testRepoName ,
231- getCodeQL ( ) ,
232- getTestConfig ( tmpDir ) ,
233- testApiDetails ,
234- createFeatures ( [ ] ) ,
235- getRecordingLogger ( loggedMessages ) ,
236- ) ;
230+ const loggedMessages = [ ] as LoggedMessage [ ] ;
231+ await cleanupAndUploadDatabases (
232+ testRepoName ,
233+ getCodeQL ( ) ,
234+ getTestConfig ( tmpDir ) ,
235+ testApiDetails ,
236+ createFeatures ( [ ] ) ,
237+ getRecordingLogger ( loggedMessages ) ,
238+ ) ;
237239
238- t . assert (
239- loggedMessages . find (
240- ( v ) =>
241- v . type === "warning" &&
242- v . message ===
243- "Failed to upload database for javascript: some error message" ,
244- ) !== undefined ,
245- ) ;
246- } ) ;
247- } ) ;
240+ t . assert (
241+ loggedMessages . find (
242+ ( v ) =>
243+ v . type === "warning" &&
244+ v . message ===
245+ "Failed to upload database for javascript: some error message" ,
246+ ) !== undefined ,
247+ ) ;
248+ } ) ;
249+ } ,
250+ ) ;
251+
252+ test . serial (
253+ "Don't crash if uploading a database fails with a retryable error" ,
254+ async ( t ) => {
255+ await withTmpDir ( async ( tmpDir ) => {
256+ setupActionsVars ( tmpDir , tmpDir ) ;
257+ sinon
258+ . stub ( actionsUtil , "getRequiredInput" )
259+ . withArgs ( "upload-database" )
260+ . returns ( "true" ) ;
261+ sinon . stub ( gitUtils , "isAnalyzingDefaultBranch" ) . resolves ( true ) ;
262+
263+ await mockHttpRequests ( 500 ) ;
264+
265+ // Stub setTimeout to fire immediately to avoid real delays from retry backoff.
266+ const originalSetTimeout = global . setTimeout ;
267+ sinon
268+ . stub ( global , "setTimeout" )
269+ . callsFake ( ( fn : ( ) => void ) => originalSetTimeout ( fn , 0 ) ) ;
270+
271+ const loggedMessages = [ ] as LoggedMessage [ ] ;
272+ await cleanupAndUploadDatabases (
273+ testRepoName ,
274+ getCodeQL ( ) ,
275+ getTestConfig ( tmpDir ) ,
276+ testApiDetails ,
277+ createFeatures ( [ ] ) ,
278+ getRecordingLogger ( loggedMessages ) ,
279+ ) ;
280+
281+ t . assert (
282+ loggedMessages . find (
283+ ( v ) =>
284+ v . type === "warning" &&
285+ v . message ===
286+ "Failed to upload database for javascript: some error message" ,
287+ ) !== undefined ,
288+ ) ;
289+ } ) ;
290+ } ,
291+ ) ;
248292
249293test . serial ( "Successfully uploading a database to github.com" , async ( t ) => {
250294 await withTmpDir ( async ( tmpDir ) => {
0 commit comments