@@ -218,8 +218,23 @@ def report_command
218
218
File . write ( queue_config . export_flaky_tests_file , failures )
219
219
end
220
220
221
+ # Handle timing data reporting and export
222
+ test_time_reporter_success = if queue_config . track_test_duration
223
+ test_time_record = CI ::Queue ::Redis ::TestTimeRecord . new ( queue_url , queue_config )
224
+ test_time_reporter = TestTimeReporter . new (
225
+ build : test_time_record ,
226
+ limit : queue_config . max_test_duration ,
227
+ percentile : queue_config . max_test_duration_percentile ,
228
+ export_file : queue_config . export_timing_file
229
+ )
230
+ test_time_reporter . report
231
+ test_time_reporter . success?
232
+ else
233
+ true
234
+ end
235
+
221
236
reporter . report
222
- exit! reporter . success? ? 0 : 1
237
+ exit! reporter . success? && test_time_reporter_success ? 0 : 1
223
238
end
224
239
225
240
def report_grind_command
@@ -241,6 +256,7 @@ def report_grind_command
241
256
build : test_time_record ,
242
257
limit : queue_config . max_test_duration ,
243
258
percentile : queue_config . max_test_duration_percentile ,
259
+ export_file : queue_config . export_timing_file
244
260
)
245
261
test_time_reporter . report
246
262
@@ -564,6 +580,38 @@ def parser
564
580
self . test_globs = test_globs
565
581
end
566
582
583
+ help = <<~EOS
584
+ Test ordering strategy: random, timing_based (default: random)
585
+ EOS
586
+ opts . separator ""
587
+ opts . on ( '--strategy STRATEGY' , help ) do |strategy |
588
+ queue_config . strategy = strategy . to_sym
589
+ end
590
+
591
+ help = <<~EOS
592
+ Path to JSON timing file for timing_based strategy
593
+ EOS
594
+ opts . separator ""
595
+ opts . on ( '--timing-file PATH' , help ) do |path |
596
+ queue_config . timing_file = path
597
+ end
598
+
599
+ help = <<~EOS
600
+ Fallback duration in ms for unknown tests (default: 100)
601
+ EOS
602
+ opts . separator ""
603
+ opts . on ( '--timing-fallback DURATION' , Float , help ) do |duration |
604
+ queue_config . timing_fallback_duration = duration
605
+ end
606
+
607
+ help = <<~EOS
608
+ Export test timing data to JSON file after run (use with report command)
609
+ EOS
610
+ opts . separator ""
611
+ opts . on ( '--export-timing-file PATH' , help ) do |path |
612
+ queue_config . export_timing_file = path
613
+ end
614
+
567
615
opts . separator ""
568
616
opts . separator " retry: Replays a previous run in the same order."
569
617
0 commit comments