@@ -501,6 +501,8 @@ pub struct PostComment {
501
501
pub body : String ,
502
502
}
503
503
504
+ /// Post messages to GitHub for all queued commits that have
505
+ /// not yet been marked as completed.
504
506
pub async fn post_finished ( ctxt : & SiteCtxt ) {
505
507
// If the github token is not configured, do not run this -- we don't want
506
508
// to mark things as complete without posting the comment.
@@ -509,7 +511,7 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
509
511
}
510
512
let conn = ctxt. conn ( ) . await ;
511
513
let index = ctxt. index . load ( ) ;
512
- let mut already_tested_commits = index
514
+ let mut known_commits = index
513
515
. commits ( )
514
516
. into_iter ( )
515
517
. map ( |c| c. sha . to_string ( ) )
@@ -519,36 +521,41 @@ pub async fn post_finished(ctxt: &SiteCtxt) {
519
521
conn. queued_commits( ) ,
520
522
conn. in_progress_artifacts( )
521
523
) ;
522
- let master_commits = master_commits
523
- . unwrap ( )
524
- . into_iter ( )
525
- . map ( |c| c. sha )
526
- . collect :: < HashSet < _ > > ( ) ;
524
+ let master_commits = if let Ok ( mcs) = master_commits {
525
+ mcs. into_iter ( ) . map ( |c| c. sha ) . collect :: < HashSet < _ > > ( )
526
+ } else {
527
+ // If we can't fetch master commits, return.
528
+ // We'll eventually try again later
529
+ return ;
530
+ } ;
527
531
528
532
for aid in in_progress_artifacts {
529
533
match aid {
530
534
ArtifactId :: Commit ( c) => {
531
- already_tested_commits . remove ( & c. sha ) ;
535
+ known_commits . remove ( & c. sha ) ;
532
536
}
533
537
ArtifactId :: Tag ( _) => {
534
538
// do nothing, for now, though eventually we'll want an artifact queue
535
539
}
536
540
}
537
541
}
538
- for commit in queued_pr_commits
542
+ for queued_commit in queued_pr_commits
539
543
. into_iter ( )
540
- . filter ( |c| already_tested_commits . contains ( & c. sha ) )
544
+ . filter ( |c| known_commits . contains ( & c. sha ) )
541
545
{
542
- if let Some ( completed) = conn. mark_complete ( & commit . sha ) . await {
543
- assert_eq ! ( completed, commit ) ;
546
+ if let Some ( completed) = conn. mark_complete ( & queued_commit . sha ) . await {
547
+ assert_eq ! ( completed, queued_commit ) ;
544
548
545
- let is_master_commit = master_commits. contains ( & commit . sha ) ;
546
- post_comparison_comment ( commit , ctxt , is_master_commit) . await ;
549
+ let is_master_commit = master_commits. contains ( & queued_commit . sha ) ;
550
+ post_comparison_comment ( ctxt , queued_commit , is_master_commit) . await ;
547
551
}
548
552
}
549
553
}
550
554
551
- async fn post_comparison_comment ( commit : QueuedCommit , ctxt : & SiteCtxt , is_master_commit : bool ) {
555
+ /// Posts a comment to GitHub summarizing the comparison of the queued commit with its parent
556
+ ///
557
+ /// `is_master_commit` is used to differentiate messages for try runs and post-merge runs.
558
+ async fn post_comparison_comment ( ctxt : & SiteCtxt , commit : QueuedCommit , is_master_commit : bool ) {
552
559
let comparison_url = format ! (
553
560
"https://perf.rust-lang.org/compare.html?start={}&end={}" ,
554
561
commit. parent_sha, commit. sha
@@ -559,6 +566,13 @@ async fn post_comparison_comment(commit: QueuedCommit, ctxt: &SiteCtxt, is_maste
559
566
Some ( Direction :: Regression | Direction :: Mixed ) => "+perf-regression" ,
560
567
Some ( Direction :: Improvement ) | None => "-perf-regression" ,
561
568
} ;
569
+ let rollup_msg = if is_master_commit {
570
+ ""
571
+ } else {
572
+ "Benchmarking this pull request likely means that it is \
573
+ perf-sensitive, so we're automatically marking it as not fit \
574
+ for rolling up. "
575
+ } ;
562
576
let next_steps_msg = direction
563
577
. map ( |d| {
564
578
format ! (
@@ -577,19 +591,12 @@ async fn post_comparison_comment(commit: QueuedCommit, ctxt: &SiteCtxt, is_maste
577
591
`@rustbot label: +perf-regression-triaged` along with \
578
592
sufficient written justification. If you cannot justify the regressions \
579
593
please fix the regressions (either in this PR if it's not yet merged or \
580
- in another PR) and do another perf run .",
594
+ in another PR), and then add the ` perf-regression-triaged` label to this PR .",
581
595
Direction :: Improvement => "" ,
582
596
}
583
597
)
584
598
} )
585
599
. unwrap_or ( String :: new ( ) ) ;
586
- let rollup_msg = if is_master_commit {
587
- ""
588
- } else {
589
- "Benchmarking this pull request likely means that it is \
590
- perf-sensitive, so we're automatically marking it as not fit \
591
- for rolling up. "
592
- } ;
593
600
let bors_msg = if is_master_commit {
594
601
""
595
602
} else {
@@ -599,14 +606,20 @@ for rolling up. "
599
606
& ctxt. config ,
600
607
commit. pr ,
601
608
format ! (
602
- "Finished benchmarking commit ({}): [comparison url]({}).
603
-
604
- **Summary**: {}
605
-
606
- {}{}
607
- {}
608
- @rustbot label: +S-waiting-on-review -S-waiting-on-perf {}" ,
609
- commit. sha, comparison_url, summary, rollup_msg, next_steps_msg, bors_msg, label
609
+ "Finished benchmarking commit ({sha}): [comparison url]({url}).
610
+
611
+ **Summary**: {summary}
612
+
613
+ {rollup}{next_steps}
614
+ {bors}
615
+ @rustbot label: +S-waiting-on-review -S-waiting-on-perf {label}" ,
616
+ sha = commit. sha,
617
+ url = comparison_url,
618
+ summary = summary,
619
+ rollup = rollup_msg,
620
+ next_steps = next_steps_msg,
621
+ bors = bors_msg,
622
+ label = label
610
623
) ,
611
624
)
612
625
. await ;
0 commit comments