Skip to content

Commit 49dfc63

Browse files
committed
add lint and ci
1 parent f04496d commit 49dfc63

File tree

11 files changed

+1144
-1
lines changed

11 files changed

+1144
-1
lines changed

.github/workflows/ci.yml

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

.github/workflows/quick-ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Quick CI
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master, develop ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
check:
14+
name: Format & Lint & Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: rustfmt, clippy
23+
24+
- name: Cache dependencies
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cargo/registry
29+
~/.cargo/git
30+
target
31+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
33+
- name: Check formatting
34+
run: cargo fmt --all -- --check
35+
36+
- name: Run Clippy
37+
run: cargo clippy --all-targets -- -D warnings
38+
39+
- name: Build
40+
run: cargo build --verbose
41+
42+
- name: Run tests
43+
run: cargo test --verbose
44+
45+
- name: Build release
46+
run: cargo build --release --verbose

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
create-release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Create Release
19+
uses: softprops/action-gh-release@v1
20+
with:
21+
draft: false
22+
prerelease: false
23+
generate_release_notes: true
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
publish-crate:
28+
name: Publish to crates.io
29+
needs: create-release
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@stable
36+
37+
- name: Publish to crates.io
38+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
39+
env:
40+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1+
# Rust build artifacts
12
/target
3+
/Cargo.lock
4+
5+
# IDE files
6+
.vscode/
7+
.idea/
8+
*.swp
9+
*.swo
10+
*~
11+
.DS_Store
12+
13+
# Test coverage
14+
tarpaulin-report.html
15+
cobertura.xml
16+
lcov.info
17+
18+
# Backup files
19+
*.bak
20+
*.orig
21+
22+
# OS files
23+
Thumbs.db
24+
.DS_Store

0 commit comments

Comments
 (0)