This is an automated email from the ASF dual-hosted git repository.

hgruszecki pushed a commit to branch improve-cache
in repository https://gitbox.apache.org/repos/asf/iggy.git

commit 698f5bae7772b350365d818fc3ada293ec7e9492
Author: Hubert Gruszecki <[email protected]>
AuthorDate: Thu Jan 15 15:00:50 2026 +0100

    chore(ci): improve sccache cache effectiveness
    
    Add daily date to cache key since GitHub cache is
    immutable and previous key was stuck with first
    run's artifacts.
    
    Separate dev/release profiles to prevent release
    builds from evicting frequently-used debug artifacts.
---
 .github/actions/rust/post-merge/action.yml         |  3 +--
 .github/actions/rust/pre-merge/action.yml          | 20 +++++++++-------
 .../actions/utils/setup-rust-with-cache/action.yml | 28 ++++++++++------------
 .github/workflows/_build_python_wheels.yml         |  1 +
 .github/workflows/_build_rust_artifacts.yml        |  2 ++
 .github/workflows/_publish_rust_crates.yml         |  2 +-
 .github/workflows/publish.yml                      |  2 +-
 7 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/.github/actions/rust/post-merge/action.yml 
b/.github/actions/rust/post-merge/action.yml
index 1255ae469..909facf8e 100644
--- a/.github/actions/rust/post-merge/action.yml
+++ b/.github/actions/rust/post-merge/action.yml
@@ -36,8 +36,7 @@ runs:
     - name: Setup Rust with cache
       uses: ./.github/actions/utils/setup-rust-with-cache
       with:
-        cache-targets: false  # Only cache registry and git deps, not target 
dir (sccache handles that)
-        show-stats: false  # Don't need stats for publishing
+        enabled: "false"  # Post-merge runs infrequently, no need to cache
 
     - name: Validate package
       run: |
diff --git a/.github/actions/rust/pre-merge/action.yml 
b/.github/actions/rust/pre-merge/action.yml
index a857f4739..5995ac766 100644
--- a/.github/actions/rust/pre-merge/action.yml
+++ b/.github/actions/rust/pre-merge/action.yml
@@ -45,7 +45,6 @@ runs:
       uses: ./.github/actions/utils/setup-rust-with-cache
       with:
         cache-targets: false # Only cache registry and git deps, not target 
dir (sccache handles that)
-        show-stats: true
 
     - name: Install tools for specific tasks
       run: |
@@ -125,14 +124,6 @@ runs:
         echo "Test time:  ${test_duration}s ($(date -ud @${test_duration} 
+'%M:%S'))"
         echo "Total time: $((build_duration + test_duration))s ($(date -ud 
@$((build_duration + test_duration)) +'%M:%S'))"
         echo "========================================="
-
-        if command -v sccache &> /dev/null; then
-          echo ""
-          echo "========================================="
-          echo "sccache statistics:"
-          echo "========================================="
-          sccache --show-stats
-        fi
       shell: bash
 
     - name: Backwards compatibility check
@@ -173,3 +164,14 @@ runs:
       if: inputs.task == 'build-macos-aarch64'
       run: cargo build --locked --all-targets
       shell: bash
+
+    - name: Show sccache statistics
+      if: always()
+      run: |
+        if command -v sccache &> /dev/null; then
+          echo "========================================="
+          echo "sccache statistics:"
+          echo "========================================="
+          sccache --show-stats
+        fi
+      shell: bash
diff --git a/.github/actions/utils/setup-rust-with-cache/action.yml 
b/.github/actions/utils/setup-rust-with-cache/action.yml
index 17a5e857a..803dc4f75 100644
--- a/.github/actions/utils/setup-rust-with-cache/action.yml
+++ b/.github/actions/utils/setup-rust-with-cache/action.yml
@@ -25,14 +25,14 @@ inputs:
     description: "Whether to enable caching"
     required: false
     default: "true"
-  show-stats:
-    description: "Whether to show sccache statistics at the end"
-    required: false
-    default: "false"
   cache-targets:
     description: "Whether to cache target directory (passed to rust-cache)"
     required: false
     default: "false"
+  profile:
+    description: "Build profile for cache separation (dev or release)"
+    required: false
+    default: "dev"
 
 runs:
   using: "composite"
