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

cargo audit ignored #708

Closed
JonathanWoollett-Light opened this issue Sep 16, 2022 · 7 comments
Closed

cargo audit ignored #708

JonathanWoollett-Light opened this issue Sep 16, 2022 · 7 comments
Assignees
Labels

Comments

@JonathanWoollett-Light
Copy link

JonathanWoollett-Light commented Sep 16, 2022

Describe The Bug

Whenever a step calls cargo audit this step is ignored by cargo make.

Example

[tasks.audit] 
install_crate = "cargo-audit" 
command = "cargo" 
args = ["audit"] 

[tasks.format] 
install_crate = "rustfmt" 
command = "cargo" 
args = ["fmt"] 
dependencies = ["audit"]

produces:

jcawl@ITVB-5CG13416VV MINGW64 ~/Projects/example (master)
$ cargo make --makefile make.toml format
[cargo-make] INFO - cargo make 0.36.0
[cargo-make] INFO - Project: example
[cargo-make] INFO - Build File: make.toml
[cargo-make] INFO - Task: format
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "cargo" "fmt"
[cargo-make] INFO - Build Done in 0.95 seconds.

jcawl@ITVB-5CG13416VV MINGW64 ~/Projects/example (master)
$

skipping cargo audit

To Reproduce

cargo new example
cd example
touch make.toml

printf "\
[tasks.audit] \n\
install_crate = \"cargo-audit\" \n\
command = \"cargo\" \n\
args = [\"audit\"] \n\
\n\
[tasks.format] \n\
install_crate = \"rustfmt\" \n\
command = \"cargo\" \n\
args = [\"fmt\"] \n\
dependencies = [\"audit\"]\n" \
> make.toml

cargo make --makefile make.toml
@sagiegurari
Copy link
Owner

audit is already predefined for you as follows:

[tasks.audit]
description = "Runs audit cargo plugin."
category = "CI"
condition = { env_true = [
  "CARGO_MAKE_CRATE_HAS_DEPENDENCIES",
  "CARGO_MAKE_CRATE_LOCK_FILE_EXISTS",
] }
command = "cargo"
args = ["audit"]

so my guess is that you do'nt have dependencies or you don't have a cargo.lock file.

  1. you do'nt need to redefine existing tasks
  2. you can remove all predefined core tasks if you wish
  3. you can overwrite existing predefined core params, but in your case, you didn't overwrite the condition.

so you have many options here

@JonathanWoollett-Light
Copy link
Author

So cargo audit is being run, just silently?

It seems very unintuitive to do this task without logging it.

I would argue if it is done by default, it should not be done silently. These sort of default tasks should print their output like any user defined task.

@sagiegurari
Copy link
Owner

not run at all since you are probably failing in the condition that i wrote.
all tasks print execution if they execute.

@sagiegurari
Copy link
Owner

a bit on conditions:
https://github.com/sagiegurari/cargo-make#usage-conditions

and how to override tasks:
https://github.com/sagiegurari/cargo-make#usage-extending-tasks

@JonathanWoollett-Light core tasks behave/print/work exactly like your custom ones.

@sagiegurari
Copy link
Owner

@JonathanWoollett-Light did you get answers here?

@JonathanWoollett-Light
Copy link
Author

JonathanWoollett-Light commented Sep 24, 2022

If a task does not meet its preconditions this should be logged, for a task to silently fail (or not run) makes testing very awkward.
An example would be that a CI might fail to run tests due to 1 missing package which might approve a PR without ever checking the conditions.

I would suggest that the evaluation of pre-conditions should be noted (at-least on failure).

did you get answers here?

My understanding is now that cargo audit is a default task which doesn't run due to unmet pre-conditions.

@sagiegurari
Copy link
Owner

@JonathanWoollett-Light i keep being asked to reduce the amount of printouts and than someone fails on something and asks it back. its a bit of a ping pong that i'm trying to see how to best handle.
for this specific issue, i do see i only print it for non ci builds with default log level, if there is a script defined. i can also do it if a command or run_task are defined and you should see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants