1
1
use experiments:: { Experiment , Status } ;
2
2
use prelude:: * ;
3
- use report;
3
+ use report:: { self , Comparison , TestResults } ;
4
4
use results:: DatabaseDB ;
5
5
use rusoto_core:: request:: HttpClient ;
6
6
use rusoto_s3:: S3Client ;
@@ -14,7 +14,7 @@ use utils;
14
14
// Automatically wake up the reports generator thread every 10 minutes to check for new jobs
15
15
const AUTOMATIC_THREAD_WAKEUP : u64 = 600 ;
16
16
17
- fn generate_report ( data : & Data , ex : & Experiment , results : & DatabaseDB ) -> Fallible < ( ) > {
17
+ fn generate_report ( data : & Data , ex : & Experiment , results : & DatabaseDB ) -> Fallible < TestResults > {
18
18
let client = S3Client :: new_with (
19
19
HttpClient :: new ( ) ?,
20
20
data. tokens . reports_bucket . to_aws_credentials ( ) ,
@@ -23,9 +23,9 @@ fn generate_report(data: &Data, ex: &Experiment, results: &DatabaseDB) -> Fallib
23
23
let dest = format ! ( "s3://{}/{}" , data. tokens. reports_bucket. bucket, & ex. name) ;
24
24
let writer = report:: S3Writer :: create ( Box :: new ( client) , dest. parse ( ) ?) ?;
25
25
26
- report:: gen ( results, & ex, & writer, & data. config ) ?;
26
+ let res = report:: gen ( results, & ex, & writer, & data. config ) ?;
27
27
28
- Ok ( ( ) )
28
+ Ok ( res )
29
29
}
30
30
31
31
fn reports_thread ( data : & Data , wakes : & mpsc:: Receiver < ( ) > ) -> Fallible < ( ) > {
@@ -49,54 +49,74 @@ fn reports_thread(data: &Data, wakes: &mpsc::Receiver<()>) -> Fallible<()> {
49
49
info ! ( "generating report for experiment {}..." , name) ;
50
50
ex. set_status ( & data. db , Status :: GeneratingReport ) ?;
51
51
52
- if let Err ( err) = generate_report ( data, & ex, & results) {
53
- ex. set_status ( & data. db , Status :: ReportFailed ) ?;
54
- error ! ( "failed to generate the report of {}" , name) ;
55
- utils:: report_failure ( & err) ;
56
-
57
- if let Some ( ref github_issue) = ex. github_issue {
58
- Message :: new ( )
59
- . line (
60
- "rotating_light" ,
61
- format ! ( "Report generation of **`{}`** failed: {}" , name, err) ,
62
- ) . line (
63
- "hammer_and_wrench" ,
64
- "If the error is fixed use the `retry-report` command." ,
65
- ) . note (
66
- "sos" ,
67
- "Can someone from the infra team check in on this? @rust-lang/infra" ,
68
- ) . send ( & github_issue. api_url , data) ?;
69
- }
70
-
71
- continue ;
72
- }
52
+ match generate_report ( data, & ex, & results) {
53
+ Err ( err) => {
54
+ ex. set_status ( & data. db , Status :: ReportFailed ) ?;
55
+ error ! ( "failed to generate the report of {}" , name) ;
56
+ utils:: report_failure ( & err) ;
57
+
58
+ if let Some ( ref github_issue) = ex. github_issue {
59
+ Message :: new ( )
60
+ . line (
61
+ "rotating_light" ,
62
+ format ! ( "Report generation of **`{}`** failed: {}" , name, err) ,
63
+ ) . line (
64
+ "hammer_and_wrench" ,
65
+ "If the error is fixed use the `retry-report` command." ,
66
+ ) . note (
67
+ "sos" ,
68
+ "Can someone from the infra team check in on this? @rust-lang/infra" ,
69
+ ) . send ( & github_issue. api_url , data) ?;
70
+ }
73
71
74
- let base_url = data
75
- . tokens
76
- . reports_bucket
77
- . public_url
78
- . replace ( "{bucket}" , & data. tokens . reports_bucket . bucket ) ;
79
- let report_url = format ! ( "{}/{}/index.html" , base_url, name) ;
80
-
81
- ex. set_status ( & data. db , Status :: Completed ) ?;
82
- ex. set_report_url ( & data. db , & report_url) ?;
83
- info ! ( "report for the experiment {} generated successfully!" , name) ;
84
-
85
- if let Some ( ref github_issue) = ex. github_issue {
86
- Message :: new ( )
87
- . line ( "tada" , format ! ( "Experiment **`{}`** is completed!" , name) )
88
- . line (
89
- "newspaper" ,
90
- format ! ( "[Open the full report]({})." , report_url) ,
91
- ) . note (
92
- "warning" ,
93
- format ! (
94
- "If you notice any spurious failure [please add them to the \
95
- blacklist]({}/blob/master/config.toml)!",
96
- :: CRATER_REPO_URL ,
97
- ) ,
98
- ) . set_label ( Label :: ExperimentCompleted )
99
- . send ( & github_issue. api_url , data) ?;
72
+ continue ;
73
+ }
74
+ Ok ( res) => {
75
+ let base_url = data
76
+ . tokens
77
+ . reports_bucket
78
+ . public_url
79
+ . replace ( "{bucket}" , & data. tokens . reports_bucket . bucket ) ;
80
+ let report_url = format ! ( "{}/{}/index.html" , base_url, name) ;
81
+
82
+ ex. set_status ( & data. db , Status :: Completed ) ?;
83
+ ex. set_report_url ( & data. db , & report_url) ?;
84
+ info ! ( "report for the experiment {} generated successfully!" , name) ;
85
+
86
+ let ( mut regressed, mut fixed) = ( 0 , 0 ) ;
87
+ res. crates . iter ( ) . for_each ( |krate| {
88
+ match krate. res {
89
+ Comparison :: Regressed => regressed += 1 ,
90
+ Comparison :: Fixed => fixed += 1 ,
91
+ _ => ( ) ,
92
+ } ;
93
+ } ) ;
94
+
95
+ if let Some ( ref github_issue) = ex. github_issue {
96
+ Message :: new ( )
97
+ . line ( "tada" , format ! ( "Experiment **`{}`** is completed!" , name) )
98
+ . line (
99
+ "bar_chart" ,
100
+ format ! (
101
+ " {} regressed and {} fixed ({} total)" ,
102
+ regressed,
103
+ fixed,
104
+ res. crates. len( ) ,
105
+ ) ,
106
+ ) . line (
107
+ "newspaper" ,
108
+ format ! ( "[Open the full report]({})." , report_url) ,
109
+ ) . note (
110
+ "warning" ,
111
+ format ! (
112
+ "If you notice any spurious failure [please add them to the \
113
+ blacklist]({}/blob/master/config.toml)!",
114
+ :: CRATER_REPO_URL ,
115
+ ) ,
116
+ ) . set_label ( Label :: ExperimentCompleted )
117
+ . send ( & github_issue. api_url , data) ?;
118
+ }
119
+ }
100
120
}
101
121
}
102
122
}
0 commit comments