From 008a90defe130bfc500c8b1d3a55b73f40d97d36 Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 4 Nov 2024 03:22:50 +0400 Subject: [PATCH 01/13] tasks: reverse task order --- devenv-tasks/src/lib.rs | 59 ++++++++++++++++++++++++++++++++++++++--- package.nix | 2 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index 8774a477c..d31d9e81c 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -434,7 +434,7 @@ impl Tasks { for dep_name in &task_state.task.after { if let Some(dep_idx) = task_indices.get(dep_name) { - edges_to_add.push((*dep_idx, index)); + edges_to_add.push((index, *dep_idx)); } else { unresolved.insert((task_state.task.name.clone(), dep_name.clone())); } @@ -442,7 +442,7 @@ impl Tasks { for before_name in &task_state.task.before { if let Some(before_idx) = task_indices.get(before_name) { - edges_to_add.push((index, *before_idx)); + edges_to_add.push((*before_idx, index)); } else { unresolved.insert((task_state.task.name.clone(), before_name.clone())); } @@ -450,7 +450,7 @@ impl Tasks { } for (dep_idx, idx) in edges_to_add { - self.graph.add_edge(dep_idx, idx, ()); + self.graph.add_edge(idx, dep_idx, ()); } if unresolved.is_empty() { @@ -493,7 +493,7 @@ impl Tasks { for edge in self.graph.edges(old_node) { let target = edge.target(); if let Some(&new_target) = node_map.get(&target) { - subgraph.add_edge(new_node, new_target, ()); + subgraph.add_edge(new_target, new_node, ()); } } } @@ -1196,6 +1196,57 @@ mod test { Ok(()) } + #[tokio::test] + async fn test_enter_shell_tasks() -> Result<(), Error> { + let script1 = create_script( + "#!/bin/sh\necho 'Task 1 is running' && sleep 0.5 && echo 'Task 1 completed'", + )?; + let script2 = create_script( + "#!/bin/sh\necho 'Task 2 is running' && sleep 0.5 && echo 'Task 2 completed'", + )?; + let script3 = create_script( + "#!/bin/sh\necho 'Task 3 is running' && sleep 0.5 && echo 'Task 3 completed'", + )?; + + let tasks = Tasks::new( + Config::try_from(json!({ + "roots": ["devenv:enterShell"], + "tasks": [ + { + "name": "devenv:enterShell", + "command": script1.to_str().unwrap(), + }, + { + "name": "devenv:python:poetry", + "before": ["devenv:enterShell"], + "command": script2.to_str().unwrap() + }, + { + "name": "app:custom", + "before": ["devenv:python:poetry"], + "command": script3.to_str().unwrap() + } + ] + })) + .unwrap(), + ) + .await?; + tasks.run().await; + + let task_statuses = inspect_tasks(&tasks).await; + let task_statuses = task_statuses.as_slice(); + assert_matches!( + task_statuses, + [ + (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) + // ] if name1 == "app:custom" && name2 == "devenv:python:poetry" && name3 == "devenv:enterShell" + ] if name1 == "devenv:enterShell" && name2 == "devenv:python:poetry" && name3 == "app:custom" + ); + Ok(()) + } + #[tokio::test] async fn test_dependency_failure() -> Result<(), Error> { let failing_script = create_script("#!/bin/sh\necho 'Failing task' && exit 1")?; diff --git a/package.nix b/package.nix index 2909442a1..6f6ca6216 100644 --- a/package.nix +++ b/package.nix @@ -22,7 +22,7 @@ pkgs.rustPlatform.buildRustPackage { then [ "-p devenv-tasks" ] else [ "-p devenv -p devenv-run-tests" ]; - doCheck = !build_tasks; + doCheck = false; #!build_tasks; cargoLock = { lockFile = ./Cargo.lock; From 82a83cc976d93b0cc8d5e4587bd79a1aa77c4e7e Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 5 Nov 2024 17:08:00 +0400 Subject: [PATCH 02/13] tasks: fix graph traversal --- devenv-tasks/src/lib.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index d31d9e81c..11671dd70 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -434,7 +434,7 @@ impl Tasks { for dep_name in &task_state.task.after { if let Some(dep_idx) = task_indices.get(dep_name) { - edges_to_add.push((index, *dep_idx)); + edges_to_add.push((*dep_idx, index)); } else { unresolved.insert((task_state.task.name.clone(), dep_name.clone())); } @@ -442,15 +442,15 @@ impl Tasks { for before_name in &task_state.task.before { if let Some(before_idx) = task_indices.get(before_name) { - edges_to_add.push((*before_idx, index)); + edges_to_add.push((index, *before_idx)); } else { unresolved.insert((task_state.task.name.clone(), before_name.clone())); } } } - for (dep_idx, idx) in edges_to_add { - self.graph.add_edge(idx, dep_idx, ()); + for (from, to) in edges_to_add { + self.graph.update_edge(from, to, ()); } if unresolved.is_empty() { @@ -479,10 +479,7 @@ impl Tasks { node_map.insert(node, new_node); // Add dependencies to visit - for neighbor in self - .graph - .neighbors_directed(node, petgraph::Direction::Incoming) - { + for neighbor in self.graph.neighbors_undirected(node) { to_visit.push(neighbor); } } @@ -493,7 +490,7 @@ impl Tasks { for edge in self.graph.edges(old_node) { let target = edge.target(); if let Some(&new_target) = node_map.get(&target) { - subgraph.add_edge(new_target, new_node, ()); + subgraph.add_edge(new_node, new_target, ()); } } } From 8754c8d270250b065e37a0628606db313d04e61e Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 5 Nov 2024 17:45:22 +0400 Subject: [PATCH 03/13] nix: re-enable tests --- package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.nix b/package.nix index 6f6ca6216..2909442a1 100644 --- a/package.nix +++ b/package.nix @@ -22,7 +22,7 @@ pkgs.rustPlatform.buildRustPackage { then [ "-p devenv-tasks" ] else [ "-p devenv -p devenv-run-tests" ]; - doCheck = false; #!build_tasks; + doCheck = !build_tasks; cargoLock = { lockFile = ./Cargo.lock; From 140b2dc6af3fda08830eee4d292c098f6ca4711a Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 5 Nov 2024 17:45:43 +0400 Subject: [PATCH 04/13] python: update task ordering spec --- src/modules/languages/python.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 9c6aef053..71bfbb447 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -459,25 +459,24 @@ in description = "Initialize Python virtual environment"; exec = initVenvScript; exports = [ "PATH" "VIRTUAL_ENV" ]; + after = [ "devenv:enterShell" ]; }; "devenv:python:poetry" = lib.mkIf cfg.poetry.install.enable { description = "Initialize Poetry"; exec = initPoetryScript; exports = [ "PATH" ] ++ lib.optional cfg.poetry.activate.enable "VIRTUAL_ENV"; - after = lib.optional cfg.venv.enable "devenv:python:virtualenv"; + after = [ "devenv:enterShell" ]; + before = lib.optional cfg.venv.enable "devenv:python:virtualenv"; }; "devenv:python:uv" = lib.mkIf cfg.uv.sync.enable { description = "Initialize uv sync"; exec = initUvScript; exports = [ "PATH" ]; - after = lib.optional cfg.venv.enable "devenv:python:virtualenv"; + after = [ "devenv:enterShell" ]; + before = lib.optional cfg.venv.enable "devenv:python:virtualenv"; }; - - "devenv:enterShell".after = lib.optional cfg.venv.enable "devenv:python:virtualenv" - ++ lib.optional cfg.poetry.install.enable "devenv:python:poetry" - ++ lib.optional cfg.uv.sync.enable "devenv:python:uv"; }; enterShell = '' From ae5540ed6e2948cedab813d4c50f03c9c630d534 Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 5 Nov 2024 18:17:31 +0400 Subject: [PATCH 05/13] tasks: add before and after test --- devenv-tasks/src/lib.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index 11671dd70..1d4f0b8ac 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -1194,7 +1194,7 @@ mod test { } #[tokio::test] - async fn test_enter_shell_tasks() -> Result<(), Error> { + async fn test_before_and_after_tasks() -> Result<(), Error> { let script1 = create_script( "#!/bin/sh\necho 'Task 1 is running' && sleep 0.5 && echo 'Task 1 completed'", )?; @@ -1207,22 +1207,23 @@ mod test { let tasks = Tasks::new( Config::try_from(json!({ - "roots": ["devenv:enterShell"], + "roots": ["myapp:task_1"], "tasks": [ { - "name": "devenv:enterShell", + "name": "myapp:task_1", "command": script1.to_str().unwrap(), }, { - "name": "devenv:python:poetry", - "before": ["devenv:enterShell"], - "command": script2.to_str().unwrap() + "name": "myapp:task_3", + "after": ["myapp:task_1"], + "command": script3.to_str().unwrap() }, { - "name": "app:custom", - "before": ["devenv:python:poetry"], - "command": script3.to_str().unwrap() - } + "name": "myapp:task_2", + "before": ["myapp:task_3"], + "after": ["myapp:task_1"], + "command": script2.to_str().unwrap() + }, ] })) .unwrap(), @@ -1238,8 +1239,7 @@ mod test { (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) - // ] if name1 == "app:custom" && name2 == "devenv:python:poetry" && name3 == "devenv:enterShell" - ] if name1 == "devenv:enterShell" && name2 == "devenv:python:poetry" && name3 == "app:custom" + ] if name1 == "myapp:task_1" && name2 == "myapp:task_2" && name3 == "myapp:task_3" ); Ok(()) } From 81a6c5558539624b46aa21ebddb18b318048ea7d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:15:47 +0000 Subject: [PATCH 06/13] Auto generate docs/reference/options.md --- docs/reference/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/options.md b/docs/reference/options.md index 69cd0b76a..a10955d57 100644 --- a/docs/reference/options.md +++ b/docs/reference/options.md @@ -492,7 +492,7 @@ list of string -Whether to include the Flutter tools. +Whether to include the React Native tools. From e24baa3ac4732aab140ff5d0c87319cbe0e8cf43 Mon Sep 17 00:00:00 2001 From: sander Date: Sat, 23 Nov 2024 03:54:34 +0400 Subject: [PATCH 07/13] lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Domen Kožar --- devenv-tasks/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index 1d4f0b8ac..d6c1773be 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -1215,7 +1215,7 @@ mod test { }, { "name": "myapp:task_3", - "after": ["myapp:task_1"], + "after": ["myapp:task_1"], "command": script3.to_str().unwrap() }, { From 25268a176b2f7e24cbe074a75046944d8fe16335 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 04:15:18 +0400 Subject: [PATCH 08/13] python: fix order of tasks vs enterShell --- src/modules/languages/python.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 71bfbb447..55a6bf629 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -459,23 +459,23 @@ in description = "Initialize Python virtual environment"; exec = initVenvScript; exports = [ "PATH" "VIRTUAL_ENV" ]; - after = [ "devenv:enterShell" ]; + before = [ "devenv:enterShell" ]; }; "devenv:python:poetry" = lib.mkIf cfg.poetry.install.enable { description = "Initialize Poetry"; exec = initPoetryScript; exports = [ "PATH" ] ++ lib.optional cfg.poetry.activate.enable "VIRTUAL_ENV"; - after = [ "devenv:enterShell" ]; - before = lib.optional cfg.venv.enable "devenv:python:virtualenv"; + before = [ "devenv:enterShell" ] + ++ lib.optional cfg.venv.enable "devenv:python:virtualenv"; }; "devenv:python:uv" = lib.mkIf cfg.uv.sync.enable { description = "Initialize uv sync"; exec = initUvScript; exports = [ "PATH" ]; - after = [ "devenv:enterShell" ]; - before = lib.optional cfg.venv.enable "devenv:python:virtualenv"; + before = [ "devenv:enterShell" ] + ++ lib.optional cfg.venv.enable "devenv:python:virtualenv"; }; }; From 4726277afa9ed2514735f8c9ac9f3de0294d9edd Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 04:15:50 +0400 Subject: [PATCH 09/13] git-hooks: update task order setup --- src/modules/integrations/git-hooks.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/integrations/git-hooks.nix b/src/modules/integrations/git-hooks.nix index ab9a7a41f..ed974afc0 100644 --- a/src/modules/integrations/git-hooks.nix +++ b/src/modules/integrations/git-hooks.nix @@ -34,10 +34,14 @@ in packages = lib.mkAfter ([ config.git-hooks.package ] ++ (config.git-hooks.enabledPackages or [ ])); tasks = { # TODO: split installation script into status + exec - "devenv:git-hooks:install".exec = config.git-hooks.installationScript; - "devenv:git-hooks:run".exec = "pre-commit run -a"; - "devenv:enterShell".after = [ "devenv:git-hooks:install" ]; - "devenv:enterTest".after = [ "devenv:git-hooks:run" ]; + "devenv:git-hooks:install" = { + exec = config.git-hooks.installationScript; + before = [ "devenv:enterShell" ]; + }; + "devenv:git-hooks:run" = { + exec = "pre-commit run -a"; + before = [ "devenv:enterShell" ]; + }; }; }; } From bc2b55d2241704221f87d05b67449f59a74f5f5f Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 19:12:26 +0400 Subject: [PATCH 10/13] tasks: add more dependency tests --- devenv-tasks/src/lib.rs | 125 +++++++++++++++++++++++++++++++++------- 1 file changed, 103 insertions(+), 22 deletions(-) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index d6c1773be..0fe023b9c 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -1145,15 +1145,9 @@ mod test { #[tokio::test] async fn test_before_tasks() -> Result<(), Error> { - let script1 = create_script( - "#!/bin/sh\necho 'Task 1 is running' && sleep 0.5 && echo 'Task 1 completed'", - )?; - let script2 = create_script( - "#!/bin/sh\necho 'Task 2 is running' && sleep 0.5 && echo 'Task 2 completed'", - )?; - let script3 = create_script( - "#!/bin/sh\necho 'Task 3 is running' && sleep 0.5 && echo 'Task 3 completed'", - )?; + let script1 = create_basic_script("1")?; + let script2 = create_basic_script("2")?; + let script3 = create_basic_script("3")?; let tasks = Tasks::new( Config::try_from(json!({ @@ -1162,7 +1156,7 @@ mod test { { "name": "myapp:task_1", "command": script1.to_str().unwrap(), - "after": ["myapp:task_3"] + "before": ["myapp:task_2", "myapp:task_3"] }, { "name": "myapp:task_2", @@ -1188,22 +1182,60 @@ mod test { (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) - ] if name1 == "myapp:task_2" && name2 == "myapp:task_3" && name3 == "myapp:task_1" + ] if name1 == "myapp:task_1" && name2 == "myapp:task_2" && name3 == "myapp:task_3" + ); + Ok(()) + } + + #[tokio::test] + async fn test_after_tasks() -> Result<(), Error> { + let script1 = create_basic_script("1")?; + let script2 = create_basic_script("2")?; + let script3 = create_basic_script("3")?; + + let tasks = Tasks::new( + Config::try_from(json!({ + "roots": ["myapp:task_1"], + "tasks": [ + { + "name": "myapp:task_1", + "command": script1.to_str().unwrap(), + "after": ["myapp:task_3", "myapp:task_2"] + }, + { + "name": "myapp:task_2", + "after": ["myapp:task_3"], + "command": script2.to_str().unwrap() + }, + { + "name": "myapp:task_3", + "command": script3.to_str().unwrap() + } + ] + })) + .unwrap(), + ) + .await?; + tasks.run().await; + + let task_statuses = inspect_tasks(&tasks).await; + let task_statuses = task_statuses.as_slice(); + assert_matches!( + task_statuses, + [ + (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) + ] if name1 == "myapp:task_3" && name2 == "myapp:task_2" && name3 == "myapp:task_1" ); Ok(()) } #[tokio::test] async fn test_before_and_after_tasks() -> Result<(), Error> { - let script1 = create_script( - "#!/bin/sh\necho 'Task 1 is running' && sleep 0.5 && echo 'Task 1 completed'", - )?; - let script2 = create_script( - "#!/bin/sh\necho 'Task 2 is running' && sleep 0.5 && echo 'Task 2 completed'", - )?; - let script3 = create_script( - "#!/bin/sh\necho 'Task 3 is running' && sleep 0.5 && echo 'Task 3 completed'", - )?; + let script1 = create_basic_script("1")?; + let script2 = create_basic_script("2")?; + let script3 = create_basic_script("3")?; let tasks = Tasks::new( Config::try_from(json!({ @@ -1244,6 +1276,51 @@ mod test { Ok(()) } + // Test that tasks indirectly linked to the root are picked up and run. + #[tokio::test] + async fn test_transitive_dependencies() -> Result<(), Error> { + let script1 = create_basic_script("1")?; + let script2 = create_basic_script("2")?; + let script3 = create_basic_script("3")?; + + let tasks = Tasks::new( + Config::try_from(json!({ + "roots": ["myapp:task_3"], + "tasks": [ + { + "name": "myapp:task_1", + "command": script1.to_str().unwrap(), + }, + { + "name": "myapp:task_2", + "after": ["myapp:task_1"], + "command": script2.to_str().unwrap() + }, + { + "name": "myapp:task_3", + "after": ["myapp:task_2"], + "command": script3.to_str().unwrap() + }, + ] + })) + .unwrap(), + ) + .await?; + tasks.run().await; + + let task_statuses = inspect_tasks(&tasks).await; + let task_statuses = task_statuses.as_slice(); + assert_matches!( + task_statuses, + [ + (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) + ] if name1 == "myapp:task_1" && name2 == "myapp:task_2" && name3 == "myapp:task_3" + ); + Ok(()) + } + #[tokio::test] async fn test_dependency_failure() -> Result<(), Error> { let failing_script = create_script("#!/bin/sh\necho 'Failing task' && exit 1")?; @@ -1405,7 +1482,6 @@ fi Ok(()) } - #[cfg(test)] async fn inspect_tasks(tasks: &Tasks) -> Vec<(String, TaskStatus)> { let mut result = Vec::new(); for index in &tasks.tasks_order { @@ -1415,7 +1491,6 @@ fi result } - #[cfg(test)] fn create_script(script: &str) -> std::io::Result { let mut temp_file = tempfile::Builder::new() .prefix("script") @@ -1427,4 +1502,10 @@ fi .set_permissions(fs::Permissions::from_mode(0o755))?; Ok(temp_file.into_temp_path()) } + + fn create_basic_script(tag: &str) -> std::io::Result { + create_script(&format!( + "#!/bin/sh\necho 'Task {tag} is running' && sleep 0.1 && echo 'Task {tag} completed'" + )) + } } From 6de413bc307a8a38a746660e307bc58f1d890207 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 19:34:37 +0400 Subject: [PATCH 11/13] tasks: add test for ordering around a root --- devenv-tasks/src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/devenv-tasks/src/lib.rs b/devenv-tasks/src/lib.rs index 0fe023b9c..758bef63f 100644 --- a/devenv-tasks/src/lib.rs +++ b/devenv-tasks/src/lib.rs @@ -1321,6 +1321,51 @@ mod test { Ok(()) } + // Ensure that tasks before and after a root are run in the correct order. + #[tokio::test] + async fn test_non_root_before_and_after() -> Result<(), Error> { + let script1 = create_basic_script("1")?; + let script2 = create_basic_script("2")?; + let script3 = create_basic_script("3")?; + + let tasks = Tasks::new( + Config::try_from(json!({ + "roots": ["myapp:task_2"], + "tasks": [ + { + "name": "myapp:task_1", + "command": script1.to_str().unwrap(), + "before": [ "myapp:task_2"] + }, + { + "name": "myapp:task_2", + "command": script2.to_str().unwrap() + }, + { + "name": "myapp:task_3", + "after": ["myapp:task_2"], + "command": script3.to_str().unwrap() + }, + ] + })) + .unwrap(), + ) + .await?; + tasks.run().await; + + let task_statuses = inspect_tasks(&tasks).await; + let task_statuses = task_statuses.as_slice(); + assert_matches!( + task_statuses, + [ + (name1, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name2, TaskStatus::Completed(TaskCompleted::Success(_, _))), + (name3, TaskStatus::Completed(TaskCompleted::Success(_, _))) + ] if name1 == "myapp:task_1" && name2 == "myapp:task_2" && name3 == "myapp:task_3" + ); + Ok(()) + } + #[tokio::test] async fn test_dependency_failure() -> Result<(), Error> { let failing_script = create_script("#!/bin/sh\necho 'Failing task' && exit 1")?; From a6481c661a6f54e7dbd4b7408d96af9207b30726 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 20:09:27 +0400 Subject: [PATCH 12/13] git-hooks: run before tests, not shell --- src/modules/integrations/git-hooks.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/integrations/git-hooks.nix b/src/modules/integrations/git-hooks.nix index ed974afc0..4df4cdebf 100644 --- a/src/modules/integrations/git-hooks.nix +++ b/src/modules/integrations/git-hooks.nix @@ -40,7 +40,7 @@ in }; "devenv:git-hooks:run" = { exec = "pre-commit run -a"; - before = [ "devenv:enterShell" ]; + before = [ "devenv:enterTest" ]; }; }; }; From 0b6d9eee3f4933e4850f798fc98c4ab36f359109 Mon Sep 17 00:00:00 2001 From: Sander Date: Sat, 23 Nov 2024 20:13:35 +0400 Subject: [PATCH 13/13] tests: adjust task test --- tests/tasks/devenv.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/tasks/devenv.nix b/tests/tasks/devenv.nix index 9d0877dd5..6574deb89 100644 --- a/tests/tasks/devenv.nix +++ b/tests/tasks/devenv.nix @@ -1,9 +1,16 @@ { tasks = { - "myapp:shell".exec = "touch shell"; - "devenv:enterShell".after = [ "myapp:shell" ]; - "myapp:test".exec = "touch test"; + "myapp:shell" = { + exec = "touch shell"; + before = [ "devenv:enterShell" ]; + }; + + "myapp:test" = { + exec = "touch test"; + }; + # Test specifying "after" "devenv:enterTest".after = [ "myapp:test" ]; + "example:statusIgnored" = { before = [ "devenv:enterTest" ]; exec = "touch ./should-not-exist";