From 7a21e12d45b51b3fe83d9bfc1892787657ff3bc9 Mon Sep 17 00:00:00 2001 From: StreamKit Devin Date: Sat, 25 Apr 2026 14:54:56 +0000 Subject: [PATCH] ci: cache sccache local disk via actions/cache for hosted runners MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore and save ~/.cache/sccache as a single GHA cache entry per Cargo.lock revision. This gives hosted runners compilation-level cache hits without the per-artifact entry explosion caused by SCCACHE_GHA_ENABLED (reverted in #373). Strategy: - actions/cache/restore before sccache-action starts (all hosted jobs) - actions/cache/save at end of job, main-branch only (if: always()) - Self-hosted GPU jobs skipped — they already have persistent disk cache - Plugins use a separate cache key prefix (sccache-plugins-*) Closes #374 Signed-off-by: StreamKit Devin Co-Authored-By: Claudio Costa --- .github/workflows/e2e.yml | 30 +++++++++++++++++ .github/workflows/marketplace-build.yml | 15 +++++++++ .github/workflows/plugins.yml | 15 +++++++++ .github/workflows/release.yml | 15 +++++++++ .github/workflows/skit.yml | 45 +++++++++++++++++++++++++ 5 files changed, 120 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 0987785d..f3ed7ceb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -45,6 +45,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -94,6 +102,13 @@ jobs: cd tests/pipeline-validation PIPELINE_TEST_URL=http://127.0.0.1:4545 cargo test --test validate + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + pipeline-validation-gpu: name: Pipeline Validation (GPU) # Skip for fork PRs — self-hosted runners must not execute untrusted code. @@ -238,6 +253,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -330,3 +353,10 @@ jobs: name: playwright-results path: e2e/test-results/ retention-days: 7 + + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} diff --git a/.github/workflows/marketplace-build.yml b/.github/workflows/marketplace-build.yml index f1fd74c4..4f9f8994 100644 --- a/.github/workflows/marketplace-build.yml +++ b/.github/workflows/marketplace-build.yml @@ -107,6 +107,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-plugins-${{ runner.os }}-${{ hashFiles('plugins/**/Cargo.lock') }} + restore-keys: | + sccache-plugins-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - name: Verify official plugins metadata is current @@ -195,6 +203,13 @@ jobs: name: marketplace-registry path: dist/registry/** + - name: Save sccache cache + if: always() + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-plugins-${{ runner.os }}-${{ hashFiles('plugins/**/Cargo.lock') }} + publish-registry: name: Publish Registry (PR) needs: [build-marketplace] diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index b5310699..9b78cd16 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -162,6 +162,14 @@ jobs: toolchain: "1.92.0" components: rustfmt, clippy + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-plugins-${{ runner.os }}-${{ hashFiles('plugins/**/Cargo.lock') }} + restore-keys: | + sccache-plugins-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - name: Build workspace list for cache @@ -226,3 +234,10 @@ jobs: (cd "plugins/native/${plugin}" && CARGO_TARGET_DIR="${{ github.workspace }}/target/plugins" cargo test) echo "::endgroup::" done + + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-plugins-${{ runner.os }}-${{ hashFiles('plugins/**/Cargo.lock') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e8e9a5e..6f843e79 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,6 +53,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -104,6 +112,13 @@ jobs: VERSION="${{ steps.version.outputs.version }}" sha256sum streamkit-${VERSION}-linux-x64.tar.gz > streamkit-${VERSION}-linux-x64.tar.gz.sha256 + - name: Save sccache cache + if: always() + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/skit.yml b/.github/workflows/skit.yml index 2deaddae..031c271e 100644 --- a/.github/workflows/skit.yml +++ b/.github/workflows/skit.yml @@ -46,6 +46,14 @@ jobs: toolchain: "1.92.0" components: rustfmt, clippy + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -72,6 +80,13 @@ jobs: - name: Check advisories run: cargo deny check advisories + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + test: name: Test runs-on: ubuntu-22.04 @@ -108,6 +123,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -122,6 +145,13 @@ jobs: cargo test --locked -p streamkit-server --features "moq" cargo test --locked -p streamkit-server --features "mcp" + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + test-gpu: name: Test (GPU) # Skip for fork PRs — self-hosted runners must not execute untrusted code. @@ -208,6 +238,14 @@ jobs: with: toolchain: "1.92.0" + - name: Restore sccache cache + uses: actions/cache/restore@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + sccache-${{ runner.os }}- + - uses: mozilla-actions/sccache-action@v0.0.9 - uses: Swatinem/rust-cache@v2 @@ -221,3 +259,10 @@ jobs: cargo build --locked --workspace --release cargo build --locked -p streamkit-server --bin skit --release --features "moq" cargo build --locked -p streamkit-client --bin skit-cli --release + + - name: Save sccache cache + if: always() && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: ~/.cache/sccache + key: sccache-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}