Skip to content

Commit 985f7af

Browse files
baptiste0928MaxOhn
authored andcommitted
chore(github-actions): improve ci cache (twilight-rs#1151)
I noticed that the cache used for the CI was inefficient: all dependencies are recompiled each time, which made the CI very long to run. This PR replaces the existing cache with the [`Swatinem/rust-cache`](https://github.com/Swatinem/rust-cache/) action, that correctly cache dependencies. This cache is used in [other big projects](https://github.com/rust-analyzer/rust-analyzer/blob/b73b321478d3b2a98d380eb79de717e01620c4e9/.github/workflows/ci.yaml#L53-L54) like `rust-analyzer`.
1 parent 134e9d3 commit 985f7af

File tree

4 files changed

+12
-48
lines changed

4 files changed

+12
-48
lines changed

.github/workflows/doc.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ jobs:
1919
profile: minimal
2020
override: true
2121

22-
- name: Setup cache
23-
uses: actions/cache@v2
24-
with:
25-
path: |
26-
~/.cargo/registry
27-
~/.cargo/git
28-
target/debug
29-
key: ${{ runner.os }}-docs-rustc-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
22+
- name: Cache dependencies
23+
uses: Swatinem/rust-cache@v1
3024

3125
- name: Build docs
3226
env:

.github/workflows/lint.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ jobs:
2020
profile: minimal
2121
override: true
2222

23-
- name: Setup cache
24-
uses: actions/cache@v2
25-
with:
26-
path: |
27-
~/.cargo/registry
28-
~/.cargo/git
29-
target
30-
key: ${{ runner.os }}-clippy-rustc-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
23+
- name: Cache dependencies
24+
uses: Swatinem/rust-cache@v1
3125

3226
- name: Run clippy
3327
uses: actions-rs/clippy-check@v1

.github/workflows/publish.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ jobs:
2222
profile: minimal
2323
override: true
2424

25-
- name: Setup cache
26-
uses: actions/cache@v2
27-
with:
28-
path: |
29-
~/.cargo/registry
30-
~/.cargo/git
31-
target/debug
32-
key: ${{ runner.os }}-docs-rustc-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
25+
- name: Cache dependencies
26+
uses: Swatinem/rust-cache@v1
3327

3428
- name: Build docs
3529
env:

.github/workflows/test.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ jobs:
2222
profile: minimal
2323
override: true
2424

25-
- name: Setup cache
26-
uses: actions/cache@v2
27-
with:
28-
path: |
29-
~/.cargo/registry
30-
~/.cargo/git
31-
target
32-
key: ${{ runner.os }}-test-rustc-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
25+
- name: Cache dependencies
26+
uses: Swatinem/rust-cache@v1
3327

3428
- name: Run cargo test
3529
run: cargo test
@@ -88,14 +82,8 @@ jobs:
8882
profile: minimal
8983
override: true
9084

91-
- name: Setup cache
92-
uses: actions/cache@v2
93-
with:
94-
path: |
95-
~/.cargo/registry
96-
~/.cargo/git
97-
target
98-
key: ${{ runner.os }}-test-rustc-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
85+
- name: Cache dependencies
86+
uses: Swatinem/rust-cache@v1
9987

10088
- name: Test ${{ matrix.package }} feat. ${{ matrix.features }}
10189
working-directory: ${{ matrix.package }}
@@ -119,14 +107,8 @@ jobs:
119107
profile: minimal
120108
override: true
121109

122-
- name: Setup cache
123-
uses: actions/cache@v2
124-
with:
125-
path: |
126-
~/.cargo/registry
127-
~/.cargo/git
128-
target
129-
key: ${{ runner.os }}-msrv-${{ steps.tc.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
110+
- name: Cache dependencies
111+
uses: Swatinem/rust-cache@v1
130112

131113
- run: cargo check --examples --tests --all-features
132114
env:

0 commit comments

Comments
 (0)