Skip to content

Commit 9d4067e

Browse files
fix: use Swatinem/rust-cache to reduce CI cache bloat (#484)
Replace manual actions/cache with Swatinem/rust-cache which: - Automatically cleans incremental compilation artifacts - Excludes debug symbols and test binaries - Has smart cache key management - Significantly reduces cache size (from 3+ GiB to ~500 MiB) This fixes the disk space issues causing CI failures.
1 parent e50cf77 commit 9d4067e

File tree

2 files changed

+19
-64
lines changed

2 files changed

+19
-64
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,10 @@ jobs:
4747
components: rustfmt, clippy
4848

4949
- name: Cache cargo registry and build
50-
uses: actions/cache@v4
50+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
5151
with:
52-
path: |
53-
~/.cargo/bin/
54-
~/.cargo/registry/index/
55-
~/.cargo/registry/cache/
56-
~/.cargo/git/db/
57-
target/
58-
key: ${{ runner.os }}-cargo-quick-${{ hashFiles('**/Cargo.lock') }}
59-
restore-keys: |
60-
${{ runner.os }}-cargo-quick-
61-
${{ runner.os }}-cargo-
52+
prefix-key: "v1-rust"
53+
shared-key: "quick"
6254

6355
- name: Check formatting
6456
run: cargo fmt --all -- --check
@@ -84,19 +76,10 @@ jobs:
8476
toolchain: stable
8577

8678
- name: Cache cargo registry and build
87-
uses: actions/cache@v4
79+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
8880
with:
89-
path: |
90-
~/.cargo/bin/
91-
~/.cargo/registry/index/
92-
~/.cargo/registry/cache/
93-
~/.cargo/git/db/
94-
target/
95-
key: ${{ runner.os }}-cargo-test-${{ matrix.package }}-${{ hashFiles('**/Cargo.lock') }}
96-
restore-keys: |
97-
${{ runner.os }}-cargo-test-${{ matrix.package }}-
98-
${{ runner.os }}-cargo-test-
99-
${{ runner.os }}-cargo-
81+
prefix-key: "v1-rust"
82+
shared-key: "test-${{ matrix.package }}"
10083

10184
- name: Run unit tests
10285
run: cargo test --package ${{ matrix.package }} --lib --all-features
@@ -115,18 +98,10 @@ jobs:
11598
toolchain: stable
11699

117100
- name: Cache cargo registry and build
118-
uses: actions/cache@v4
101+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
119102
with:
120-
path: |
121-
~/.cargo/bin/
122-
~/.cargo/registry/index/
123-
~/.cargo/registry/cache/
124-
~/.cargo/git/db/
125-
target/
126-
key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }}
127-
restore-keys: |
128-
${{ runner.os }}-cargo-integration-
129-
${{ runner.os }}-cargo-
103+
prefix-key: "v1-rust"
104+
shared-key: "integration"
130105

131106
- name: Run integration tests
132107
run: cargo test --workspace --test '*' --all-features
@@ -156,18 +131,10 @@ jobs:
156131
toolchain: stable
157132

158133
- name: Cache cargo registry and build
159-
uses: actions/cache@v4
134+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
160135
with:
161-
path: |
162-
~/.cargo/bin/
163-
~/.cargo/registry/index/
164-
~/.cargo/registry/cache/
165-
~/.cargo/git/db/
166-
target/
167-
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
168-
restore-keys: |
169-
${{ runner.os }}-cargo-build-
170-
${{ runner.os }}-cargo-
136+
prefix-key: "v1-rust"
137+
shared-key: "build"
171138

172139
- name: Build binary
173140
run: cargo build --release --bin redisctl
@@ -192,18 +159,10 @@ jobs:
192159
toolchain: stable
193160

194161
- name: Cache cargo registry and build
195-
uses: actions/cache@v4
162+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
196163
with:
197-
path: |
198-
~/.cargo/bin/
199-
~/.cargo/registry/index/
200-
~/.cargo/registry/cache/
201-
~/.cargo/git/db/
202-
target/
203-
key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
204-
restore-keys: |
205-
${{ runner.os }}-cargo-coverage-
206-
${{ runner.os }}-cargo-
164+
prefix-key: "v1-rust"
165+
shared-key: "coverage"
207166

208167
- name: Install tarpaulin
209168
uses: taiki-e/install-action@v2

.github/workflows/docs.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,11 @@ jobs:
122122
toolchain: stable
123123

124124
- name: Cache cargo registry
125-
uses: actions/cache@v4
125+
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
126126
with:
127-
path: |
128-
~/.cargo/registry/index/
129-
~/.cargo/registry/cache/
130-
~/.cargo/git/db/
131-
key: ${{ runner.os }}-cargo-doc-${{ hashFiles('**/Cargo.lock') }}
132-
restore-keys: |
133-
${{ runner.os }}-cargo-doc-
127+
prefix-key: "v1-rust"
128+
shared-key: "doc"
129+
cache-targets: false
134130

135131
- name: Check that API docs build
136132
run: cargo doc --workspace --no-deps --all-features

0 commit comments

Comments
 (0)