@@ -61,6 +61,11 @@ runs:
       with:
         cache-targets: ${{ inputs.cache-targets }}
 
+    - name: Get current date
+      id: date
+      run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
+      shell: bash
+
     - name: Setup sccache cache
       if: inputs.enabled == 'true'
       uses: actions/cache@v4
@@ -69,9 +74,9 @@ runs:
           ~/.cache/sccache
           ~/Library/Caches/sccache
           ~/.local/share/sccache
-        key: sccache-${{ runner.os }}-${{ runner.arch }}-${{ 
hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}
+        key: sccache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.profile 
}}-${{ steps.date.outputs.date }}-${{ hashFiles('**/Cargo.lock', 
'rust-toolchain.toml') }}
         restore-keys: |
-          sccache-${{ runner.os }}-${{ runner.arch }}-
+          sccache-${{ runner.os }}-${{ runner.arch }}-${{ inputs.profile }}-
 
     - name: Install sccache
       if: inputs.enabled == 'true'
@@ -160,7 +165,7 @@ runs:
           mkdir -p "$SCCACHE_DIR"
 
           echo "SCCACHE_DIR=$SCCACHE_DIR" >> $GITHUB_ENV
-          echo "SCCACHE_CACHE_SIZE=5G" >> $GITHUB_ENV
+          echo "SCCACHE_CACHE_SIZE=2G" >> $GITHUB_ENV
           echo "SCCACHE_ERROR_BEHAVIOR=warn" >> $GITHUB_ENV
           echo "SCCACHE_IGNORE_SERVER_IO_ERROR=1" >> $GITHUB_ENV
 
@@ -196,12 +201,3 @@ runs:
           echo "⚠️ sccache not available, continuing without cache"
         fi
       shell: bash
-
-    - name: Show sccache stats on completion
-      if: always() && inputs.enabled == 'true' && inputs.show-stats == 'true'
-      run: |
-        if command -v sccache &> /dev/null; then
-          echo "### Final sccache Statistics ###"
-          sccache --show-stats || true
-        fi
-      shell: bash
diff --git a/.github/workflows/_build_python_wheels.yml 
b/.github/workflows/_build_python_wheels.yml
index 7b2b674c7..3b5e79080 100644
--- a/.github/workflows/_build_python_wheels.yml
+++ b/.github/workflows/_build_python_wheels.yml
@@ -88,6 +88,7 @@ jobs:
         uses: ./.github/actions/utils/setup-rust-with-cache
         with:
           cache-targets: false
+          profile: release
 
       - name: Build wheels
         uses: PyO3/maturin-action@v1
diff --git a/.github/workflows/_build_rust_artifacts.yml 
b/.github/workflows/_build_rust_artifacts.yml
index 14c8e7904..5afb9af1e 100644
--- a/.github/workflows/_build_rust_artifacts.yml
+++ b/.github/workflows/_build_rust_artifacts.yml
@@ -103,6 +103,7 @@ jobs:
         uses: ./.github/actions/utils/setup-rust-with-cache
         with:
           cache-targets: false
+          profile: release
 
       - name: Add Rust target
         run: rustup target add ${{ matrix.target }}
@@ -205,6 +206,7 @@ jobs:
         uses: ./.github/actions/utils/setup-rust-with-cache
         with:
           cache-targets: false
+          profile: release
 
       - name: Add Rust target
         run: rustup target add ${{ matrix.target }}
diff --git a/.github/workflows/_publish_rust_crates.yml 
b/.github/workflows/_publish_rust_crates.yml
index d2e7db074..5b04d92ac 100644
--- a/.github/workflows/_publish_rust_crates.yml
+++ b/.github/workflows/_publish_rust_crates.yml
@@ -98,7 +98,7 @@ jobs:
         uses: ./.github/actions/utils/setup-rust-with-cache
         with:
           cache-targets: false
-          show-stats: false
+          profile: release
 
       - name: Extract versions
         id: versions
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 646955d19..14bb892aa 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -768,7 +768,7 @@ jobs:
         uses: ./.github/actions/utils/setup-rust-with-cache
         with:
           cache-targets: false
-          show-stats: false
+          profile: release
 
       - name: Debug matrix
         run: echo '${{ toJson(matrix) }}'

Reply via email to