Skip to content

Commit 6452659

Browse files
committed
ci(check): add caching to workflow
1 parent 02e3a91 commit 6452659

1 file changed

Lines changed: 118 additions & 31 deletions

File tree

.github/workflows/check.yml

Lines changed: 118 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,66 @@ env:
1111
cache_nonce: 0
1212

1313
jobs:
14+
build:
15+
name: Build
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v6
22+
23+
- name: Install dependencies
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y clang libclang-dev
27+
28+
- name: Cache Rust toolchain
29+
uses: actions/cache@v5
30+
with:
31+
path: |
32+
~/.rustup
33+
~/.cargo/bin
34+
key: ${{ runner.os }}-rust-toolchain-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
35+
36+
- name: Cache cargo registry
37+
uses: actions/cache@v5
38+
with:
39+
path: ~/.cargo/registry
40+
key: ${{ runner.os }}-cargo-registry-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
41+
42+
- name: Cache cargo index
43+
uses: actions/cache@v5
44+
with:
45+
path: ~/.cargo/git
46+
key: ${{ runner.os }}-cargo-index-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
47+
48+
- name: Cache cargo build
49+
uses: actions/cache@v5
50+
with:
51+
path: target
52+
key: ${{ runner.os }}-cargo-build-target-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
53+
54+
- name: Cache prebuilt binaries
55+
uses: actions/cache@v5
56+
with:
57+
path: ~/.cache/storage-bindings
58+
key: ${{ runner.os }}-prebuilt-binaries-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
59+
60+
- name: Install mise
61+
uses: jdx/mise-action@v3
62+
with:
63+
enable: true
64+
cache: true
65+
66+
- name: Run cargo build
67+
run: cargo build --all-features --release
68+
1469
lint:
15-
name: Lint - ${{ matrix.task }}
70+
name: Lint
1671
runs-on: ubuntu-latest
1772
timeout-minutes: 30
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
task:
22-
- check
23-
- fmt
24-
- clippy
73+
needs: build
2574

2675
steps:
2776
- name: Checkout code
@@ -32,6 +81,38 @@ jobs:
3281
sudo apt-get update
3382
sudo apt-get install -y clang libclang-dev
3483
84+
- name: Cache Rust toolchain
85+
uses: actions/cache@v5
86+
with:
87+
path: |
88+
~/.rustup
89+
~/.cargo/bin
90+
key: ${{ runner.os }}-rust-toolchain-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
91+
92+
- name: Cache cargo registry
93+
uses: actions/cache@v5
94+
with:
95+
path: ~/.cargo/registry
96+
key: ${{ runner.os }}-cargo-registry-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
97+
98+
- name: Cache cargo index
99+
uses: actions/cache@v5
100+
with:
101+
path: ~/.cargo/git
102+
key: ${{ runner.os }}-cargo-index-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
103+
104+
- name: Cache cargo build
105+
uses: actions/cache@v5
106+
with:
107+
path: target
108+
key: ${{ runner.os }}-cargo-build-target-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
109+
110+
- name: Cache prebuilt binaries
111+
uses: actions/cache@v5
112+
with:
113+
path: ~/.cache/storage-bindings
114+
key: ${{ runner.os }}-prebuilt-binaries-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
115+
35116
- name: Install mise
36117
uses: jdx/mise-action@v3
37118
with:
@@ -42,21 +123,19 @@ jobs:
42123
run: rustup component add rustfmt clippy
43124

44125
- name: Run cargo check
45-
if: matrix.task == 'check'
46126
run: cargo check --all-targets --all-features
47127

48128
- name: Run cargo fmt
49-
if: matrix.task == 'fmt'
50129
run: cargo fmt --all -- --check
51130

52131
- name: Run cargo clippy
53-
if: matrix.task == 'clippy'
54132
run: cargo clippy --all-targets --all-features -- -D warnings
55133

56134
test:
57135
name: Test
58136
runs-on: ubuntu-latest
59137
timeout-minutes: 30
138+
needs: build
60139

61140
steps:
62141
- name: Checkout code
@@ -67,35 +146,43 @@ jobs:
67146
sudo apt-get update
68147
sudo apt-get install -y clang libclang-dev
69148
70-
- name: Install mise
71-
uses: jdx/mise-action@v3
149+
- name: Cache Rust toolchain
150+
uses: actions/cache@v5
72151
with:
73-
enable: true
74-
cache: true
152+
path: |
153+
~/.rustup
154+
~/.cargo/bin
155+
key: ${{ runner.os }}-rust-toolchain-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
75156

76-
- name: Run cargo test
77-
run: cargo test --all-features
157+
- name: Cache cargo registry
158+
uses: actions/cache@v5
159+
with:
160+
path: ~/.cargo/registry
161+
key: ${{ runner.os }}-cargo-registry-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
78162

79-
build:
80-
name: Build
81-
runs-on: ubuntu-latest
82-
timeout-minutes: 30
83-
needs: [lint, test]
163+
- name: Cache cargo index
164+
uses: actions/cache@v5
165+
with:
166+
path: ~/.cargo/git
167+
key: ${{ runner.os }}-cargo-index-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
84168

85-
steps:
86-
- name: Checkout code
87-
uses: actions/checkout@v6
169+
- name: Cache cargo build
170+
uses: actions/cache@v5
171+
with:
172+
path: target
173+
key: ${{ runner.os }}-cargo-build-target-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
88174

89-
- name: Install dependencies
90-
run: |
91-
sudo apt-get update
92-
sudo apt-get install -y clang libclang-dev
175+
- name: Cache prebuilt binaries
176+
uses: actions/cache@v5
177+
with:
178+
path: ~/.cache/storage-bindings
179+
key: ${{ runner.os }}-prebuilt-binaries-${{ env.cache_nonce }}-${{ hashFiles('**/Cargo.lock') }}
93180

94181
- name: Install mise
95182
uses: jdx/mise-action@v3
96183
with:
97184
enable: true
98185
cache: true
99186

100-
- name: Run cargo build
101-
run: cargo build --all-features --release
187+
- name: Run cargo test
188+
run: cargo test --all-features

0 commit comments

Comments
 (0)