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

set rust source/base folder #223

Open
jimkring opened this issue Jan 2, 2025 · 1 comment
Open

set rust source/base folder #223

jimkring opened this issue Jan 2, 2025 · 1 comment

Comments

@jimkring
Copy link

jimkring commented Jan 2, 2025

It would be nice to be able to set the source/base folder used by the Swatinem/rust-cache action.

Background:

I have a tauri project and all the rust code is in a folder named src-tauri
The Swatinem/rust-cache action is complaining that it cannot find a Cargo.toml file in the root folder of my repository. However, I actually have my rust source in a subfolder.

 Error: The process 'C:\Users\runneradmin\.cargo\bin\cargo.exe' failed with exit code 101
    at ExecState._setResult (D:\a\_actions\Swatinem\rust-cache\v2\dist\restore\index.js:9728:25)
    at ExecState.CheckComplete (D:\a\_actions\Swatinem\rust-cache\v2\dist\restore\index.js:9711:18)
    at ChildProcess.<anonymous> (D:\a\_actions\Swatinem\rust-cache\v2\dist\restore\index.js:9605:27)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  commandFailed: {
    command: 'cargo metadata --all-features --format-version 1 --no-deps',
    stderr: 'error: could not find `Cargo.toml` in `D:\\a\\my-repo\\my-repo` or any parent directory\n'
  }

Is there a way to change the root folder that Swatinem/rust-cache uses?

I'm not sure if it will work, but I'm going to give this a try.

        - uses: Swatinem/rust-cache@v2
        with:
          # default: ". -> target"
          workspaces: "src-tauri -> src-tauri/target"

I don't get any errors, so far (just says "... Restoring cache ... No cache found."). It will take me a couple hours to get through my build and try new build to see if it finds a cache hit.

Even if this works, I might request that a new parameter/argument be added to the Swatinem/rust-cache called source_directory that defaults to "." which can be used for pointing to a subfolder. Sometimes, people use monorepos a lot and the probably don't want to have to do things like workspaces: "mono/repo/rust/sub/project/ -> mono/repo/rust/sub/project/target" to get this action to work. They'd probably prefer to simply put:

source_folder: "mono/repo/rust/sub/project/" and have any "workspaces" specified relative to that source_folder (or maybe call it "base_folder").

Thanks for listening...

@MC-XiaoHei
Copy link

I did it with this code:

uses: Swatinem/rust-cache@v2
with:
  workspaces: './src-tauri -> target'

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

No branches or pull requests

2 participants