diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index bb2d478fc..77e84cdcd 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -109,8 +109,6 @@ jobs: # Keep branch-check caches partitioned by runner architecture; lint # and test intentionally share the same job-local target directory. shared-key: rust-checks-${{ matrix.runner }} - # Cache the sccache directory too - cache-directories: .cache/sccache # Preserve compiled artifacts from failed lint/test runs so the next # push to the same PR branch does not start from a cold cache. cache-on-failure: "true" 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