Skip to content

Commit aa804d2

Browse files
committed
add github ci config
1 parent d9ac176 commit aa804d2

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed

.github/workflows/ci.yml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
RUST_BACKTRACE: 1
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
test:
15+
name: Test Suite
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
matrix:
19+
os: [ubuntu-latest, macos-latest]
20+
rust: [stable]
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install Rust
25+
uses: dtolnay/rust-toolchain@master
26+
with:
27+
toolchain: ${{ matrix.rust }}
28+
29+
- name: Cache cargo registry
30+
uses: actions/cache@v4
31+
with:
32+
path: ~/.cargo/registry
33+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
34+
restore-keys: |
35+
${{ runner.os }}-cargo-registry-
36+
37+
- name: Cache cargo index
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cargo/git
41+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
42+
restore-keys: |
43+
${{ runner.os }}-cargo-index-
44+
45+
- name: Cache target directory
46+
uses: actions/cache@v4
47+
with:
48+
path: target
49+
key: ${{ runner.os }}-target-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
50+
restore-keys: |
51+
${{ runner.os }}-target-${{ matrix.rust }}-
52+
53+
- name: Run tests
54+
run: cargo test --all-features
55+
56+
fmt:
57+
name: Rustfmt
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Install Rust
63+
uses: dtolnay/rust-toolchain@stable
64+
with:
65+
components: rustfmt
66+
67+
- name: Check formatting
68+
run: cargo fmt --all -- --check
69+
70+
clippy:
71+
name: Clippy
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Install Rust
77+
uses: dtolnay/rust-toolchain@stable
78+
with:
79+
components: clippy
80+
81+
- name: Cache cargo registry
82+
uses: actions/cache@v4
83+
with:
84+
path: ~/.cargo/registry
85+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
86+
restore-keys: |
87+
${{ runner.os }}-cargo-registry-
88+
89+
- name: Cache cargo index
90+
uses: actions/cache@v4
91+
with:
92+
path: ~/.cargo/git
93+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
94+
restore-keys: |
95+
${{ runner.os }}-cargo-index-
96+
97+
- name: Cache target directory
98+
uses: actions/cache@v4
99+
with:
100+
path: target
101+
key: ${{ runner.os }}-target-clippy-${{ hashFiles('**/Cargo.lock') }}
102+
restore-keys: |
103+
${{ runner.os }}-target-clippy-
104+
105+
- name: Run clippy
106+
run: cargo clippy --all-targets --all-features -- -D warnings
107+
108+
build:
109+
name: Build
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v4
113+
114+
- name: Install Rust
115+
uses: dtolnay/rust-toolchain@stable
116+
117+
- name: Cache cargo registry
118+
uses: actions/cache@v4
119+
with:
120+
path: ~/.cargo/registry
121+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
122+
restore-keys: |
123+
${{ runner.os }}-cargo-registry-
124+
125+
- name: Cache cargo index
126+
uses: actions/cache@v4
127+
with:
128+
path: ~/.cargo/git
129+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
130+
restore-keys: |
131+
${{ runner.os }}-cargo-index-
132+
133+
- name: Cache target directory
134+
uses: actions/cache@v4
135+
with:
136+
path: target
137+
key: ${{ runner.os }}-target-build-${{ hashFiles('**/Cargo.lock') }}
138+
restore-keys: |
139+
${{ runner.os }}-target-build-
140+
141+
- name: Build
142+
run: cargo build --all-features --verbose
143+
144+
- name: Build examples
145+
run: cargo build --examples --all-features --verbose
146+
147+
doc:
148+
name: Documentation
149+
runs-on: ubuntu-latest
150+
steps:
151+
- uses: actions/checkout@v4
152+
153+
- name: Install Rust
154+
uses: dtolnay/rust-toolchain@stable
155+
156+
- name: Cache cargo registry
157+
uses: actions/cache@v4
158+
with:
159+
path: ~/.cargo/registry
160+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
161+
restore-keys: |
162+
${{ runner.os }}-cargo-registry-
163+
164+
- name: Cache cargo index
165+
uses: actions/cache@v4
166+
with:
167+
path: ~/.cargo/git
168+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
169+
restore-keys: |
170+
${{ runner.os }}-cargo-index-
171+
172+
- name: Cache target directory
173+
uses: actions/cache@v4
174+
with:
175+
path: target
176+
key: ${{ runner.os }}-target-doc-${{ hashFiles('**/Cargo.lock') }}
177+
restore-keys: |
178+
${{ runner.os }}-target-doc-
179+
180+
- name: Check documentation
181+
run: cargo doc --no-deps --all-features
182+
env:
183+
RUSTDOCFLAGS: -D warnings

0 commit comments

Comments
 (0)