Skip to content

Commit f01d606

Browse files
committed
Only save caches on master branch pushes
With a large build matrix and various specialized jobs, cache entries are created for every PR branch, quickly exhausting the 10 GB GitHub Actions cache limit and causing evictions. That is a problem, because it can force kernel bzImage and vmsh rebuilds, which can take a long time. Restrict cache saving to the master branch, while still allowing all branches to restore from existing caches. In so doing we should curb evictions hopefully completely. Signed-off-by: Daniel Müller <deso@posteo.net>
1 parent d9bf528 commit f01d606

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ jobs:
7171
sudo ln -s /usr/include/asm-generic /usr/include/asm
7272
sudo rm -f /bin/clang && sudo ln -s /usr/bin/clang-18 /bin/clang
7373
- uses: Swatinem/rust-cache@v2
74+
with:
75+
save-if: ${{ github.ref == 'refs/heads/master' }}
7476
- name: Build
7577
run: cargo build --profile=${{ matrix.profile }} --locked --verbose --workspace --exclude runqslower
7678
- name: Run tests
@@ -128,6 +130,8 @@ jobs:
128130
with:
129131
components: rustfmt
130132
- uses: Swatinem/rust-cache@v2
133+
with:
134+
save-if: ${{ github.ref == 'refs/heads/master' }}
131135
- name: Run examples
132136
#env:
133137
# CFLAGS: '-fsanitize=leak'
@@ -158,6 +162,8 @@ jobs:
158162
sudo apt-get install --yes --no-install-recommends libelf-dev autopoint
159163
- uses: dtolnay/rust-toolchain@stable
160164
- uses: Swatinem/rust-cache@v2
165+
with:
166+
save-if: ${{ github.ref == 'refs/heads/master' }}
161167
- name: Build libbpf-rs sample
162168
run: |
163169
cargo init --bin ../libbpf-rs-test-project
@@ -194,6 +200,8 @@ jobs:
194200
toolchain: 1.82.0
195201
components: rustfmt
196202
- uses: Swatinem/rust-cache@v2
203+
with:
204+
save-if: ${{ github.ref == 'refs/heads/master' }}
197205
- name: Build
198206
run: cargo build --verbose --workspace --exclude runqslower --exclude task_longrun
199207

@@ -210,6 +218,8 @@ jobs:
210218
with:
211219
components: rustfmt
212220
- uses: Swatinem/rust-cache@v2
221+
with:
222+
save-if: ${{ github.ref == 'refs/heads/master' }}
213223
# `-lzstd` is necessary because Ubuntu's system libelf.a is built
214224
# with zstd support.
215225
- run: RUSTFLAGS="$RUSTFLAGS -L /usr/lib/x86_64-linux-gnu -lzstd" cargo build --locked --package capable --features=static
@@ -236,6 +246,8 @@ jobs:
236246
sudo apt-get update
237247
sudo apt-get install --yes --no-install-recommends libelf-dev:arm64 zlib1g-dev:arm64 gcc-aarch64-linux-gnu
238248
- uses: Swatinem/rust-cache@v2
249+
with:
250+
save-if: ${{ github.ref == 'refs/heads/master' }}
239251
- name: Build
240252
env:
241253
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
@@ -264,6 +276,8 @@ jobs:
264276
sudo apt-get update
265277
sudo apt-get install --yes --no-install-recommends libelf-dev:armhf zlib1g-dev:armhf gcc-arm-linux-gnueabihf
266278
- uses: Swatinem/rust-cache@v2
279+
with:
280+
save-if: ${{ github.ref == 'refs/heads/master' }}
267281
- name: Build
268282
env:
269283
CARGO_BUILD_TARGET: armv7-unknown-linux-gnueabihf
@@ -284,6 +298,8 @@ jobs:
284298
with:
285299
components: clippy, rustfmt
286300
- uses: Swatinem/rust-cache@v2
301+
with:
302+
save-if: ${{ github.ref == 'refs/heads/master' }}
287303
- run: |
288304
# We want the old resolver here as it has more suitable feature
289305
# unification logic for this invocation.

0 commit comments

Comments
 (0)