Azure / Azure/azure-sdk-for-rust
Cache toolchain, dependencies in PR/CI
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 109
Description
Rust builds seem to be taking longer lately, presumably to set up older toolchains the agents may not have since we target older versions by design. But caching certain directories can help a lot. I use the following in nearly all my Rust repos and it makes a significant improvement in build time.
https://github.com/heaths/akv-cli-rs/blob/241c9ccc84be7ba277c5483192ba3f0714215c64/.github/workflows/ci.yml#L36-L45
```yaml
- name: Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
```
Using the right cache key - including the toolchain (version), platform, and a hash of `Cargo.lock` - we can handle all the variations we have.
Contributor guide
Assessment
This issue has not been assessed yet.