From fd471aef6e14749967612c0ed6fe30ee50e05893 Mon Sep 17 00:00:00 2001 From: Gilver Date: Sun, 22 Feb 2026 19:29:11 -0600 Subject: [PATCH] fix: sccache setup and toggle (#10028) (#10043) * fix: Try and fix sccache toggle...again Signed-off-by: Gilver * Beep Signed-off-by: Gilver * Revert "Beep" This reverts commit 34ee5aa7fa12bc99c567df1ca3ba6590853cfbb6. * ? Signed-off-by: Gilver * chore: sccache path Signed-off-by: Gilver * chore: Add back if Signed-off-by: Gilver * The Success * fix: Reminder to disable autoformatting on Kate again * feat: sccache summary back Signed-off-by: Gilver --------- Signed-off-by: Gilver (cherry picked from commit d2e74d4b377fd85a43fe6c0592e1f10e3a00fc6b) Signed-off-by: GildedRoach # Conflicts: # .github/workflows/json-build.yml --- .github/scripts/configure-sccache.js | 10 ++++++++- .github/workflows/json-build.yml | 31 ++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/.github/scripts/configure-sccache.js b/.github/scripts/configure-sccache.js index 53da0201ca..bd450d0118 100644 --- a/.github/scripts/configure-sccache.js +++ b/.github/scripts/configure-sccache.js @@ -6,7 +6,7 @@ // Note: ACTIONS_CACHE_SERVICE_V2 and SCCACHE_GHA_ENABLED are set at workflow level module.exports = async ({ github, context, core, exec }) => { // Find sccache path (try which command) - let sccachePath = "sccache"; + let sccachePath = "/usr/bin/sccache"; try { const result = await exec.getExecOutput("which", ["sccache"], { ignoreReturnCode: true, @@ -31,6 +31,13 @@ module.exports = async ({ github, context, core, exec }) => { core.warning(`Could not get sccache version: ${e.message}`); } + // Enable caching + core.exportVariable("RUSTC_WRAPPER", sccachePath); + core.exportVariable("SCCACHE_GHA_ENABLED", "true"); + + // Disable Cargo incremental builds to not interfere with caching + core.exportVariable("CARGO_INCREMENTAL", "false"); + // Debug: Show what environment variables are available core.info("=== Environment Variables Diagnostic ==="); core.info(`SCCACHE_GHA_ENABLED: ${process.env.SCCACHE_GHA_ENABLED}`); @@ -106,6 +113,7 @@ module.exports = async ({ github, context, core, exec }) => { } if (bustCache) { + core.exportVariable("SCCACHE_BUST_CACHE", "true"); core.exportVariable("SCCACHE_RECACHE", "1"); core.info("SCCACHE_RECACHE enabled because bust_cache is true"); } diff --git a/.github/workflows/json-build.yml b/.github/workflows/json-build.yml index f7e069a33a..b99d124afe 100644 --- a/.github/workflows/json-build.yml +++ b/.github/workflows/json-build.yml @@ -55,6 +55,18 @@ jobs: - name: Set up git repository run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Configure sccache + id: sccache + if: ${{ !contains(matrix.pkg.labels.sccache, '0') }} + uses: actions/github-script@v8 + env: + SCCACHE_GHA_VERSION: ${{ matrix.version }}-${{ matrix.pkg.arch }}-${{ matrix.pkg.pkg }} + SCCACHE_GHA_CACHE_FROM: ${{ matrix.version }}-${{ matrix.pkg.arch }}-${{ matrix.pkg.pkg }} + with: + script: | + const script = require('./.github/scripts/configure-sccache.js') + await script({github, context, core, exec}) + - name: CI Setup Script if: ${{ !contains(matrix.pkg.labels, 'mock') }} run: | @@ -69,20 +81,17 @@ jobs: dir=$(dirname ${{ matrix.pkg.pkg }}) dnf5 builddep -y ${dir}/*.spec - - name: Configure sccache - if: matrix.pkg.labels['sccache'] != '0' - run: | - set -euo pipefail - echo "RUSTC_WRAPPER=/usr/bin/sccache" >> $GITHUB_ENV - echo "CARGO_INCREMENTAL=false" >> $GITHUB_ENV - echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV - if [ "${{ inputs.bust_cache }}" = "true" ]; then - echo "SCCACHE_BUST_CACHE=true" >> $GITHUB_ENV - fi - - name: Build with Andaman run: anda build -D "vendor Terra" -D "__python %{__python3}" ${{ matrix.pkg.pkg }} -c terra-${{ matrix.version }}-${{ matrix.pkg.arch }} ${{ !matrix.pkg.labels.mock == '1' && '-rrpmbuild' || '' }} + - name: Report Cache Summary + if: steps.sccache.outcome == 'success' + uses: actions/github-script@v8 + with: + script: | + const script = require('./.github/scripts/sccache-stats.js') + await script({github, context, core, exec}) + - name: Generating artifact name id: art run: |