Skip to content

Commit 5cc3047

Browse files
authored
Switch to Swatinem/rust-cache (#402)
This is an experiment to see if this cache action performs better than `Leafwing-Studios/cargo-cache`, just like TheBevyFlock/bevy_new_2d#381. If this gets merged we can test it for a few weeks then evaluate whether it's an improvement or not. Closes #400.
1 parent ccb0538 commit 5cc3047

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

.github/workflows/ci.yml

+11-19
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,12 @@ jobs:
3636
uses: bevyengine/bevy/.github/actions/[email protected]
3737

3838
- name: Cache build artifacts
39-
uses: Leafwing-Studios/cargo-cache@v2
39+
uses: Swatinem/rust-cache@v2
4040
with:
41-
sweep-cache: true
42-
43-
# We have a separate workspace where we execute the CLI in the E2E tests
44-
# It has it's own `target` folder, hence we need to cache it separately
45-
- name: Cache test workspace
46-
uses: Leafwing-Studios/cargo-cache@v2
47-
with:
48-
sweep-cache: true
49-
# The cache-group needs to be different to not collide with the cache for the test executing itself
50-
cache-group: "test_workspace-${{ hashFiles(env.workflow_path) }}-${{ github.job }}-${{ strategy.job-index }}"
51-
# cargo-cache doesn't support `working-directory` yet, we have to do it manually
52-
# See https://github.com/Leafwing-Studios/cargo-cache/issues/44
53-
cargo-target-dir: ./tests/bevy_cli_test/target
54-
manifest-path: ./tests/bevy_cli_test/Cargo.toml
41+
workspaces: |
42+
. -> target
43+
tests/bevy_cli_test -> target
44+
save-if: ${{ github.ref == 'refs/heads/main' }}
5545

5646
- name: Run tests
5747
run: |
@@ -78,9 +68,11 @@ jobs:
7868
components: "${{ needs.extract-rust-version.outputs.components }}, clippy"
7969

8070
- name: Cache build artifacts
81-
uses: Leafwing-Studios/cargo-cache@v2
71+
uses: Swatinem/rust-cache@v2
8272
with:
83-
sweep-cache: true
73+
# All 3 matrix combinations share the same cache key, so we only save the cache for the
74+
# combination that does the most work. In this case, that's `--all-features`.
75+
save-if: ${{ github.ref == 'refs/heads/main' && matrix.features == '--all-features' }}
8476

8577
- name: Run Clippy
8678
env:
@@ -120,9 +112,9 @@ jobs:
120112
components: ${{ needs.extract-rust-version.outputs.components }}
121113

122114
- name: Cache build artifacts
123-
uses: Leafwing-Studios/cargo-cache@v2
115+
uses: Swatinem/rust-cache@v2
124116
with:
125-
sweep-cache: true
117+
save-if: ${{ github.ref == 'refs/heads/main' }}
126118

127119
- name: Build documentation
128120
run: cargo doc --workspace --all-features --document-private-items --no-deps

.github/workflows/docs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
components: ${{ needs.extract-rust-version.outputs.components }}
3333

3434
- name: Cache build artifacts
35-
uses: Leafwing-Studios/cargo-cache@v2
35+
uses: Swatinem/rust-cache@v2
3636
with:
37-
sweep-cache: true
37+
save-if: ${{ github.ref == 'refs/heads/main' }}
3838

3939
- name: Build with `rustdoc`
4040
# This alias calls `cargo rustdoc` with additional arguments, as specified by

0 commit comments

Comments
 (0)