Skip to content

Commit ad9d1dc

Browse files
fix: do not error out if no head report is present after local run
This used to happen on local runs with integration when no run on main branch is present.
1 parent 920c7a1 commit ad9d1dc

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

src/cli/run/poll_results.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,25 @@ pub async fn poll_results(
1313
) -> Result<()> {
1414
let response = poll_run_report(api_client, upload_result).await?;
1515

16-
let report = response
17-
.run
18-
.head_reports
19-
.into_iter()
20-
.next()
21-
.ok_or_else(|| anyhow!("No head report found in the run report"))?;
16+
let report = response.run.head_reports.into_iter().next();
2217

23-
if let Some(impact) = report.impact {
24-
let rounded_impact = (impact * 100.0).round();
25-
let impact_text = if impact > 0.0 {
26-
style(format!("+{rounded_impact}%")).green().bold()
27-
} else {
28-
style(format!("{rounded_impact}%")).red().bold()
29-
};
18+
if let Some(report) = report {
19+
if let Some(impact) = report.impact {
20+
let rounded_impact = (impact * 100.0).round();
21+
let impact_text = if impact > 0.0 {
22+
style(format!("+{rounded_impact}%")).green().bold()
23+
} else {
24+
style(format!("{rounded_impact}%")).red().bold()
25+
};
3026

31-
info!(
32-
"Impact: {} (allowed regression: -{}%)",
33-
impact_text,
34-
(response.allowed_regression * 100.0).round()
35-
);
36-
} else {
37-
info!("No impact detected, reason: {}", report.conclusion);
27+
info!(
28+
"Impact: {} (allowed regression: -{}%)",
29+
impact_text,
30+
(response.allowed_regression * 100.0).round()
31+
);
32+
} else {
33+
info!("No impact detected, reason: {}", report.conclusion);
34+
}
3835
}
3936

4037
if output_json {

0 commit comments

Comments
 (0)