Skip to content

Commit 98ae4cf

Browse files
Enhance CI workflow: Add caching for Rust toolchain, Cargo registry, and target directories across jobs
1 parent 07c3d40 commit 98ae4cf

1 file changed

Lines changed: 136 additions & 4 deletions

File tree

.github/workflows/rustls-rustcrypto.yml

Lines changed: 136 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
paths-ignore:
66
- README.md
77
push:
8-
branches: master
8+
branches: [master]
99
paths-ignore:
1010
- README.md
1111

@@ -15,31 +15,85 @@ permissions:
1515
env:
1616
CARGO_INCREMENTAL: 0
1717
RUSTFLAGS: "-Dwarnings"
18+
CARGO_HOME: ${{ github.workspace }}/.cargo
19+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
1820

1921
jobs:
2022
clippy:
2123
runs-on: ubuntu-latest
2224
steps:
2325
- uses: actions/checkout@v4
26+
- name: Cache Rust toolchain
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.rustup/toolchains
31+
~/.rustup/downloads
32+
key: rust-toolchain-${{ runner.os }}-1.88.0-clippy
33+
restore-keys: |
34+
rust-toolchain-${{ runner.os }}-1.88.0
2435
- uses: dtolnay/rust-toolchain@master
2536
with:
2637
toolchain: 1.88.0
2738
components: clippy
39+
- name: Cache Cargo registry and index
40+
uses: actions/cache@v4
41+
with:
42+
path: |
43+
~/.cargo/registry
44+
~/.cargo/git
45+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
46+
restore-keys: |
47+
cargo-${{ runner.os }}-
2848
- run: cargo clippy --all --all-features -- -D warnings
2949

3050
doc:
3151
runs-on: ubuntu-latest
3252
steps:
3353
- uses: actions/checkout@v4
54+
- name: Cache Rust toolchain
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/.rustup/toolchains
59+
~/.rustup/downloads
60+
key: rust-toolchain-${{ runner.os }}-stable-doc
61+
restore-keys: |
62+
rust-toolchain-${{ runner.os }}-stable
3463
- uses: dtolnay/rust-toolchain@master
3564
with:
3665
toolchain: stable
66+
- name: Cache Cargo registry and index
67+
uses: actions/cache@v4
68+
with:
69+
path: |
70+
~/.cargo/registry
71+
~/.cargo/git
72+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
73+
restore-keys: |
74+
cargo-${{ runner.os }}-
75+
- name: Cache target directory
76+
uses: actions/cache@v4
77+
with:
78+
path: target
79+
key: cargo-doc-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
80+
restore-keys: |
81+
cargo-doc-${{ runner.os }}-
3782
- run: cargo doc --all-features --no-deps
3883

