Skip to content

Commit af24737

Browse files
committed
ci: add caching strategy for ci
1 parent 3964d2c commit af24737

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,40 @@ jobs:
2525
format:
2626
name: format
2727
runs-on: ubuntu-22.04
28+
timeout-minutes: 10
2829
steps:
2930
- name: checkout
3031
uses: actions/checkout@v4
32+
- name: Cache Rust dependencies
33+
uses: Swatinem/rust-cache@v2
34+
with:
35+
cache-directories: |
36+
~/.cargo/registry
37+
~/.cargo/git
38+
target
3139
- name: toolchain
3240
uses: dtolnay/rust-toolchain@stable
3341
with:
3442
toolchain: ${{ env.toolchain }}
3543
components: rustfmt
3644
- name: cargo format
3745
run: cargo fmt --all -- --check
46+
timeout-minutes: 5
3847

3948
clippy:
4049
name: clippy
4150
runs-on: ubuntu-22.04
51+
timeout-minutes: 15
4252
steps:
4353
- name: checkout
4454
uses: actions/checkout@v4
55+
- name: Cache Rust dependencies
56+
uses: Swatinem/rust-cache@v2
57+
with:
58+
cache-directories: |
59+
~/.cargo/registry
60+
~/.cargo/git
61+
target
4562
- name: toolchain
4663
uses: dtolnay/rust-toolchain@stable
4764
with:
@@ -59,9 +76,12 @@ jobs:
5976
-W clippy::perf \
6077
-W clippy::suspicious \
6178
-W clippy::correctness
79+
timeout-minutes: 10
80+
6281
toml-format:
6382
name: toml-format
6483
runs-on: ubuntu-22.04
84+
timeout-minutes: 10
6585
steps:
6686
- name: checkout
6787
uses: actions/checkout@v4
@@ -73,12 +93,15 @@ jobs:
7393
gzip -d > taplo && \
7494
chmod +x taplo && \
7595
sudo mv taplo /usr/local/bin/taplo
96+
timeout-minutes: 5
7697
- name: Run Taplo
7798
run: taplo fmt --check
99+
timeout-minutes: 5
78100

79101
test:
80102
name: test
81103
runs-on: ubuntu-22.04
104+
timeout-minutes: 30
82105
services:
83106
postgres:
84107
image: postgres:13
@@ -96,9 +119,17 @@ jobs:
96119
steps:
97120
- name: checkout
98121
uses: actions/checkout@v4
122+
- name: Cache Rust dependencies
123+
uses: Swatinem/rust-cache@v2
124+
with:
125+
cache-directories: |
126+
~/.cargo/registry
127+
~/.cargo/git
128+
target
99129
- name: toolchain
100130
uses: dtolnay/rust-toolchain@stable
101131
with:
102132
toolchain: ${{ env.toolchain }}
103133
- name: Unit tests
104134
run: cargo test
135+
timeout-minutes: 20

.github/workflows/coverage.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ concurrency:
1717
jobs:
1818
coverage:
1919
runs-on: ubuntu-22.04
20+
timeout-minutes: 30
2021
services:
2122
postgres:
2223
image: postgres:13
@@ -38,15 +39,27 @@ jobs:
3839
run: |
3940
sudo apt-get update
4041
sudo apt-get install -y pkg-config libtss2-dev
42+
timeout-minutes: 5
43+
44+
- name: Cache Rust dependencies
45+
uses: Swatinem/rust-cache@v2
46+
with:
47+
cache-directories: |
48+
~/.cargo/registry
49+
~/.cargo/git
50+
target
4151
4252
- name: Install cargo-llvm-cov
4353
run: cargo install cargo-llvm-cov
54+
timeout-minutes: 5
4455

4556
- name: Generate coverage
4657
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
58+
timeout-minutes: 15
4759

4860
- name: Upload to Codecov
4961
uses: codecov/codecov-action@v5
5062
with:
5163
token: ${{ secrets.CODECOV_TOKEN }}
5264
files: lcov.info
65+
timeout-minutes: 5

0 commit comments

Comments
 (0)