From d47eeccca8f1804e648ebbacefff3860c9fb841e Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 10 Jan 2024 15:04:27 -0600 Subject: [PATCH] Only write to rust cache in CI from main branch (#874) Each cache entry is ~1 GB of our allotted 10 GB for the repository which is quite a bit. We're probably losing cache entries all the time since we add an entry per commit per pull request. Saving the cache takes ~3 minutes ([example](https://github.com/astral-sh/puffin/actions/runs/7479909295/job/20358124969)), it's probably just slowing down CI. It's ~25% of our test runtime and ~50% of our clippy runtime. --- .github/workflows/ci.yaml | 4 ++++ .github/workflows/release.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f85f20b0a..8ce128dd6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,6 +37,8 @@ jobs: run: | rustup component add clippy - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Clippy" run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings @@ -65,6 +67,8 @@ jobs: with: tool: cargo-insta - uses: Swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: "Tests (Ubuntu)" if: ${{ matrix.os == 'ubuntu-latest' }} run: cargo insta test --all --all-features --unreferenced reject diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd7127523..b63d3d091 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,6 +96,8 @@ jobs: with: submodules: recursive - uses: swatinem/rust-cache@v2 + with: + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Install cargo-dist run: ${{ matrix.install_dist }} - name: Build artifacts