Skip to content

Commit b1abf2e

Browse files
committed
feat(ci): adds automated Rust code quality CI workflow
Introduces a CI workflow to enforce Rust code formatting, linting, testing, and documentation checks on relevant branches and pull requests. Ensures higher code quality and consistency by automating these checks in the development process.
1 parent 57ddad7 commit b1abf2e

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

.github/workflows/code-quality.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Code Quality
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- dev*
9+
- feat*
10+
- fix*
11+
- chore*
12+
- test*
13+
paths:
14+
- "**/*.rs"
15+
- "**/Cargo.toml"
16+
- "Cargo.lock"
17+
- ".github/workflows/code-quality.yml"
18+
pull_request:
19+
types: [ opened, synchronize, reopened, ready_for_review ]
20+
paths:
21+
- "**/*.rs"
22+
- "**/Cargo.toml"
23+
- "Cargo.lock"
24+
- ".github/workflows/code-quality.yml"
25+
26+
env:
27+
CARGO_TERM_COLOR: always
28+
29+
jobs:
30+
check:
31+
name: Code Quality Checks
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Install Rust toolchain
39+
uses: dtolnay/rust-toolchain@stable
40+
with:
41+
components: clippy, rustfmt
42+
43+
- name: Cache Cargo dependencies
44+
uses: actions/cache@v3
45+
with:
46+
path: |
47+
~/.cargo/registry/index
48+
~/.cargo/registry/cache
49+
~/.cargo/git/db
50+
target
51+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-cargo-
54+
55+
- name: Check code formatting
56+
run: cargo fmt --all -- --check
57+
58+
- name: Run Clippy
59+
run: cargo clippy --all-targets --all-features -- -D warnings
60+
61+
- name: Run tests
62+
run: cargo test --all-features
63+
64+
- name: Check documentation
65+
run: cargo doc --all-features --no-deps --document-private-items
66+
env:
67+
RUSTDOCFLAGS: -D warnings

0 commit comments

Comments
 (0)