Skip to content

Commit

Permalink
gate task execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Olszewski authored and nicholaslyang committed Oct 4, 2023
1 parent daf0111 commit 5b327f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ impl<'a> Run<'a> {
true,
self.processes.clone(),
&self.base.repo_root,
);
)
.dry_run();

visitor.visit(engine.clone()).await?;
let task_hash_tracker = visitor.into_task_hash_tracker();
Expand Down
11 changes: 11 additions & 0 deletions crates/turborepo-lib/src/task_graph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct Visitor<'a> {
ui: UI,
manager: ProcessManager,
repo_root: &'a AbsoluteSystemPath,
dry: bool,
}

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -101,6 +102,7 @@ impl<'a> Visitor<'a> {
ui,
manager,
repo_root,
dry: false,
}
}

Expand Down Expand Up @@ -180,6 +182,10 @@ impl<'a> Visitor<'a> {
)?;

debug!("task {} hash is {}", info, task_hash);
if self.dry {
callback.send(Ok(())).ok();
continue;
}

let task_cache =
self.run_cache
Expand Down Expand Up @@ -387,6 +393,11 @@ impl<'a> Visitor<'a> {
pub fn into_task_hash_tracker(self) -> TaskHashTrackerState {
self.task_hasher.into_task_hash_tracker_state()
}

pub fn dry_run(mut self) -> Self {
self.dry = true;
self
}
}

// A tiny enum that allows us to use the same type for stdout and stderr without
Expand Down

0 comments on commit 5b327f7

Please sign in to comment.