cargo icon indicating copy to clipboard operation
cargo copied to clipboard

Cache target directory between runs

Open sebschmi opened this issue 5 years ago • 3 comments
trafficstars

Motivation

Building a Rust project takes a lot of time if many dependencies are involved. In my case I have >2 minutes build time, of which only a few seconds are from my own crates. This could be greatly reduced by caching the target directory with the dependency cache.

Workflow example

steps:
  - name: Cargo check
    uses: actions-rs/cargo@v2
    with:
      command: check
      use-cache: true # cache the target directory between runs

Additional context

The action is actions/cache.

There is an example on how to use it for the .cargo directory. Employing that example prevents cargo from redownloading all the crates on every run, but it still recompiles them.

sebschmi avatar Aug 20 '20 09:08 sebschmi

Hi, cache not work in my workflow either, what's the status of this issue? Does the use-cache config in the example above work now?

huangjj27 avatar May 16 '21 05:05 huangjj27

Adding myself to the list of interested users.

I found this repository while looking for a simple way to add caching to my crate's CI. I would absolutely adopt this action if caching were implemented.

PoignardAzur avatar Aug 18 '21 18:08 PoignardAzur

For folks looking for a solution, there is: https://github.com/Swatinem/rust-cache

PiDelport avatar Mar 04 '22 17:03 PiDelport