diff --git a/fontc_crater/src/ci.rs b/fontc_crater/src/ci.rs index 4c8dca91..8fd36a2c 100644 --- a/fontc_crater/src/ci.rs +++ b/fontc_crater/src/ci.rs @@ -35,6 +35,8 @@ struct RunSummary { began: DateTime, finished: DateTime, fontc_rev: String, + #[serde(default)] + pip_freeze_sha: String, results_file: PathBuf, // the name of the file listing targets used by this run. // it is intended that when this list is updated, the filename is changed. @@ -81,11 +83,13 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { let mut prev_runs: Vec = load_json_if_exists_else_default(&summary_file)?; // todo: fontc_repo should be checked out by us, and have a known path let fontc_rev = super::get_git_rev(None).unwrap(); + let pip_freeze_sha = super::pip_freeze_sha(); if let Some(last_run) = prev_runs.last() { if last_run.fontc_rev == fontc_rev && Some(last_run.input_file.as_os_str()) == args.to_run.file_name() + && pip_freeze_sha == last_run.pip_freeze_sha { - log::info!("fontc rev & inputs is unchanged from last run, skipping"); + log::info!("no changes since last run, skipping"); return Ok(()); } } @@ -121,6 +125,7 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { began, finished, fontc_rev, + pip_freeze_sha, results_file: out_file.into(), input_file, stats: summary, diff --git a/fontc_crater/src/main.rs b/fontc_crater/src/main.rs index 7665316d..90b1e422 100644 --- a/fontc_crater/src/main.rs +++ b/fontc_crater/src/main.rs @@ -4,6 +4,7 @@ use std::{ collections::BTreeMap, fmt::Display, path::{Path, PathBuf}, + process::{Command, Stdio}, str::FromStr, sync::atomic::{AtomicUsize, Ordering}, }; @@ -135,6 +136,22 @@ fn get_git_rev(repo_path: Option<&Path>) -> Option { ) } +fn pip_freeze_sha() -> String { + let pipfreeze = Command::new("pip") + .arg("freeze") + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + let sha1sum = Command::new("shasum") + .stdin(Stdio::from(pipfreeze.stdout.unwrap())) + .output() + .expect("shasum should be preinstalled everywhere"); + assert!(sha1sum.status.success()); + std::str::from_utf8(sha1sum.stdout.trim_ascii()) + .expect("shasum output always ascii") + .to_owned() +} + impl Target { pub(crate) fn id(&self) -> TargetId { TargetId {