Skip to content

Commit 465843f

Browse files
committed
Introduce ci
1 parent 67ecc63 commit 465843f

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

.github/workflows/ci.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
format:
14+
name: Format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt
23+
24+
- name: Check formatting
25+
run: cargo fmt --all -- --check
26+
27+
clippy:
28+
name: Clippy
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Setup Rust
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
components: clippy
37+
38+
- name: Cache cargo registry
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.cargo/registry
42+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
43+
restore-keys: |
44+
${{ runner.os }}-cargo-registry-
45+
46+
- name: Cache cargo index
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cargo/git
50+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
51+
restore-keys: |
52+
${{ runner.os }}-cargo-git-
53+
54+
- name: Cache build artifacts
55+
uses: actions/cache@v4
56+
with:
57+
path: target
58+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-cargo-build-
61+
62+
- name: Run clippy
63+
run: cargo clippy --all-targets --all-features -- -D warnings
64+
65+
check:
66+
name: Check
67+
runs-on: ubuntu-latest
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Setup Rust
72+
uses: dtolnay/rust-toolchain@stable
73+
74+
- name: Cache cargo registry
75+
uses: actions/cache@v4
76+
with:
77+
path: ~/.cargo/registry
78+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
79+
restore-keys: |
80+
${{ runner.os }}-cargo-registry-
81+
82+
- name: Cache cargo index
83+
uses: actions/cache@v4
84+
with:
85+
path: ~/.cargo/git
86+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
87+
restore-keys: |
88+
${{ runner.os }}-cargo-git-
89+
90+
- name: Cache build artifacts
91+
uses: actions/cache@v4
92+
with:
93+
path: target
94+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
95+
restore-keys: |
96+
${{ runner.os }}-cargo-build-
97+
98+
- name: Run cargo check
99+
run: cargo check --all-targets --all-features
100+
101+
test:
102+
name: Test
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Setup Rust
108+
uses: dtolnay/rust-toolchain@stable
109+
110+
- name: Cache cargo registry
111+
uses: actions/cache@v4
112+
with:
113+
path: ~/.cargo/registry
114+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
115+
restore-keys: |
116+
${{ runner.os }}-cargo-registry-
117+
118+
- name: Cache cargo index
119+
uses: actions/cache@v4
120+
with:
121+
path: ~/.cargo/git
122+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
123+
restore-keys: |
124+
${{ runner.os }}-cargo-git-
125+
126+
- name: Cache build artifacts
127+
uses: actions/cache@v4
128+
with:
129+
path: target
130+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
131+
restore-keys: |
132+
${{ runner.os }}-cargo-build-
133+
134+
- name: Run tests
135+
run: cargo test --all-features

0 commit comments

Comments
 (0)