From e8e5d2d5ecebf19947d918b2acb46d129d46476d Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Fri, 22 May 2026 10:53:10 -0700 Subject: [PATCH] ci: seed shared Rust caches from main Signed-off-by: Piotr Mlocek --- .github/workflows/branch-checks.yml | 3 +- .github/workflows/rust-cache-seed.yml | 72 +++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/rust-cache-seed.yml diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 54084fddd..d8045f773 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -109,8 +109,7 @@ jobs: # Separate caches for clippy (check-like) vs test (full build) # so they don't thrash each other's artifacts shared-key: rust-checks-${{ matrix.runner }} - # Cache the sccache directory too - cache-directories: .cache/sccache + cache-on-failure: true - name: Format run: mise run rust:format:check diff --git a/.github/workflows/rust-cache-seed.yml b/.github/workflows/rust-cache-seed.yml new file mode 100644 index 000000000..3b369c611 --- /dev/null +++ b/.github/workflows/rust-cache-seed.yml @@ -0,0 +1,72 @@ +name: Rust Cache Seed + +on: + push: + branches: + - main + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: "0" + MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SCCACHE_GHA_ENABLED: "true" + +permissions: + contents: read + packages: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + rust: + name: Rust (${{ matrix.runner }}) + strategy: + fail-fast: false + matrix: + runner: [linux-amd64-cpu8, linux-arm64-cpu8] + runs-on: ${{ matrix.runner }} + env: + SCCACHE_GHA_VERSION: branch-checks-rust-${{ matrix.runner }} + container: + image: ghcr.io/nvidia/openshell/ci:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: Install tools + run: mise install --locked + + - name: Configure GHA sccache backend + uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 + + - name: Cache Rust target and registry + uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + with: + shared-key: rust-checks-${{ matrix.runner }} + cache-on-failure: true + + - name: Format + run: mise run rust:format:check + + - name: Lint + run: mise run rust:lint + + - name: Test + run: mise run test:rust + + - name: sccache stats + if: always() + run: | + set +e + stats_bin="${SCCACHE_PATH:-sccache}" + "$stats_bin" --show-stats + status=$? + if [ "$status" -ne 0 ]; then + echo "::warning::sccache stats unavailable (exit $status)" + fi + exit 0