From d89e4ce6ed3dab04c8b4eb7724b5964f67722420 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 16 Apr 2024 06:30:14 +0200 Subject: [PATCH 1/4] fix: use project root directory instead of task.working_directory for base dir when hashing --- src/cli/run.rs | 2 +- src/task/task_hash.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli/run.rs b/src/cli/run.rs index 1931bb518..2d48ba0b8 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -150,7 +150,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { { CanSkip::No(cache) => cache, CanSkip::Yes => { - eprintln!("Task can be skipped (cache hit) 🚀"); + eprintln!("Task \"{}\" can be skipped (cache hit) 🚀", executable_task.name().unwrap_or("")); task_idx += 1; continue; } diff --git a/src/task/task_hash.rs b/src/task/task_hash.rs index ad470fa8d..a28235713 100644 --- a/src/task/task_hash.rs +++ b/src/task/task_hash.rs @@ -132,7 +132,7 @@ impl InputHashes { return Ok(None); }; - let files = FileHashes::from_files(&task.working_directory()?, inputs.iter()).await?; + let files = FileHashes::from_files(&task.project().root(), inputs.iter()).await?; Ok(Some(Self { files })) } } @@ -150,7 +150,7 @@ impl OutputHashes { return Ok(None); }; - let files = FileHashes::from_files(&task.working_directory()?, outputs.iter()).await?; + let files = FileHashes::from_files(&task.project().root(), outputs.iter()).await?; Ok(Some(Self { files })) } } From a1aef992b32760df45bf3c8a27e4b526384b63b1 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 16 Apr 2024 08:42:39 +0200 Subject: [PATCH 2/4] fmt --- src/cli/run.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/run.rs b/src/cli/run.rs index 2d48ba0b8..2d1cfb054 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -150,7 +150,10 @@ pub async fn execute(args: Args) -> miette::Result<()> { { CanSkip::No(cache) => cache, CanSkip::Yes => { - eprintln!("Task \"{}\" can be skipped (cache hit) 🚀", executable_task.name().unwrap_or("")); + eprintln!( + "Task \"{}\" can be skipped (cache hit) 🚀", + executable_task.name().unwrap_or("") + ); task_idx += 1; continue; } From f0d690dde61dd971e60c93323779d77ab112c686 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 16 Apr 2024 08:47:00 +0200 Subject: [PATCH 3/4] format and make print a little nicer --- src/cli/run.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli/run.rs b/src/cli/run.rs index 2d1cfb054..ab3d5c7db 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -151,8 +151,8 @@ pub async fn execute(args: Args) -> miette::Result<()> { CanSkip::No(cache) => cache, CanSkip::Yes => { eprintln!( - "Task \"{}\" can be skipped (cache hit) 🚀", - executable_task.name().unwrap_or("") + "Task '{}' can be skipped (cache hit) 🚀", + console::style(executable_task.name().unwrap_or("")).bold() ); task_idx += 1; continue; From b2d79a695f7f0c3b8a16920c6b717c3d497ecf46 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 16 Apr 2024 09:34:37 +0200 Subject: [PATCH 4/4] improve logging --- src/cli/run.rs | 5 ++++- src/task/task_hash.rs | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/cli/run.rs b/src/cli/run.rs index ab3d5c7db..3d96f0bf6 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -129,9 +129,12 @@ pub async fn execute(args: Args) -> miette::Result<()> { eprintln!(); } eprintln!( - "{}{}{}{}{}", + "{}{}{} in {}{}{}", console::Emoji("✨ ", ""), console::style("Pixi task (").bold(), + console::style(executable_task.name().unwrap_or("unnamed")) + .green() + .bold(), executable_task .run_environment .name() diff --git a/src/task/task_hash.rs b/src/task/task_hash.rs index a28235713..7f4691355 100644 --- a/src/task/task_hash.rs +++ b/src/task/task_hash.rs @@ -86,7 +86,7 @@ impl TaskHash { lock_file: &LockFile, ) -> Result, InputHashesError> { let input_hashes = InputHashes::from_task(task).await?; - let output_hashes = OutputHashes::from_task(task).await?; + let output_hashes = OutputHashes::from_task(task, false).await?; if input_hashes.is_none() && output_hashes.is_none() { return Ok(None); @@ -104,7 +104,7 @@ impl TaskHash { &mut self, task: &ExecutableTask<'_>, ) -> Result<(), InputHashesError> { - self.outputs = OutputHashes::from_task(task).await?; + self.outputs = OutputHashes::from_task(task, true).await?; Ok(()) } @@ -132,7 +132,20 @@ impl InputHashes { return Ok(None); }; - let files = FileHashes::from_files(&task.project().root(), inputs.iter()).await?; + let files = FileHashes::from_files(task.project().root(), inputs.iter()).await?; + + // check if any files were matched + if files.files.is_empty() { + tracing::warn!( + "No files matched the input globs for task '{}'", + task.name().unwrap_or_default() + ); + tracing::warn!( + "Input globs: {:?}", + inputs.iter().map(|g| g.as_str()).collect::>() + ); + } + Ok(Some(Self { files })) } } @@ -144,13 +157,30 @@ pub struct OutputHashes { } impl OutputHashes { - /// Compute the input hashes from a task. - pub async fn from_task(task: &ExecutableTask<'_>) -> Result, InputHashesError> { + /// Compute the output hashes from a task. + pub async fn from_task( + task: &ExecutableTask<'_>, + warn: bool, + ) -> Result, InputHashesError> { let Some(ref outputs) = task.task().as_execute().and_then(|e| e.outputs.clone()) else { return Ok(None); }; - let files = FileHashes::from_files(&task.project().root(), outputs.iter()).await?; + let files = FileHashes::from_files(task.project().root(), outputs.iter()).await?; + + // check if any files were matched + if warn && files.files.is_empty() { + tracing::warn!( + "No files matched the output globs for task` '{}'", + task.name().unwrap_or_default() + ); + tracing::warn!( + "Output globs: {:?}", + outputs.iter().map(|g| g.as_str()).collect::>() + ); + return Ok(None); + } + Ok(Some(Self { files })) } }