Skip to content

Commit 351a181

Browse files
feat: added action
1 parent a4d2109 commit 351a181

File tree

1 file changed

+153
-0
lines changed

1 file changed

+153
-0
lines changed

.github/workflows/ci.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Rust CI/CD Pipeline
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, reopened]
7+
8+
env:
9+
RUST_BACKTRACE: 1
10+
11+
jobs:
12+
# Job 1: Format Check
13+
format:
14+
name: Format Check
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install Rust toolchain
21+
uses: dtolnay/rust-toolchain@stable
22+
with:
23+
components: rustfmt
24+
25+
- name: Check formatting
26+
run: cargo fmt --all -- --check
27+
28+
# Job 2: Lint Check
29+
lint:
30+
name: Lint Check
31+
needs: [format]
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Install Rust toolchain
38+
uses: dtolnay/rust-toolchain@stable
39+
with:
40+
components: clippy
41+
42+
- name: Cache cargo registry
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.cargo/registry
47+
~/.cargo/git
48+
target
49+
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
50+
restore-keys: |
51+
${{ runner.os }}-cargo-
52+
53+
- name: Run clippy
54+
run: cargo clippy --all-targets --all-features -- -D warnings
55+
56+
- name: Check documentation
57+
run: cargo doc --no-deps --document-private-items --all-features
58+
env:
59+
RUSTDOCFLAGS: "-D warnings"
60+
61+
# Job 3: Build
62+
build:
63+
name: Build
64+
needs: [lint]
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v4
69+
70+
- name: Install Rust toolchain
71+
uses: dtolnay/rust-toolchain@stable
72+
73+
- name: Cache cargo registry
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
~/.cargo/registry
78+
~/.cargo/git
79+
target
80+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
81+
restore-keys: |
82+
${{ runner.os }}-cargo-
83+
84+
- name: Build project
85+
run: cargo build --verbose --all-features
86+
87+
# Job 4: Test Suite
88+
test:
89+
name: Test Suite
90+
needs: [build]
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
97+
- name: Install Rust toolchain
98+
uses: dtolnay/rust-toolchain@master
99+
with:
100+
toolchain: ${{ matrix.rust }}
101+
102+
- name: Cache cargo registry
103+
uses: actions/cache@v4
104+
with:
105+
path: |
106+
~/.cargo/registry
107+
~/.cargo/git
108+
target
109+
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
110+
restore-keys: |
111+
${{ runner.os }}-${{ matrix.rust }}-cargo-
112+
113+
- name: Run tests
114+
run: cargo test --verbose --all-features
115+
116+
- name: Run integration tests
117+
run: cargo test --verbose --test '*'
118+
119+
- name: Run doc tests
120+
run: cargo test --doc --all-features
121+
122+
# Job 5: Security Audit
123+
security:
124+
name: Security Audit
125+
needs: [test]
126+
runs-on: ubuntu-latest
127+
steps:
128+
- name: Checkout code
129+
uses: actions/checkout@v4
130+
131+
- name: Install Rust toolchain
132+
uses: dtolnay/rust-toolchain@stable
133+
134+
- name: Cache cargo registry
135+
uses: actions/cache@v4
136+
with:
137+
path: |
138+
~/.cargo/registry
139+
~/.cargo/git
140+
target
141+
key: ${{ runner.os }}-cargo-audit-${{ hashFiles('**/Cargo.lock') }}
142+
143+
- name: Install cargo-audit
144+
run: cargo install cargo-audit
145+
146+
- name: Run security audit
147+
run: cargo audit
148+
149+
- name: Install cargo-deny
150+
run: cargo install cargo-deny
151+
152+
- name: Run cargo-deny
153+
run: cargo deny check

0 commit comments

Comments
 (0)