From 83bc24b48006414b1a48f42f7fba1c3ff716ef86 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 27 Feb 2024 11:35:17 -0500 Subject: [PATCH] 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 --- .github/workflows/ci.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a35d778570c526df29cd92f0bec0f991b22bb29..4e3b6e65fd6e3daf4fff7e4845c1a7b1d6594e7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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}