Skip to content

Commit 4951765

Browse files
update github to use sscache, following format of rust-sdks #1069 (#132)
1 parent 7d4faf3 commit 4951765

3 files changed

Lines changed: 136 additions & 14 deletions

File tree

.github/workflows/builds.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ permissions:
5252

5353
env:
5454
CARGO_TERM_COLOR: always
55+
# sccache caches rustc invocations across runs. RUSTC_WRAPPER is exported
56+
# only after the setup step verifies the GHA cache backend is reachable, so
57+
# transient cache backend failures fall back to uncached rustc instead of
58+
# failing the build.
59+
SCCACHE_GHA_ENABLED: "true"
5560
# Pinned commit for cpp-example-collection smoke build (https://github.com/livekit-examples/cpp-example-collection)
5661
CPP_EXAMPLE_COLLECTION_REF: 46083ea4e5d3def8e44a53148c2c7800131efca0
5762
# vcpkg binary caching for Windows
@@ -158,11 +163,39 @@ jobs:
158163
if: matrix.name == 'macos-x64'
159164
run: rustup target add x86_64-apple-darwin
160165

166+
# ---------- Setup sccache ----------
167+
- name: Setup sccache
168+
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
169+
170+
- name: Enable sccache wrapping (probe first)
171+
shell: bash
172+
run: |
173+
if sccache --start-server >/dev/null 2>&1; then
174+
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
175+
echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
176+
else
177+
echo "::warning::sccache backend unreachable; building without compile cache this run"
178+
fi
179+
161180
# ---------- Cache Cargo ----------
162-
- name: Cache Cargo
163-
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
181+
- name: Cache cargo registry
182+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
183+
with:
184+
path: |
185+
~/.cargo/registry/index/
186+
~/.cargo/registry/cache/
187+
~/.cargo/git/db/
188+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-registry-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
189+
restore-keys: |
190+
${{ runner.os }}-${{ matrix.name }}-cargo-registry-
191+
192+
- name: Cache cargo target
193+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
164194
with:
165-
workspaces: client-sdk-rust -> target
195+
path: client-sdk-rust/target/
196+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
197+
restore-keys: |
198+
${{ runner.os }}-${{ matrix.name }}-cargo-target-
166199
167200
# ---------- Build environment setup ----------
168201
- name: Set Linux build environment

.github/workflows/make-release.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ on:
1313

1414
env:
1515
CARGO_TERM_COLOR: always
16+
# sccache caches rustc invocations across runs. RUSTC_WRAPPER is exported
17+
# only after the setup step verifies the GHA cache backend is reachable, so
18+
# transient cache backend failures fall back to uncached rustc instead of
19+
# failing the build.
20+
SCCACHE_GHA_ENABLED: "true"
1621
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
1722
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
1823
VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-static-md
@@ -135,15 +140,39 @@ jobs:
135140
if: matrix.name == 'macos-x64'
136141
run: rustup target add x86_64-apple-darwin
137142

143+
# ---------- Setup sccache ----------
144+
- name: Setup sccache
145+
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
146+
147+
- name: Enable sccache wrapping (probe first)
148+
shell: bash
149+
run: |
150+
if sccache --start-server >/dev/null 2>&1; then
151+
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
152+
echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
153+
else
154+
echo "::warning::sccache backend unreachable; building without compile cache this run"
155+
fi
156+
138157
# ---------- Cache Cargo ----------
139158
- name: Cache Cargo registry
140159
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
141160
with:
142161
path: |
143-
~/.cargo/registry
144-
~/.cargo/git
145-
key: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-${{ hashFiles('**/Cargo.lock') }}
146-
restore-keys: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-
162+
~/.cargo/registry/index/
163+
~/.cargo/registry/cache/
164+
~/.cargo/git/db/
165+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-registry-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
166+
restore-keys: |
167+
${{ runner.os }}-${{ matrix.name }}-cargo-registry-
168+
169+
- name: Cache cargo target
170+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
171+
with:
172+
path: client-sdk-rust/target/
173+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
174+
restore-keys: |
175+
${{ runner.os }}-${{ matrix.name }}-cargo-target-
147176
148177
# ---------- Build environment setup ----------
149178
- name: Set Linux build environment

.github/workflows/tests.yml

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ permissions:
3636

3737
env:
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

Comments
 (0)