-
Notifications
You must be signed in to change notification settings - Fork 14k
bootstrap: Replace Step::DEFAULT and default_condition with is_default_step
#148987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Ignoring the new snapshot tests, the actual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great cleanup! To go further, I think that we could eventually rethink/rename all the important Step functions (not in this PR).
Something like:
should_run => `define_cli_paths`
is_default_step => `should_run_by_default`, `should_run_with_no_path` or just `is_default`
make_run => `run_from_cli`
I would suggest making fn is_default_step { true } the default implementation. IMO everything should be enabled by default, so that we don't miss steps by accident, and only specific steps should return false. This reduces then need to think about the right default impl for the is_default_step function. Most/more of the impls in this PR return true anyway.
| fn check_if_tidy_is_installed(builder: &Builder<'_>) -> bool { | ||
| command("tidy").allow_failure().arg("--version").run_capture_stdout(builder).is_success() | ||
| *builder.html_tidy_is_available_memo.get_or_init(|| { | ||
| command("tidy").allow_failure().arg("--version").run_capture_stdout(builder).is_success() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than caching this in the builder, you can just make the command cached (.cached()). That's IMO much simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching the command output is a bit less powerful, since it doesn't cache the subsequent processing steps.
But if running the command repeatedly is the thing we're worried about, then that's fine.
Ideally I would want to not perform these probes here at all, and instead require opt-in config for these tools. But that's well beyond the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I think that even without any caching it would be fine. But if anything, I'd expect the command invocation to take more time than the processing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally I would want to not perform these probes here at all, and instead require opt-in config for these tools. But that's well beyond the scope of this PR.
This is also my preference (if I were to redesign this setup from scratch), but I can appreciate it being annoying for existing usages.
I've written some of my thoughts about this on Zulip, since it's a bit of a pain to have an actual discussion on GitHub. |
|
Holding off on reviewing this to wait for the discussion to settle down first. |
|
☔ The latest upstream changes (presumably #148763) made this pull request unmergeable. Please resolve the merge conflicts. |
Step::is_really_defaultfromStep::should_run#148965One of the confusing things about bootstrap's
Step::should_runis that it combines two loosely-related but non-overlapping responsibilities:./x test compiler, this allows bootstrap to know what steps “compiler” should translate intoDEFAULT = trueshould actually run or not, when no paths/aliases are explicitly specified./x test, this allows bootstrap to know which steps to run by defaultThis PR therefore splits out the latter of those responsibilities into a dedicated
is_default_stepassociated function, which also replaces the existingDEFAULTassociated constant.A small number of steps were using
ShouldRun::lazy_default_conditionto specify a condition that should not be run repeatedly if possible, e.g. because it queries external tools. Those steps now perform memoization via fields inBuilderinstead.r? jieyouxu