From e1f41acf542be7f187c12d2c971d7b9979fecaa3 Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Sun, 27 Oct 2024 16:27:52 -0400 Subject: [PATCH] [crater] Actually run gftools mode This will only run gftools mode for fonts using the default recipeProvider. --- fontc_crater/Cargo.toml | 2 +- fontc_crater/src/ci.rs | 44 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/fontc_crater/Cargo.toml b/fontc_crater/Cargo.toml index 79d4b625..0ad25fbe 100644 --- a/fontc_crater/Cargo.toml +++ b/fontc_crater/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" [dependencies] fontc = { version = "0.0.1", path = "../fontc" } -google-fonts-sources = "0.5.0" +google-fonts-sources = "0.5.1" maud = "0.26.0" tidier = "0.5.3" diff --git a/fontc_crater/src/ci.rs b/fontc_crater/src/ci.rs index a93e09e5..4f1e435e 100644 --- a/fontc_crater/src/ci.rs +++ b/fontc_crater/src/ci.rs @@ -18,7 +18,7 @@ use crate::{ args::CiArgs, error::Error, ttx_diff_runner::{DiffError, DiffOutput}, - Results, Target, + BuildType, Results, Target, }; mod html; @@ -176,12 +176,46 @@ fn make_targets(cache_dir: &Path, repos: &[RepoInfo]) -> (Vec, BTreeMap< .expect("source is always in cache dir") .to_path_buf(); repo_list.insert(src_path.clone(), repo.repo_url.clone()); - targets.push(Target { - _config: config_path.to_owned(), - source: src_path, - }) + targets.extend(targets_for_source(&src_path, &config_path, &config)) } } } (targets, repo_list) } + +fn targets_for_source( + src_path: &Path, + config_path: &Path, + config: &Config, +) -> impl Iterator { + let default = Some(Target { + config: config_path.to_owned(), + source: src_path.to_owned(), + build: BuildType::Default, + }); + + let gftools = should_build_in_gftools_mode(src_path, config).then(|| Target { + config: config_path.to_owned(), + source: src_path.to_owned(), + build: BuildType::GfTools, + }); + [default, gftools].into_iter().flatten() +} + +fn should_build_in_gftools_mode(src_path: &Path, config: &Config) -> bool { + // skip noto, which have an implicitly different recipe provider + if src_path + .file_stem() + .and_then(|stem| stem.to_str().map(|s| s.to_lowercase().contains("noto"))) + .unwrap_or(false) + { + return false; + } + + // if there is a recipe provider other than googlefonts, we skip + config + .recipe_provider + .as_ref() + .filter(|provider| *provider != "googlefonts") + .is_none() +}