Skip to content

Commit b77a27f

Browse files
committed
Cache Cargo registry
Cache standalone index and cache to speed up the CI. https: //doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 87efe4a commit b77a27f

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,51 @@ jobs:
7474
- name: Check JSON scoped
7575
run: ./schema/check.sh examples/mini-scoped.json
7676

77+
cache_cargo_index:
78+
runs-on: ubuntu-24.04
79+
steps:
80+
81+
- uses: actions/checkout@v4
82+
83+
- name: Cache Cargo registry index
84+
uses: actions/cache@v4
85+
with:
86+
path: |
87+
~/.cargo/registry/index
88+
key: cargo-registry-index-${{ github.sha }}
89+
restore-keys: |
90+
cargo-registry-index-
91+
92+
- name: Update Cargo registry
93+
run: cargo update
94+
7795
ubuntu_24_rust_msrv:
7896
runs-on: ubuntu-24.04
79-
needs: commit_list
97+
needs: commit_list cache_cargo_index
8098
strategy:
8199
fail-fast: false
82100
matrix:
83101
commit: ${{ fromJSON(needs.commit_list.outputs.commits) }}
84102
steps:
85103

104+
- name: Restore Cargo registry index cache
105+
uses: actions/cache/restore@v4
106+
with:
107+
path: |
108+
~/.cargo/registry/index
109+
key: cargo-registry-index-${{ github.sha }}
110+
restore-keys: |
111+
cargo-registry-index-
112+
113+
- name: Cache Cargo registry MSRV cache
114+
uses: actions/cache@v4
115+
with:
116+
path: |
117+
~/.cargo/registry/cache
118+
key: cargo-registry-cache-msrv-${{ github.sha }}
119+
restore-keys: |
120+
cargo-registry-cache-msrv-
121+
86122
- name: Install cargo-c
87123
run: sudo apt install cargo-c
88124

@@ -117,13 +153,31 @@ jobs:
117153

118154
ubuntu_24_rust_stable:
119155
runs-on: ubuntu-24.04
120-
needs: commit_list
156+
needs: commit_list cache_cargo_index
121157
strategy:
122158
fail-fast: false
123159
matrix:
124160
commit: ${{ fromJSON(needs.commit_list.outputs.commits) }}
125161
steps:
126162

163+
- name: Restore Cargo registry index cache
164+
uses: actions/cache/restore@v4
165+
with:
166+
path: |
167+
~/.cargo/registry/index
168+
key: cargo-registry-index-${{ github.sha }}
169+
restore-keys: |
170+
cargo-registry-index-
171+
172+
- name: Cache Cargo registry stable cache
173+
uses: actions/cache@v4
174+
with:
175+
path: |
176+
~/.cargo/registry/cache
177+
key: cargo-registry-cache-stable-${{ github.sha }}
178+
restore-keys: |
179+
cargo-registry-cache-stable-
180+
127181
- name: Install cargo-c
128182
run: sudo apt install cargo-c
129183

0 commit comments

Comments
 (0)