@@ -299,9 +299,14 @@ private async Task RunBenchmarksAsync(string[] coreRunPaths)
299299
300300 string ? artifactsDir = null ;
301301
302- await RunProcessAsync ( "/usr/lib/dotnet/dotnet" ,
302+ // Don't throw on a non-zero exit code. A single failing benchmark (e.g. a broken test in
303+ // dotnet/performance) makes the whole process exit with an error, but BenchmarkDotNet still
304+ // produces report files for everything that did run. We want to report those partial results
305+ // and note the failure rather than throwing away potentially hours of work.
306+ int exitCode = await RunProcessAsync ( "/usr/lib/dotnet/dotnet" ,
303307 $ "run -c Release --framework net{ dotnetVersion } .0 -- --filter { filter } -h { HiddenColumns } --corerun { coreRuns } { parallelSuffix } ",
304308 workDir : "performance/src/benchmarks/micro" ,
309+ checkExitCode : false ,
305310 processLogs : line =>
306311 {
307312 // Example:
@@ -336,7 +341,10 @@ await RunProcessAsync("/usr/lib/dotnet/dotnet",
336341
337342 if ( string . IsNullOrEmpty ( artifactsDir ) )
338343 {
339- throw new Exception ( "Couldn't find the artifacts directory" ) ;
344+ // We never saw a single results file, so there's nothing to report.
345+ throw new Exception ( exitCode == 0
346+ ? "Couldn't find the artifacts directory"
347+ : $ "The benchmark process failed with exit code { exitCode } before producing any results") ;
340348 }
341349
342350 await ZipAndUploadArtifactAsync ( "BDN_Artifacts" , artifactsDir ) ;
@@ -400,6 +408,19 @@ await RunProcessAsync("/usr/lib/dotnet/dotnet",
400408
401409 string combinedMarkdown = string . Join ( "\n \n " , results ) ;
402410
411+ if ( exitCode != 0 )
412+ {
413+ await LogAsync ( $ "The benchmark process exited with code { exitCode } . Reporting the { results . Count } result(s) that were still produced.") ;
414+
415+ string note =
416+ $ "⚠️ **The benchmark run did not complete successfully (exit code { exitCode } ).** " +
417+ "Some benchmarks may be missing from the results below. See the job logs for details." ;
418+
419+ combinedMarkdown = string . IsNullOrEmpty ( combinedMarkdown )
420+ ? note
421+ : $ "{ note } \n \n { combinedMarkdown } ";
422+ }
423+
403424 await UploadTextArtifactAsync ( "results.md" , combinedMarkdown ) ;
404425 }
405426
0 commit comments