diff --git a/fontc_crater/src/ci.rs b/fontc_crater/src/ci.rs index ad6dc5b4..f3096692 100644 --- a/fontc_crater/src/ci.rs +++ b/fontc_crater/src/ci.rs @@ -44,7 +44,8 @@ struct RunSummary { 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. - input_file: PathBuf, + #[serde(alias = "input_file")] + input_file_sha: String, stats: super::ttx_diff_runner::Summary, } @@ -84,15 +85,18 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { } log_if_auth_or_not(); + // do this now so we error if the input file doesn't exist + let inputs: Vec = super::try_read_json(&args.to_run)?; let summary_file = args.out_dir.join(SUMMARY_FILE); 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(); + let input_file_sha = super::get_input_sha(&args.to_run); 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() + && input_file_sha == last_run.input_file_sha && pip_freeze_sha == last_run.pip_freeze_sha { log::info!("no changes since last run, skipping"); @@ -100,8 +104,6 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { } } - let inputs: Vec = super::try_read_json(&args.to_run)?; - let out_file = result_path_for_current_date(); let out_path = args.out_dir.join(&out_file); // for now we are going to be cloning each repo freshly @@ -146,11 +148,6 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { log::info!("output identical to last run, skipping"); return Ok(()); } - let input_file = args - .to_run - .file_name() - .map(PathBuf::from) - .unwrap_or_else(|| args.to_run.clone()); let summary = RunSummary { began, @@ -158,7 +155,7 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> { fontc_rev, pip_freeze_sha, results_file: out_file.into(), - input_file, + input_file_sha, stats: summary, }; diff --git a/fontc_crater/src/main.rs b/fontc_crater/src/main.rs index af93583f..5f275f89 100644 --- a/fontc_crater/src/main.rs +++ b/fontc_crater/src/main.rs @@ -130,6 +130,17 @@ fn pip_freeze_sha() -> String { .to_owned() } +fn get_input_sha(path: &Path) -> String { + let output = Command::new("shasum") + .arg(path) + .output() + .expect("shasum should be installed everywhere"); + std::str::from_utf8(&output.stdout) + .expect("shasum output always ascii") + .trim() + .to_owned() +} + impl FromIterator<(Target, RunResult)> for Results { fn from_iter)>>(iter: I) -> Self { let mut out = Results::default();