@@ -36,6 +36,11 @@ permissions:
3636
3737env :
3838 CARGO_TERM_COLOR : always
39+ # sccache caches rustc invocations across runs. RUSTC_WRAPPER is exported
40+ # only after the setup step verifies the GHA cache backend is reachable, so
41+ # transient cache backend failures fall back to uncached rustc instead of
42+ # failing the build.
43+ SCCACHE_GHA_ENABLED : " true"
3944 # vcpkg binary caching for Windows (mirrors builds.yml)
4045 VCPKG_DEFAULT_TRIPLET : x64-windows-static-md
4146 VCPKG_DEFAULT_HOST_TRIPLET : x64-windows-static-md
@@ -134,11 +139,39 @@ jobs:
134139 if : matrix.name == 'macos-x64'
135140 run : rustup target add x86_64-apple-darwin
136141
142+ # ---------- Setup sccache ----------
143+ - name : Setup sccache
144+ uses : mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
145+
146+ - name : Enable sccache wrapping (probe first)
147+ shell : bash
148+ run : |
149+ if sccache --start-server >/dev/null 2>&1; then
150+ echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
151+ echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
152+ else
153+ echo "::warning::sccache backend unreachable; building without compile cache this run"
154+ fi
155+
137156 # ---------- Cache Cargo ----------
138- - name : Cache Cargo
139- uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
157+ - name : Cache cargo registry
158+ uses : actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
159+ with :
160+ path : |
161+ ~/.cargo/registry/index/
162+ ~/.cargo/registry/cache/
163+ ~/.cargo/git/db/
164+ key : ${{ runner.os }}-${{ matrix.name }}-cargo-registry-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
165+ restore-keys : |
166+ ${{ runner.os }}-${{ matrix.name }}-cargo-registry-
167+
168+ - name : Cache cargo target
169+ uses : actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
140170 with :
141- workspaces : client-sdk-rust -> target
171+ path : client-sdk-rust/target/
172+ key : ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
173+ restore-keys : |
174+ ${{ runner.os }}-${{ matrix.name }}-cargo-target-
142175
143176 # ---------- Build environment setup ----------
144177 - name : Set Linux build environment
@@ -303,12 +336,39 @@ jobs:
303336 with :
304337 toolchain : stable
305338
339+ # ---------- Setup sccache ----------
340+ - name : Setup sccache
341+ uses : mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
342+
343+ - name : Enable sccache wrapping (probe first)
344+ shell : bash
345+ run : |
346+ if sccache --start-server >/dev/null 2>&1; then
347+ echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
348+ echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
349+ else
350+ echo "::warning::sccache backend unreachable; building without compile cache this run"
351+ fi
352+
306353 # ---------- Cache Cargo ----------
307- - name : Cache Cargo
308- uses : Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
354+ - name : Cache cargo registry
355+ uses : actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
356+ with :
357+ path : |
358+ ~/.cargo/registry/index/
359+ ~/.cargo/registry/cache/
360+ ~/.cargo/git/db/
361+ key : ${{ runner.os }}-coverage-cargo-registry-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
362+ restore-keys : |
363+ ${{ runner.os }}-coverage-cargo-registry-
364+
365+ - name : Cache cargo target
366+ uses : actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
309367 with :
310- workspaces : client-sdk-rust -> target
311- key : coverage
368+ path : client-sdk-rust/target/
369+ key : ${{ runner.os }}-coverage-cargo-target-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
370+ restore-keys : |
371+ ${{ runner.os }}-coverage-cargo-target-
312372
313373 # ---------- Build environment setup ----------
314374 - name : Set build environment
0 commit comments