Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fontc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ fn main() -> Result<(), Box<dyn Error>> {
.add_instructions(&gitcl)?
.add_instructions(&RustcBuilder::all_rustc()?)? // VERGEN_RUSTC_* for `--vv`
.emit()?;
// vergen honours VERGEN_GIT_DESCRIBE as an override but doesn't ask cargo to
// watch it; without this a warm target dir keeps the previous value.
println!("cargo:rerun-if-env-changed=VERGEN_GIT_DESCRIBE");
Ok(())
}
20 changes: 16 additions & 4 deletions fontc_crater/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ struct RunSummary {
#[serde(alias = "input_file")]
input_file_sha: String,
stats: super::ttx_diff_runner::Summary,
/// How many targets skipped the comparison because fontc's output was unchanged.
#[serde(default)]
reused_cached_results: usize,
}

impl RunSummary {
Expand Down Expand Up @@ -170,6 +173,7 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> {
normalizer_path,
source_cache: cache_dir,
results_cache,
reused_cached_results: Default::default(),
};

let began = Utc::now();
Expand All @@ -182,7 +186,12 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> {
let elapsed = elapsed.to_std().unwrap_or_default();
let elapsed = super::human_readable_duration(elapsed);

log::info!("completed {n_targets} targets in {elapsed}");
let reused_cached_results = context
.reused_cached_results
.load(std::sync::atomic::Ordering::Relaxed);
log::info!(
"completed {n_targets} targets in {elapsed} ({reused_cached_results}/{n_targets} results reused from cache)"
);

let summary = super::ttx_diff_runner::Summary::new(&results);
// if nothing has changed we still want to report it, but we don't need to
Expand All @@ -200,6 +209,7 @@ fn run_crater_and_save_results(args: &CiArgs) -> Result<(), Error> {
results_file,
input_file_sha,
stats: summary,
reused_cached_results,
};

prev_runs.push(summary);
Expand Down Expand Up @@ -231,9 +241,8 @@ fn ttx_diff_has_changes(last_run_sha: &str) -> bool {
.arg(last_run_sha)
.output()
.unwrap();
std::str::from_utf8(&output.stdout)
.unwrap()
.contains("ttx_diff/")
let diff = std::str::from_utf8(&output.stdout).unwrap();
diff.contains("ttx_diff/") || diff.contains("otl-normalizer/")
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -394,6 +403,9 @@ fn copy_file_into_dir(file_path: &Path, dir_path: &Path) -> PathBuf {
fn compile_crate_or_die(name: &str) -> PathBuf {
let status = Command::new("cargo")
.args(["build", "-p", name, "--release"])
// prevent fontc from including a git sha in its version in the name table
// this lets us skip work when two fontc builds produce identical output
.env("VERGEN_GIT_DESCRIBE", "VERGEN_IDEMPOTENT_OUTPUT")
.status()
.expect("failed to run cargo build");
if !status.success() {
Expand Down
3 changes: 3 additions & 0 deletions fontc_crater/src/ttx_diff_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{
collections::BTreeMap,
path::{Path, PathBuf},
process::Command,
sync::atomic::{AtomicUsize, Ordering},
};

use crate::{BuildType, Results, RunResult, Target, ci::ResultsCache};
Expand All @@ -19,6 +20,7 @@ pub(super) struct TtxContext {
pub normalizer_path: PathBuf,
pub source_cache: PathBuf,
pub results_cache: ResultsCache,
pub reused_cached_results: AtomicUsize,
}

pub(super) fn run_ttx_diff(ctx: &TtxContext, target: &Target) -> RunResult<DiffOutput, DiffError> {
Expand Down Expand Up @@ -89,6 +91,7 @@ pub(super) fn run_ttx_diff(ctx: &TtxContext, target: &Target) -> RunResult<DiffO
// fontc produced the same font as last time, so last time's result stands
Some(UNCHANGED_EXIT_CODE) => match cached {
Some(cached) => {
ctx.reused_cached_results.fetch_add(1, Ordering::Relaxed);
log::trace!("reused cached result for {target}");
return cached.into_result();
}
Expand Down
1 change: 1 addition & 0 deletions resources/scripts/check_no_println.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ allowlist+=("fea-rs/src/tests/parse.rs")
allowlist+=("otl-normalizer")
allowlist+=("glyphs-reader/build.rs")
allowlist+=("fontdrasil/build.rs")
allowlist+=("fontc/build.rs")
allowlist+=("fontc_crater/src/main.rs")
allowlist+=("fontc_crater/src/ttx_diff_runner.rs")
allowlist+=("fontc_crater/src/ci.rs")
Expand Down
Loading