-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: Re-run dependent tasks in watch mode #7898
Merged
NicholasLYang
merged 4 commits into
nicholasyang/watch-mode
from
nicholasyang/watch-walker
Apr 18, 2024
+208
−86
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,11 @@ pub struct RunBuilder { | |
experimental_ui: bool, | ||
api_client: APIClient, | ||
analytics_sender: Option<AnalyticsSender>, | ||
// In watch mode, we can have a changed package that we want to serve as an entrypoint. | ||
// We will then prune away any tasks that do not depend on tasks inside | ||
// this package. | ||
entrypoint_package: Option<PackageName>, | ||
should_print_prelude_override: Option<bool>, | ||
} | ||
|
||
impl RunBuilder { | ||
|
@@ -98,6 +103,7 @@ impl RunBuilder { | |
(!cfg!(windows) || experimental_ui), | ||
); | ||
let CommandBase { repo_root, ui, .. } = base; | ||
|
||
Ok(Self { | ||
processes, | ||
opts, | ||
|
@@ -108,9 +114,21 @@ impl RunBuilder { | |
version, | ||
experimental_ui, | ||
analytics_sender: None, | ||
entrypoint_package: None, | ||
should_print_prelude_override: None, | ||
}) | ||
} | ||
|
||
pub fn with_entrypoint_package(mut self, entrypoint_package: PackageName) -> Self { | ||
self.entrypoint_package = Some(entrypoint_package); | ||
self | ||
} | ||
|
||
pub fn hide_prelude(mut self) -> Self { | ||
self.should_print_prelude_override = Some(false); | ||
self | ||
} | ||
|
||
fn connect_process_manager(&self, signal_subscriber: SignalSubscriber) { | ||
let manager = self.processes.clone(); | ||
tokio::spawn(async move { | ||
|
@@ -377,6 +395,10 @@ impl RunBuilder { | |
self.opts.run_opts.env_mode = EnvMode::Strict; | ||
} | ||
|
||
let should_print_prelude = self.should_print_prelude_override.unwrap_or_else(|| { | ||
self.opts.run_opts.dry_run.is_none() && self.opts.run_opts.graph.is_none() | ||
}); | ||
|
||
Ok(Run { | ||
version: self.version, | ||
ui: self.ui, | ||
|
@@ -397,6 +419,7 @@ impl RunBuilder { | |
engine: Arc::new(engine), | ||
run_cache, | ||
signal_handler: signal_handler.clone(), | ||
should_print_prelude, | ||
}) | ||
} | ||
|
||
|
@@ -406,7 +429,7 @@ impl RunBuilder { | |
root_turbo_json: &TurboJson, | ||
filtered_pkgs: &HashSet<PackageName>, | ||
) -> Result<Engine, Error> { | ||
let engine = EngineBuilder::new( | ||
let mut engine = EngineBuilder::new( | ||
&self.repo_root, | ||
pkg_dep_graph, | ||
self.opts.run_opts.single_package, | ||
|
@@ -425,6 +448,12 @@ impl RunBuilder { | |
})) | ||
.build()?; | ||
|
||
// If we have an initial task, we prune out the engine to only | ||
// tasks that are reachable from that initial task. | ||
if let Some(entrypoint_package) = &self.entrypoint_package { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will eventually need to be a set of packages, especially with debouncing and waiting for current runs to finish being cancelled or completed |
||
engine = engine.create_engine_for_subgraph(entrypoint_package); | ||
} | ||
|
||
if !self.opts.run_opts.parallel { | ||
engine | ||
.validate( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I added this because the prelude makes less sense with re-run tasks. It prints the packages in scope, but the tasks in those packages are not always run, since the task graph is pruned.