Skip to content

Commit cf44616

Browse files
committed
fix(ci): enable sccache cache loading and saving in GitHub Actions
Previously sccache cache had 0% hit rate because environment variables were set too late (after sccache-action execution). This caused cache to never load or save, resulting in full compilation on every workflow run. Changes: - Add job-level env vars (SCCACHE_GHA_ENABLED, RUSTC_WRAPPER) - Specify explicit sccache version v0.10.2 (required for GHA cache service) - Remove redundant configuration steps Expected improvement: 40-60% cache hit rate, 50-70% faster builds
1 parent cd64496 commit cf44616

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
matrix:
2525
os: [ubuntu-latest, macos-latest, windows-latest]
2626
rust: [stable]
27+
env:
28+
SCCACHE_GHA_ENABLED: "true"
29+
RUSTC_WRAPPER: "sccache"
2730
steps:
2831
- name: Checkout code
2932
uses: actions/checkout@v6
@@ -35,12 +38,8 @@ jobs:
3538

3639
- name: Setup sccache
3740
uses: mozilla-actions/sccache-action@v0.0.9
38-
39-
- name: Configure sccache
40-
shell: bash
41-
run: |
42-
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
43-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
41+
with:
42+
version: "v0.10.2"
4443

4544
- name: Install cargo-nextest
4645
uses: taiki-e/install-action@nextest
@@ -70,6 +69,9 @@ jobs:
7069
clippy:
7170
name: Clippy
7271
runs-on: ubuntu-latest
72+
env:
73+
SCCACHE_GHA_ENABLED: "true"
74+
RUSTC_WRAPPER: "sccache"
7375
steps:
7476
- name: Checkout code
7577
uses: actions/checkout@v6
@@ -81,12 +83,8 @@ jobs:
8183

8284
- name: Setup sccache
8385
uses: mozilla-actions/sccache-action@v0.0.9
84-
85-
- name: Configure sccache
86-
shell: bash
87-
run: |
88-
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
89-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
86+
with:
87+
version: "v0.10.2"
9088

9189
- name: Run clippy
9290
run: cargo clippy --all-targets --all-features -- -D warnings
@@ -111,6 +109,9 @@ jobs:
111109
strategy:
112110
matrix:
113111
os: [ubuntu-latest, macos-latest, windows-latest]
112+
env:
113+
SCCACHE_GHA_ENABLED: "true"
114+
RUSTC_WRAPPER: "sccache"
114115
steps:
115116
- name: Checkout code
116117
uses: actions/checkout@v6
@@ -120,12 +121,8 @@ jobs:
120121

121122
- name: Setup sccache
122123
uses: mozilla-actions/sccache-action@v0.0.9
123-
124-
- name: Configure sccache
125-
shell: bash
126-
run: |
127-
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
128-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
124+
with:
125+
version: "v0.10.2"
129126

130127
- name: Build release
131128
run: cargo build --release --verbose

.github/workflows/release.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ jobs:
7878
needs: validate
7979
runs-on: ${{ matrix.os }}
8080
timeout-minutes: 45
81+
env:
82+
SCCACHE_GHA_ENABLED: "true"
83+
RUSTC_WRAPPER: "sccache"
8184
strategy:
8285
fail-fast: false
8386
matrix:
@@ -135,12 +138,8 @@ jobs:
135138

136139
- name: Setup sccache
137140
uses: mozilla-actions/sccache-action@v0.0.9
138-
139-
- name: Configure sccache
140-
shell: bash
141-
run: |
142-
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
143-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
141+
with:
142+
version: "v0.10.2"
144143

145144
# Install musl tools for Linux musl builds
146145
- name: Install musl tools (Linux musl only)

0 commit comments

Comments
 (0)