Skip to content

[crater] Rework representation of targets#1564

Merged
cmyr merged 1 commit into
mainfrom
configs-are-truth
Jul 23, 2025
Merged

[crater] Rework representation of targets#1564
cmyr merged 1 commit into
mainfrom
configs-are-truth

Conversation

@cmyr

@cmyr cmyr commented Jul 17, 2025

Copy link
Copy Markdown
Member

This patch is kind of doing a bunch of stuff and I apologize for getting it all tied up together.

I. Preamble

Crater, like much software, was accreted more than it was designed. This has started to pose challanges.

The main problem is that historically we were only concerned with font source files; repositories and config files were just a way for us to discover sources.

Later on, we started to also care about config files, so that we could do gftools builds; but this work brought in a bunch of assumptions about where config files could be found, and how they related to sources.

II. This Commit

  • The main purpose of this commit is to move us from being focused on sources to being focused on configs. We will only build something if we have a config, and for a given config we will only build a source that is named by that config.

  • In addition to that, this commit tries to generally be more consistent about how we construct paths, and how we report errors if we cannot compile a given target.

  • Finally, this commit adds preliminary support for 'virtual configs', which occur when we want to provide a config file for a repository that we do not otherwise want to (or are unable to) modify. These config files live in the google/fonts repository.

    More work will be required before we can actually build these virtual configs, but at least now we understand that they exist.

@anthrotype

Copy link
Copy Markdown
Member

We will only build something if we have a config...

are there font source repositories without any configs in which we were previously discovering and building some sources whereas now we will no longer? Or is that covered by the 'virtual configs'?

@cmyr cmyr force-pushed the configs-are-truth branch from 972e479 to 2a6e5a9 Compare July 18, 2025 13:55
@cmyr

cmyr commented Jul 18, 2025

Copy link
Copy Markdown
Member Author

No, previously we would rely on configs to find sources, but we would then forget about them.

Comment thread fontc_crater/src/ci.rs Outdated
.expect("config path always in sources dir");
// config is always in sources, sources is always in org/repo
let repo_dir = relative_config_path.parent().unwrap().parent().unwrap();
// we map repos to URLS in a special sources.json file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand what "special" is trying to tell me? I wonder if we could describe what is in sources.json (or point to the description) more directly? - it's not entirely clear to me from this what I'm going to find there

Comment thread fontc_crater/src/ci.rs
// config is always in sources, sources is always in org/repo
let repo_dir = relative_config_path.parent().unwrap().parent().unwrap();
// we map repos to URLS in a special sources.json file
let repo_dir = repo.repo_path(Path::new(""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would read nicer without Path::new, could we modify repo_path to allow &str input?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could, but it isn't defined in this crate so would be a bit of a hassle.

Comment thread fontc_crater/src/ci.rs Outdated
.insert(repo_dir.to_owned(), repo.repo_url.clone());
.insert(repo_dir.clone(), repo.repo_url.clone());

let sources_dir = if repo.config_is_virtual() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"virtual" for a file that exists feels a touch off to me. Might "external" or even out_of_repo or some siuch, aiming to convey that the config doesn't live in this repo (but does live somewhere!) convey the concept more clearly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config_in_repo seems like it would work? If the config is not in the repo { do something else } type of deal.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This method is also not defined here, we're just calling it.
  2. I'm not sure I understand, are you proposing a new method called config_in_repo?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, this commit adds preliminary support for 'virtual configs', which occur when we want to provide a config file for a repository that we do not otherwise want to (or are unable to) modify. These config files live in the google/fonts repository.

To me this sounds like a config_override.

Comment thread fontc_crater/src/target.rs Outdated
pub(crate) struct Target {
/// path to the source dir for this target (relative to the git cache root)
source_dir: PathBuf,
/// path to the source repo, from the cache dir root

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "relative to cache root" instead of "from..."

///
/// - From the cache root if it is virtual;
/// - From the repo root otherwise
pub(crate) config: PathBuf,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly suggest "relative to..." instead of "from", clearer to at least this reader and consistent with how source is described below.

Comment thread fontc_crater/src/target.rs Outdated
}
}
impl Target {
pub(crate) fn new2(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is new2 temporary? If not perhaps we could use names that convey something? The purpose or when it shoudl be used or some such?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops yes this was leftover from earlier in the refactor, when I hadn't removed the previous constructor.

///
/// $ORG/$REPO/$CONFIG_PATH?$SHA $SRC_PATH ($BUILD_TYPE)
///
/// where a virtual config's $CONFIG_PATH starts with the literal path element

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find EXTERNAL or OUT_OF_REPO or similar more informative than VIRTUAL, virtual makes me think you synthesized it, not that it exists somewhere else.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if this is a serious concern I'll need to go and make a separate PR + release in google_fonts_sources, which is where I first picked this terminology. Would you prefer that?

@rsheeter rsheeter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM subject to "virtual" changing, that term leads me (and I suspect others) to assume things that are entirely wrong

@cmyr cmyr force-pushed the configs-are-truth branch from 2a6e5a9 to 8a615f9 Compare July 22, 2025 18:34
This patch is kind of doing a bunch of stuff and I apologize for getting
it all tied up together.

I. Preamble

Crater, like much software, was accreted more than it was
designed. This has started to pose challanges.

The main problem is that historically we were only concerned with font
source files; repositories and config files were just a way for us to
discover sources.

Later on, we started to also care about config files, so that we could
do gftools builds; but this work brought in a bunch of assumptions about
where config files could be found, and how they related to sources.

II. This Commit

- The main purpose of this commit is to move us from being focused on
  sources to being focused on configs. We will only build something if we
  have a config, and for a given config we will only build a source that
  is named by that config.

- In addition to that, this commit tries to generally be more consistent
  about how we construct paths, and how we report errors if we cannot
  compile a given target.

- Finally, this commit adds preliminary support for 'virtual configs',
  which occur when we want to provide a config file for a repository
  that we do not otherwise want to (or are unable to) modify. These
  config files live in the google/fonts repository.

  More work will be required before we can actually build these virtual
  configs, but at least now we understand that they exist.
@cmyr cmyr force-pushed the configs-are-truth branch from 8a615f9 to bb45a1a Compare July 23, 2025 14:25
@cmyr cmyr added this pull request to the merge queue Jul 23, 2025
Merged via the queue into main with commit 9ee3e14 Jul 23, 2025
12 checks passed
@cmyr cmyr deleted the configs-are-truth branch July 23, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants