Permalink
Browse files

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
  • Loading branch information...
bors committed Dec 4, 2018
2 parents 8472192 + 4661d07 commit dcc769920ceb5066e8ecbab08f1ffb26e366a452
Showing with 78 additions and 58 deletions.
  1. +7 −7 src/report/mod.rs
  2. +71 −51 src/server/reports.rs
@@ -35,18 +35,18 @@ fn url_encode(input: &str) -> String {

#[derive(Serialize, Deserialize)]
pub struct TestResults {
crates: Vec<CrateResult>,
pub crates: Vec<CrateResult>,
}

#[derive(Serialize, Deserialize, Clone)]
struct CrateResult {
pub struct CrateResult {
name: String,
url: String,
res: Comparison,
pub res: Comparison,
runs: [Option<BuildTestResult>; 2],
}

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

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

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

Ok(())
Ok(res)
}

fn crate_to_name(c: &Crate, shas: &HashMap<GitHubRepo, String>) -> Fallible<String> {
@@ -1,6 +1,6 @@
use experiments::{Experiment, Status};
use prelude::*;
use report;
use report::{self, Comparison, TestResults};
use results::DatabaseDB;
use rusoto_core::request::HttpClient;
use rusoto_s3::S3Client;
@@ -14,7 +14,7 @@ use utils;
// Automatically wake up the reports generator thread every 10 minutes to check for new jobs
const AUTOMATIC_THREAD_WAKEUP: u64 = 600;

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

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

Ok(())
Ok(res)
}

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

if let Err(err) = generate_report(data, &ex, &results) {
ex.set_status(&data.db, Status::ReportFailed)?;
error!("failed to generate the report of {}", name);
utils::report_failure(&err);

if let Some(ref github_issue) = ex.github_issue {
Message::new()
.line(
"rotating_light",
format!("Report generation of **`{}`** failed: {}", name, err),
).line(
"hammer_and_wrench",
"If the error is fixed use the `retry-report` command.",
).note(
"sos",
"Can someone from the infra team check in on this? @rust-lang/infra",
).send(&github_issue.api_url, data)?;
}

continue;
}
match generate_report(data, &ex, &results) {
Err(err) => {
ex.set_status(&data.db, Status::ReportFailed)?;
error!("failed to generate the report of {}", name);
utils::report_failure(&err);

if let Some(ref github_issue) = ex.github_issue {
Message::new()
.line(
"rotating_light",
format!("Report generation of **`{}`** failed: {}", name, err),
).line(
"hammer_and_wrench",
"If the error is fixed use the `retry-report` command.",
).note(
"sos",
"Can someone from the infra team check in on this? @rust-lang/infra",
).send(&github_issue.api_url, data)?;
}

let base_url = data
.tokens
.reports_bucket
.public_url
.replace("{bucket}", &data.tokens.reports_bucket.bucket);
let report_url = format!("{}/{}/index.html", base_url, name);

ex.set_status(&data.db, Status::Completed)?;
ex.set_report_url(&data.db, &report_url)?;
info!("report for the experiment {} generated successfully!", name);

if let Some(ref github_issue) = ex.github_issue {
Message::new()
.line("tada", format!("Experiment **`{}`** is completed!", name))
.line(
"newspaper",
format!("[Open the full report]({}).", report_url),
).note(
"warning",
format!(
"If you notice any spurious failure [please add them to the \
blacklist]({}/blob/master/config.toml)!",
::CRATER_REPO_URL,
),
).set_label(Label::ExperimentCompleted)
.send(&github_issue.api_url, data)?;
continue;
}
Ok(res) => {
let base_url = data
.tokens
.reports_bucket
.public_url
.replace("{bucket}", &data.tokens.reports_bucket.bucket);
let report_url = format!("{}/{}/index.html", base_url, name);

ex.set_status(&data.db, Status::Completed)?;
ex.set_report_url(&data.db, &report_url)?;
info!("report for the experiment {} generated successfully!", name);

let (mut regressed, mut fixed) = (0, 0);
res.crates.iter().for_each(|krate| {
match krate.res {
Comparison::Regressed => regressed += 1,
Comparison::Fixed => fixed += 1,
_ => (),
};
});

if let Some(ref github_issue) = ex.github_issue {
Message::new()
.line("tada", format!("Experiment **`{}`** is completed!", name))
.line(
"bar_chart",
format!(
" {} regressed and {} fixed ({} total)",
regressed,
fixed,
res.crates.len(),
),
).line(
"newspaper",
format!("[Open the full report]({}).", report_url),
).note(
"warning",
format!(
"If you notice any spurious failure [please add them to the \
blacklist]({}/blob/master/config.toml)!",
::CRATER_REPO_URL,
),
).set_label(Label::ExperimentCompleted)
.send(&github_issue.api_url, data)?;
}
}
}
}
}

0 comments on commit dcc7699

Please sign in to comment.