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

Workspace Makefile inheritance in members (CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true) not working #1207

Open
tgrushka opened this issue Dec 30, 2024 · 1 comment
Assignees
Labels

Comments

@tgrushka
Copy link

tgrushka commented Dec 30, 2024

Describe The Bug

I am very confused by the README/docs on how to even achieve this.

Relative to workspace:
/Makefile.toml:

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true

[tasks.workspacetask]
script = ["echo hello from workspace"]

/Cargo.toml:

[workspace]
resolver = "3"
members = [
    "member1"
]

/member1/Makefile.toml:

[tasks.membertask]
script = ["echo hello from member"]
cd member1
cargo make workspacetask
...
Task "workspacetask" not found
exit code 404

Confusing docs:

This allows you to maintaining a single makefile for the entire workspace but having access to those custom tasks in every member crate.

Right. Exactly what I want.

This is only relevant for workspace builds which are triggered in the workspace root.
Flows that start directly in the member crate, must manually extend the workspace level makefile using the extend keyword.

Huh? You just said I could access the workspace-level tasks inside members, and then said they have to start in the workspace root? "using the extend keyword" -- how??

To Reproduce

Try above example.

Error Stack

Task "workspacetask" not found
exit code 404

What I'm trying to do

I want to have a common task, e.g. coverage (no, couldn't override that one either, I want Tarpaulin with HTML, not XML, and in each member, not in the root, so had to set:

[config]
skip_core_tasks = true

to even get overriding that to work, else I got a Invalid task: coverage, contains multiple actions error -- different issue, but aggravates the frustration:

# [config]
# without: skip_core_tasks = true

[tasks.coverage]
command = "echo"
args = ["hello"]
cargo make coverage
[cargo-make] INFO - cargo make 0.37.23
[cargo-make] INFO - 
[cargo-make] INFO - Project: api
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: coverage
[cargo-make] INFO - Profile: development
[cargo-make] ERROR - Invalid task: coverage, contains multiple actions.
Task {
    clear: None,
    description: Some(
        "Runs coverage (by default using kcov).",
    ),
...

So I want a [tasks.coverage] in my workspace Makefile.toml that will just run the coverage relative to whatever member crate I'm in, only, without having to re-create that task in every Makefile.toml in every member.

CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true (without or with quotes around "true") has no effect.

What am I doing wrong? Can the docs be made more clear on this?

@sagiegurari
Copy link
Owner

CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE works when you start the build on the workspace dir.
it will run all builds for all members and all members 'see/use' also the workspace level makefile (with member level extension automatically done).

or if you want to run a single member from member dir, than you have to add the extends.
it is documented:
https://github.com/sagiegurari/cargo-make?tab=readme-ov-file#usage-workspace-extending-external-makefile

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