Skip to content

Commit dcc7699

Browse files
committed
Auto merge of #372 - Zeegomo:zeegomo, r=pietroalbini
Show stats in GitHub message Implementation of #249 Show number of tested, regressed and fixed crates in the GitHub Message
2 parents 8472192 + 4661d07 commit dcc7699

File tree

2 files changed

+78
-58
lines changed

2 files changed

+78
-58
lines changed

src/report/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ fn url_encode(input: &str) -> String {
3535

3636
#[derive(Serialize, Deserialize)]
3737
pub struct TestResults {
38-
crates: Vec<CrateResult>,
38+
pub crates: Vec<CrateResult>,
3939
}
4040

4141
#[derive(Serialize, Deserialize, Clone)]
42-
struct CrateResult {
42+
pub struct CrateResult {
4343
name: String,
4444
url: String,
45-
res: Comparison,
45+
pub res: Comparison,
4646
runs: [Option<BuildTestResult>; 2],
4747
}
4848

49-
string_enum!(enum Comparison {
49+
string_enum!(pub enum Comparison {
5050
Regressed => "regressed",
5151
Fixed => "fixed",
5252
Skipped => "skipped",
@@ -61,7 +61,7 @@ string_enum!(enum Comparison {
6161
});
6262

6363
impl Comparison {
64-
fn show_in_summary(self) -> bool {
64+
pub fn show_in_summary(self) -> bool {
6565
match self {
6666
Comparison::Regressed
6767
| Comparison::Fixed
@@ -212,7 +212,7 @@ pub fn gen<DB: ReadResults, W: ReportWriter + Display>(
212212
ex: &Experiment,
213213
dest: &W,
214214
config: &Config,
215-
) -> Fallible<()> {
215+
) -> Fallible<TestResults> {
216216
let res = generate_report(db, config, ex)?;
217217

218218
info!("writing results to {}", dest);
@@ -235,7 +235,7 @@ pub fn gen<DB: ReadResults, W: ReportWriter + Display>(
235235
info!("writing logs");
236236
write_logs(db, ex, dest, config)?;
237237

238-
Ok(())
238+
Ok(res)
239239
}
240240

241241
fn crate_to_name(c: &Crate, shas: &HashMap<GitHubRepo, String>) -> Fallible<String> {

src/server/reports.rs

Lines changed: 71 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use experiments::{Experiment, Status};
22
use prelude::*;
3-
use report;
3+
use report::{self, Comparison, TestResults};
44
use results::DatabaseDB;
55
use rusoto_core::request::HttpClient;
66
use rusoto_s3::S3Client;
@@ -14,7 +14,7 @@ use utils;
1414
// Automatically wake up the reports generator thread every 10 minutes to check for new jobs
1515
const AUTOMATIC_THREAD_WAKEUP: u64 = 600;
1616

17-
fn generate_report(data: &Data, ex: &Experiment, results: &DatabaseDB) -> Fallible<()> {
17+
fn generate_report(data: &Data, ex: &Experiment, results: &DatabaseDB) -> Fallible<TestResults> {
1818
let client = S3Client::new_with(
1919
HttpClient::new()?,
2020
data.tokens.reports_bucket.to_aws_credentials(),
@@ -23,9 +23,9 @@ fn generate_report(data: &Data, ex: &Experiment, results: &DatabaseDB) -> Fallib
2323
let dest = format!("s3://{}/{}", data.tokens.reports_bucket.bucket, &ex.name);
2424
let writer = report::S3Writer::create(Box::new(client), dest.parse()?)?;
2525

26-
report::gen(results, &ex, &writer, &data.config)?;
26+
let res = report::gen(results, &ex, &writer, &data.config)?;
2727

28-
Ok(())
28+
Ok(res)
2929
}
3030

3131
fn reports_thread(data: &Data, wakes: &mpsc::Receiver<()>) -> Fallible<()> {
@@ -49,54 +49,74 @@ fn reports_thread(data: &Data, wakes: &mpsc::Receiver<()>) -> Fallible<()> {
4949
info!("generating report for experiment {}...", name);
5050
ex.set_status(&data.db, Status::GeneratingReport)?;
5151

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+
}
7371

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+
}
100120
}
101121
}
102122
}

0 commit comments

Comments
 (0)