Adjust Cargo caching in CI (#8494)

This PR adjusts the way we cache Cargo dependencies in CI.

We're trying out
[swatinem/rust-cache](https://github.com/swatinem/rust-cache) to see if
it can improve our caching strategy such that we're able to get more
cache hits on PRs.

We'll only write to the cache on `main` in the hopes that it will
mitigate the amount of thrashing of the cache.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-02-27 11:35:17 -05:00 committed by GitHub
parent 7acd6879db
commit 83bc24b480
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -107,16 +107,10 @@ jobs:
clean: false
submodules: "recursive"
- name: Restore from cache
uses: actions/cache@v4
- name: Cache dependencies
uses: swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: configure linux
shell: bash -euxo pipefail {0}
@ -140,16 +134,10 @@ jobs:
clean: false
submodules: "recursive"
- name: Restore from cache
uses: actions/cache@v4
- name: Cache dependencies
uses: swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: cargo clippy
shell: bash -euxo pipefail {0}