Skip to content

Commit 30d5757

Browse files
committed
Print test diffs into GitHub summary
So that we can also observe them for try builds, before merging a PR.
1 parent 6c24c9c commit 30d5757

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,12 @@ jobs:
252252
exit 0
253253
fi
254254
255+
# Get closest bors merge commit
256+
PARENT_COMMIT=`git rev-list --author='bors <[email protected]>' -n1 --first-parent HEAD^1`
257+
255258
./build/citool/debug/citool postprocess-metrics \
259+
--job-name ${CI_JOB_NAME} \
260+
--parent ${PARENT_COMMIT} \
256261
${METRICS} >> ${GITHUB_STEP_SUMMARY}
257262
258263
- name: upload job metrics to DataDog

src/ci/citool/src/main.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod jobs;
55
mod metrics;
66
mod utils;
77

8-
use std::collections::BTreeMap;
8+
use std::collections::{BTreeMap, HashMap};
99
use std::path::{Path, PathBuf};
1010
use std::process::Command;
1111

@@ -18,7 +18,7 @@ use crate::analysis::output_test_diffs;
1818
use crate::cpu_usage::load_cpu_usage;
1919
use crate::datadog::upload_datadog_metric;
2020
use crate::jobs::RunType;
21-
use crate::metrics::{download_auto_job_metrics, load_metrics};
21+
use crate::metrics::{JobMetrics, download_auto_job_metrics, download_job_metrics, load_metrics};
2222
use crate::utils::load_env_var;
2323
use analysis::output_bootstrap_stats;
2424

@@ -138,6 +138,27 @@ fn upload_ci_metrics(cpu_usage_csv: &Path) -> anyhow::Result<()> {
138138
Ok(())
139139
}
140140

141+
fn postprocess_metrics(
142+
metrics_path: PathBuf,
143+
parent: Option<String>,
144+
job_name: Option<String>,
145+
) -> anyhow::Result<()> {
146+
let metrics = load_metrics(&metrics_path)?;
147+
output_bootstrap_stats(&metrics);
148+
149+
let (Some(parent), Some(job_name)) = (parent, job_name) else {
150+
return Ok(());
151+
};
152+
153+
let parent_metrics =
154+
download_job_metrics(&job_name, &parent).context("cannot download parent metrics")?;
155+
let job_metrics =
156+
HashMap::from([(job_name, JobMetrics { parent: Some(parent_metrics), current: metrics })]);
157+
output_test_diffs(job_metrics);
158+
159+
Ok(())
160+
}
161+
141162
#[derive(clap::Parser)]
142163
enum Args {
143164
/// Calculate a list of jobs that should be executed on CI.
@@ -155,10 +176,19 @@ enum Args {
155176
#[clap(long = "type", default_value = "auto")]
156177
job_type: JobType,
157178
},
158-
/// Postprocess the metrics.json file generated by bootstrap.
179+
/// Postprocess the metrics.json file generated by bootstrap and output
180+
/// various statistics.
181+
/// If `--parent` and `--job-name` are provided, also display a diff
182+
/// against previous metrics that are downloaded from CI.
159183
PostprocessMetrics {
160184
/// Path to the metrics.json file
161185
metrics_path: PathBuf,
186+
/// A parent SHA against which to compare.
187+
#[clap(long, requires("job_name"))]
188+
parent: Option<String>,
189+
/// The name of the current job.
190+
#[clap(long, requires("parent"))]
191+
job_name: Option<String>,
162192
},
163193
/// Upload CI metrics to Datadog.
164194
UploadBuildMetrics {
@@ -209,9 +239,8 @@ fn main() -> anyhow::Result<()> {
209239
Args::UploadBuildMetrics { cpu_usage_csv } => {
210240
upload_ci_metrics(&cpu_usage_csv)?;
211241
}
212-
Args::PostprocessMetrics { metrics_path } => {
213-
let metrics = load_metrics(&metrics_path)?;
214-
output_bootstrap_stats(&metrics);
242+
Args::PostprocessMetrics { metrics_path, parent, job_name } => {
243+
postprocess_metrics(metrics_path, parent, job_name)?;
215244
}
216245
Args::PostMergeReport { current, parent } => {
217246
let db = load_db(default_jobs_file)?;

0 commit comments

Comments
 (0)