Skip to content
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

--skip-init-end-tasks doesn't seem to work #1108

Closed
06393993 opened this issue Jul 7, 2024 · 6 comments · Fixed by #1109
Closed

--skip-init-end-tasks doesn't seem to work #1108

06393993 opened this issue Jul 7, 2024 · 6 comments · Fixed by #1109
Assignees
Labels

Comments

@06393993
Copy link
Contributor

06393993 commented Jul 7, 2024

Describe The Bug

With tasks.init defined, even if we call cargo make --skip-init-end-tasks empty, the init task will be called.

I am not sure if I am understanding the --skip-init-end-tasks argument incorrectly, or there is a bug. If it's a misunderstanding, I believe we should change the documentation for the --skip-init-end-tasks argument: "If set, init and end tasks are skipped". If it's a bug, we need a fix.

To Reproduce

On Linux with bash:

cargo init hello-world && cd hello-world && echo "tasks.init.script = \"echo init\"" > Makefile.toml && cargo make --skip-init-end-tasks empty

The actual output is:

$ cargo init hello-world && cd hello-world && echo "tasks.init.script = \"echo init\"" > Makefile.toml && cargo make --skip-init-end-tasks empty
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[cargo-make] INFO - cargo make 0.37.13
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: hello-world
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: empty
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
init
[cargo-make] INFO - Build Done in 0.28 seconds.

I guess we are not supposed to see the "Running Task: init" log and the "init" echo?

Error Stack

N/A

Code Sample

tasks.init.script = "echo init"

This problem is important to me, as I plan to use the init task to add "-D warning" to the RUSTFLAGS environement variable for the CI environment. However, ff --skip-init-end-tasks doesn't work, the init task will be run another time when a new cargo-make process is forked due to tasks.<task_id>.run_task.fork being true. As a result, 2 duplicate "-D warnings" will be added to RUSTFLAGS, and cause recompilation.

EDIT: move the --skip-init-end-tasks argument before the empty target in To Reproduce section, and update the output.

@sagiegurari
Copy link
Owner

instead of
cargo make empty --skip-init-end-tasks
do
cargo make --skip-init-end-tasks empty

@06393993
Copy link
Contributor Author

06393993 commented Jul 7, 2024

instead of cargo make empty --skip-init-end-tasks do cargo make --skip-init-end-tasks empty

The same:

$ cargo init hello-world && cd hello-world && echo "tasks.init.script = \"echo init\"" > Makefile.toml && cargo make --skip-init-end-tasks empty
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[cargo-make] INFO - cargo make 0.37.13
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: hello-world
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: empty
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
init
[cargo-make] INFO - Build Done in 0.28 seconds.

@06393993
Copy link
Contributor Author

06393993 commented Jul 7, 2024

A hacky patch works:

~/src/cargo-make$ git diff
diff --git a/src/lib/runner.rs b/src/lib/runner.rs
index c774314a..0f3d5d12 100755
--- a/src/lib/runner.rs
+++ b/src/lib/runner.rs
@@ -629,6 +629,14 @@ pub(crate) fn run(
         },
         None => None,
     };
+    let config = if cli_args.skip_init_end_tasks {
+        let mut config = config;
+        config.config.init_task = None;
+        config.config.end_task = None;
+        config
+    } else {
+        config
+    };
 
     let flow_info = FlowInfo {
         config,
~/src/cargo-make$ cargo run --bin makers -- --makefile /tmp/hello-world/Makefile.toml empty
   Compiling cargo-make v0.37.13 (/home/user/src/cargo-make)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.09s
     Running `target/debug/makers --makefile /tmp/hello-world/Makefile.toml empty`
[cargo-make] INFO - makers 0.37.13
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: cargo-make
[cargo-make] INFO - Build File: /tmp/hello-world/Makefile.toml
[cargo-make] INFO - Task: empty
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: init
init
[cargo-make] INFO - Build Done in 0.50 seconds.
~/src/cargo-make$ cargo run --bin makers -- --makefile /tmp/hello-world/Makefile.toml --skip-init-end-tasks empty
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/makers --makefile /tmp/hello-world/Makefile.toml --skip-init-end-tasks empty`
[cargo-make] INFO - makers 0.37.13
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: cargo-make
[cargo-make] INFO - Build File: /tmp/hello-world/Makefile.toml
[cargo-make] INFO - Task: empty
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Build Done in 0.57 seconds.

@sagiegurari
Copy link
Owner

hmmm... seems like a bug. i'll check it out.

@sagiegurari sagiegurari added bug and removed question labels Jul 7, 2024
@06393993
Copy link
Contributor Author

06393993 commented Jul 7, 2024

In case you miss it, I have uploaded a PR(#1109) to fix this issue. PTAL.

@sagiegurari
Copy link
Owner

thanks and sorry for the delay

06393993 added a commit to 06393993/vk-layer-for-rust that referenced this issue Aug 15, 2024
... since cargo-make 0.37.14 fixes the sagiegurari/cargo-make#1108 issue.
06393993 added a commit to google/vk-layer-for-rust that referenced this issue Aug 16, 2024
... since cargo-make 0.37.14 fixes the sagiegurari/cargo-make#1108 issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants