1818 # incremental dirs add nothing but bloat the cached target/ directory and
1919 # slow the cache upload/download.
2020 CARGO_INCREMENTAL : " 0"
21- # sccache uses this when the server starts. Set it at workflow scope so the
22- # probe step can actually start the server with the GitHub Actions backend.
23- SCCACHE_GHA_ENABLED : " true"
2421 # vcpkg binary caching for Windows. The x-gha backend was removed from vcpkg,
2522 # so use vcpkg's files provider and persist that directory with actions/cache.
2623 VCPKG_GIT_COMMIT : fb87e2bb3fe69e16c224989acb5a61349166c782
@@ -137,25 +134,6 @@ jobs:
137134 if : matrix.name == 'macos-x64'
138135 run : rustup target add x86_64-apple-darwin
139136
140- # ---------- sccache experiment for Windows Rust builds ----------
141- - name : Setup sccache (Windows only)
142- if : runner.os == 'Windows'
143- uses : mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
144-
145- - name : Enable sccache wrapping (Windows only)
146- id : sccache
147- if : runner.os == 'Windows'
148- shell : bash
149- run : |
150- if sccache --start-server >/dev/null 2>&1; then
151- echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
152- echo "enabled=true" >> "$GITHUB_OUTPUT"
153- echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
154- else
155- echo "enabled=false" >> "$GITHUB_OUTPUT"
156- echo "::warning::sccache backend unreachable; building without compile cache this run"
157- fi
158-
159137 # ---------- Cache Cargo ----------
160138 # The Rust FFI is built from the pinned client-sdk-rust submodule. Its
161139 # compiled output only changes when the submodule commit changes, so we
@@ -201,11 +179,6 @@ jobs:
201179 LLVM_VERSION=$(llvm-config --version | cut -d. -f1)
202180 echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> "$GITHUB_ENV"
203181
204- - name : Reset sccache stats (Windows only)
205- if : runner.os == 'Windows' && steps.sccache.outputs.enabled == 'true'
206- shell : bash
207- run : sccache --zero-stats
208-
209182 # ---------- Build ----------
210183 - name : Build (Unix)
211184 if : runner.os != 'Windows'
@@ -219,18 +192,12 @@ jobs:
219192 shell : pwsh
220193 run : ${{ matrix.build_cmd }}
221194
222- - name : Show sccache stats (Windows only)
223- if : always() && runner.os == 'Windows'
224- shell : bash
225- run : sccache --show-stats
226-
227195 # Save the populated target/ now, while the build output still exists and
228- # before the "Clean after build" step runs clean-all. Only on a miss --
229- # an exact-key hit means the cache already holds this submodule's output.
230- # A restore-keys prefix hit still counts as a miss (cache-hit != 'true'),
231- # so a submodule bump always refreshes the cache under the new SHA.
196+ # before the "Clean after build" step runs clean-all. Save only from main
197+ # pushes so PRs restore from the shared main cache instead of creating
198+ # large PR-scoped target caches that quickly evict useful entries.
232199 - name : Save cargo target
233- if : steps.cache-cargo-target.outputs.cache-hit != 'true'
200+ if : github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.cache-cargo-target.outputs.cache-hit != 'true'
234201 uses : actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
235202 with :
236203 path : client-sdk-rust/target/
0 commit comments