Skip to content

Commit 56398cb

Browse files
ci(cache): only save caches on master branch (#3249)
Previously, we would always save certain smaller caches like clippy etc on each PR. This still amounts to a lot of caches. With this patch, we conditionally only save them when the workflow is run on the master branch. This gives most pull requests a good base to work with to speed them up significantly without us keeping around a lot of caches and have GitHub invalidate them constantly. On master, the condition evaluates to `true` which saves the cache: https://github.com/thomaseizinger/rust-libp2p/actions/runs/3699904381/jobs/6267774899#step:5:3 On pull-requests, the condition evaluates to `false` which skips saving it: https://github.com/thomaseizinger/rust-libp2p/actions/runs/3700055536/jobs/6268096357#step:4:3
1 parent e9d5a30 commit 56398cb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ jobs:
115115
target: ${{ matrix.target }}
116116

117117
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
118+
with:
119+
save-if: ${{ github.ref == 'refs/heads/master' }}
118120

119121
- run: cargo check --package libp2p --all-features --target=${{ matrix.target }}
120122

@@ -141,6 +143,8 @@ jobs:
141143
override: true
142144

143145
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
146+
with:
147+
save-if: ${{ github.ref == 'refs/heads/master' }}
144148

145149
- run: cargo check --package libp2p --features="${{ matrix.features }}"
146150

@@ -162,6 +166,8 @@ jobs:
162166
override: true
163167

164168
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
169+
with:
170+
save-if: ${{ github.ref == 'refs/heads/master' }}
165171

166172
- name: Check rustdoc links
167173
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links --deny warnings" cargo doc --verbose --workspace --no-deps --all-features --document-private-items
@@ -191,6 +197,8 @@ jobs:
191197
components: clippy
192198

193199
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
200+
with:
201+
save-if: ${{ github.ref == 'refs/heads/master' }}
194202

195203
- name: Run cargo clippy
196204
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
@@ -215,6 +223,8 @@ jobs:
215223
override: true
216224

217225
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
226+
with:
227+
save-if: ${{ github.ref == 'refs/heads/master' }}
218228

219229
- name: Run ipfs-kad example
220230
run: RUST_LOG=libp2p_swarm=debug,libp2p_kad=trace,libp2p_tcp=debug cargo run --example ipfs-kad --features full

0 commit comments

Comments
 (0)