3984
rustfmt:
4085
runs-on: ubuntu-latest
4186
steps:
4287
- uses: actions/checkout@v4
88+
- name: Cache Rust toolchain
89+
uses: actions/cache@v4
90+
with:
91+
path: |
92+
~/.rustup/toolchains
93+
~/.rustup/downloads
94+
key: rust-toolchain-${{ runner.os }}-stable-rustfmt
95+
restore-keys: |
96+
rust-toolchain-${{ runner.os }}-stable
4397
- uses: dtolnay/rust-toolchain@master
4498
with:
4599
toolchain: stable
@@ -57,14 +111,43 @@ jobs:
57111
- armv7a-none-eabi
58112
- thumbv7em-none-eabi
59113
- wasm32-unknown-unknown
114+
- xtensa-esp32-none-elf
115+
- xtensa-esp32s2-none-elf
116+
- xtensa-esp32s3-none-elf
117+
- riscv32imc-unknown-none-elf
60118
steps:
61119
- uses: actions/checkout@v4
120+
- name: Cache Rust toolchain
121+
uses: actions/cache@v4
122+
with:
123+
path: |
124+
~/.rustup/toolchains
125+
~/.rustup/downloads
126+
key: rust-toolchain-${{ runner.os }}-${{ matrix.rust }}-${{ matrix.target }}
127+
restore-keys: |
128+
rust-toolchain-${{ runner.os }}-${{ matrix.rust }}
62129
- uses: dtolnay/rust-toolchain@master
63130
with:
64131
toolchain: ${{ matrix.rust }}
65132
targets: ${{ matrix.target }}
133+
- name: Cache Cargo registry and index
134+
uses: actions/cache@v4
135+
with:
136+
path: |
137+
~/.cargo/registry
138+
~/.cargo/git
139+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
140+
restore-keys: |
141+
cargo-${{ runner.os }}-
142+
- name: Cache target directory
143+
uses: actions/cache@v4
144+
with:
145+
path: target
146+
key: cargo-nostd-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
147+
restore-keys: |
148+
cargo-nostd-${{ runner.os }}-${{ matrix.target }}-
66149
- run: cargo build --no-default-features --features tls12,full,alloc --release --target ${{ matrix.target }}
67-
env:
150+
env:
68151
RUSTFLAGS: --cfg getrandom_backend="custom"
69152
test:
70153
strategy:
@@ -75,10 +158,34 @@ jobs:
75158
runs-on: ubuntu-latest
76159
steps:
77160
- uses: actions/checkout@v4
78-
- uses: RustCrypto/actions/cargo-cache@master
161+
- name: Cache Rust toolchain
162+
uses: actions/cache@v4
163+
with:
164+
path: |
165+
~/.rustup/toolchains
166+
~/.rustup/downloads
167+
key: rust-toolchain-${{ runner.os }}-${{ matrix.toolchain }}-test
168+
restore-keys: |
169+
rust-toolchain-${{ runner.os }}-${{ matrix.toolchain }}
79170
- uses: dtolnay/rust-toolchain@master
80171
with:
81172
toolchain: ${{ matrix.toolchain }}
173+
- name: Cache Cargo registry and index
174+
uses: actions/cache@v4
175+
with:
176+
path: |
177+
~/.cargo/registry
178+
~/.cargo/git
179+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
180+
restore-keys: |
181+
cargo-${{ runner.os }}-
182+
- name: Cache target directory
183+
uses: actions/cache@v4
184+
with:
185+
path: target
186+
key: cargo-test-${{ runner.os }}-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}
187+
restore-keys: |
188+
cargo-test-${{ runner.os }}-${{ matrix.toolchain }}-
82189
- run: cargo test --features tls12
83190
- name: Test no_std with alloc
84191
run: cargo test --no-default-features --features tls12,full,alloc
@@ -94,10 +201,35 @@ jobs:
94201
runs-on: ubuntu-latest
95202
steps:
96203
- uses: actions/checkout@v4
204+
- name: Cache Rust toolchain
205+
uses: actions/cache@v4
206+
with:
207+
path: |
208+
~/.rustup/toolchains
209+
~/.rustup/downloads
210+
key: rust-toolchain-${{ runner.os }}-${{ matrix.rust }}-${{ matrix.target }}
211+
restore-keys: |
212+
rust-toolchain-${{ runner.os }}-${{ matrix.rust }}
97213
- run: ${{ matrix.deps }}
98214
- uses: dtolnay/rust-toolchain@master
99215
with:
100216
toolchain: ${{ matrix.rust }}
101217
targets: ${{ matrix.target }}
102218
- uses: RustCrypto/actions/cross-install@master
103-
- run: cross test --release --target ${{ matrix.target }} --all-features
219+
- name: Cache Cargo registry and index
220+
uses: actions/cache@v4
221+
with:
222+
path: |
223+
~/.cargo/registry
224+
~/.cargo/git
225+
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
226+
restore-keys: |
227+
cargo-${{ runner.os }}-
228+
- name: Cache target directory
229+
uses: actions/cache@v4
230+
with:
231+
path: target
232+
key: cargo-cross-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
233+
restore-keys: |
234+
cargo-cross-${{ runner.os }}-${{ matrix.target }}-
235+
- run: cross test --release --target ${{ matrix.target }} --all-features

0 commit comments

Comments
 (0)