ci: caching between run in the CI to make building faster (#114)

~~Improve CI runs by adding a caching action. Between each run crates
should be cached to speed up building datahaven binary.~~

## Summary

In the end the real issue was not that we were missing a caching action
but that we were caching too much. We went way over the 10GB limit
imposed by github (we were using 60GB of cache). So the most recent
cache were deleted right away or not cache at all.

The over use of the cache was happening because we were caching twice
sccache folder. Once with the `mozilla-actions/sccache-action` and an
other time with `Swatinem/rust-cache`.

The solution was to keep caching sccache on github with
`mozilla-actions/sccache-action`.

In this PR we also exchange the `Swatinem/rust-cache` action to use the
more standard `actions/cache@v4`. It would avoid in the future unwanted
breaking changes and security issues.

---------

Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
This commit is contained in:
undercover-cactus 2025-07-14 14:48:20 +02:00 committed by GitHub
parent e8970a2b5f
commit 01962656d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 15 deletions

View file

@ -25,21 +25,15 @@ runs:
- name: Show sccache stats
shell: bash
run: sccache --show-stats
- name: Cache cargo + target + sccache
uses: Swatinem/rust-cache@v2
- uses: actions/cache@v4
with:
cache-targets: true
cache-all-crates: true
shared-key: ${{ runner.os }}-${{inputs.cache-key}}-${{ hashFiles('operator/rust-toolchain.toml') }}-${{ hashFiles('operator/Cargo.lock') }}
workspaces: |
operator -> target
cache-on-failure: true
cache-bin: true
cache-directories: |
**/sccache
**/.cargo/registry
**/.cargo/git
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable

View file

@ -1,6 +1,6 @@
# Build Operator: CI for building the operator binary
name: DataHave Operator Rust Tests
name: DataHaven Operator Binary Build
on:
workflow_dispatch: