1+ name : CI/CD Pipeline
2+
3+ on :
4+ push
5+
6+ env :
7+ CARGO_TERM_COLOR : always
8+ RUST_BACKTRACE : 1
9+ RUST_LOG : info
10+
11+ jobs :
12+ # Linting and formatting
13+ lint :
14+ name : Lint and Format
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 cargo registry
25+ uses : actions/cache@v4
26+ with :
27+ path : ~/.cargo/registry
28+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
29+
30+ - name : Cache cargo index
31+ uses : actions/cache@v4
32+ with :
33+ path : ~/.cargo/git
34+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
35+
36+ - name : Cache cargo build
37+ uses : actions/cache@v4
38+ with :
39+ path : target
40+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
41+
42+ - name : Check formatting
43+ run : cargo fmt -- --check
44+
45+ - name : Run clippy
46+ run : cargo clippy --all-targets --all-features -- -D warnings
47+
48+ # Dependency check
49+ deps :
50+ name : Dependency Check
51+ runs-on : ubuntu-latest
52+ steps :
53+ - uses : actions/checkout@v4
54+
55+ - name : Install Rust
56+ uses : dtolnay/rust-toolchain@stable
57+
58+ - name : Install cargo-outdated
59+ run : cargo install cargo-outdated
60+
61+ - name : Check for outdated dependencies
62+ run : cargo outdated --exit-code 1
63+
64+ # Test on multiple platforms
65+ test :
66+ name : Test Suite
67+ runs-on : ${{ matrix.os }}
68+ strategy :
69+ matrix :
70+ os : [ubuntu-latest, windows-latest, macos-latest]
71+ rust : [stable, beta, nightly]
72+ include :
73+ - os : ubuntu-latest
74+ rust : stable
75+ features : " --all-features"
76+ - os : ubuntu-latest
77+ rust : stable
78+ features : " --no-default-features"
79+ steps :
80+ - uses : actions/checkout@v4
81+
82+ - name : Install Rust
83+ uses : dtolnay/rust-toolchain@master
84+ with :
85+ toolchain : ${{ matrix.rust }}
86+ components : rustfmt, clippy
87+
88+ - name : Cache cargo registry
89+ uses : actions/cache@v4
90+ with :
91+ path : ~/.cargo/registry
92+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
93+
94+ - name : Cache cargo index
95+ uses : actions/cache@v4
96+ with :
97+ path : ~/.cargo/git
98+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
99+
100+ - name : Cache cargo build
101+ uses : actions/cache@v4
102+ with :
103+ path : target
104+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
105+
106+ - name : Build
107+ run : cargo build --verbose ${{ matrix.features }}
108+
109+ - name : Run tests
110+ run : cargo test --verbose ${{ matrix.features }} -- --nocapture
111+
112+ - name : Run integration tests
113+ run : cargo test --verbose ${{ matrix.features }} --test '*' -- --nocapture
114+
115+ # Security audit
116+ security :
117+ name : Security Audit
118+ runs-on : ubuntu-latest
119+ steps :
120+ - uses : actions/checkout@v4
121+
122+ - name : Install Rust
123+ uses : dtolnay/rust-toolchain@stable
124+
125+ - name : Install cargo-audit
126+ run : cargo install cargo-audit
127+
128+ - name : Run security audit
129+ run : cargo audit
130+
131+ # Performance benchmarks
132+ benchmark :
133+ name : Performance Benchmarks
134+ runs-on : ubuntu-latest
135+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
136+ steps :
137+ - uses : actions/checkout@v4
138+
139+ - name : Install Rust
140+ uses : dtolnay/rust-toolchain@stable
141+
142+ - name : Cache cargo registry
143+ uses : actions/cache@v4
144+ with :
145+ path : ~/.cargo/registry
146+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
147+
148+ - name : Cache cargo index
149+ uses : actions/cache@v4
150+ with :
151+ path : ~/.cargo/git
152+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
153+
154+ - name : Cache cargo build
155+ uses : actions/cache@v4
156+ with :
157+ path : target
158+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
159+
160+ - name : Install criterion
161+ run : cargo install cargo-criterion
162+
163+ - name : Run benchmarks
164+ run : cargo bench --verbose
165+
166+ - name : Upload benchmark results
167+ uses : actions/upload-artifact@v4
168+ with :
169+ name : benchmark-results
170+ path : target/criterion/
171+
172+ # Documentation
173+ docs :
174+ name : Documentation
175+ runs-on : ubuntu-latest
176+ steps :
177+ - uses : actions/checkout@v4
178+
179+ - name : Install Rust
180+ uses : dtolnay/rust-toolchain@stable
181+
182+ - name : Cache cargo registry
183+ uses : actions/cache@v4
184+ with :
185+ path : ~/.cargo/registry
186+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
187+
188+ - name : Cache cargo index
189+ uses : actions/cache@v4
190+ with :
191+ path : ~/.cargo/git
192+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
193+
194+ - name : Cache cargo build
195+ uses : actions/cache@v4
196+ with :
197+ path : target
198+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
199+
200+ - name : Build documentation
201+ run : cargo doc --all-features --no-deps
202+
203+ - name : Check documentation
204+ run : cargo doc --all-features --no-deps --document-private-items
205+
206+ - name : Upload documentation
207+ uses : actions/upload-artifact@v4
208+ with :
209+ name : documentation
210+ path : target/doc/
211+
212+ # Release build
213+ release :
214+ name : Release Build
215+ runs-on : ${{ matrix.os }}
216+ needs : [lint, test, security, deps]
217+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
218+ strategy :
219+ matrix :
220+ os : [ubuntu-latest, windows-latest, macos-latest]
221+ steps :
222+ - uses : actions/checkout@v4
223+
224+ - name : Install Rust
225+ uses : dtolnay/rust-toolchain@stable
226+
227+ - name : Cache cargo registry
228+ uses : actions/cache@v4
229+ with :
230+ path : ~/.cargo/registry
231+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
232+
233+ - name : Cache cargo index
234+ uses : actions/cache@v4
235+ with :
236+ path : ~/.cargo/git
237+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
238+
239+ - name : Cache cargo build
240+ uses : actions/cache@v4
241+ with :
242+ path : target
243+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
244+
245+ - name : Build release
246+ run : cargo build --release --verbose
247+
248+ - name : Run release tests
249+ run : cargo test --release --verbose -- --nocapture
250+
251+ - name : Upload release artifacts
252+ uses : actions/upload-artifact@v4
253+ with :
254+ name : release-${{ matrix.os }}
255+ path : target/release/
256+
257+ # Integration tests
258+ integration :
259+ name : Integration Tests
260+ runs-on : ubuntu-latest
261+ needs : [lint, test, deps]
262+ steps :
263+ - uses : actions/checkout@v4
264+
265+ - name : Install Rust
266+ uses : dtolnay/rust-toolchain@stable
267+
268+ - name : Cache cargo registry
269+ uses : actions/cache@v4
270+ with :
271+ path : ~/.cargo/registry
272+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
273+
274+ - name : Cache cargo index
275+ uses : actions/cache@v4
276+ with :
277+ path : ~/.cargo/git
278+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
279+
280+ - name : Cache cargo build
281+ uses : actions/cache@v4
282+ with :
283+ path : target
284+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
285+
286+ - name : Build
287+ run : cargo build --verbose
288+
289+ - name : Run integration tests
290+ run : cargo test --verbose --test integration_tests -- --nocapture
291+
292+ - name : Test CLI functionality
293+ run : |
294+ cargo build --release
295+ ./target/release/purr --help
296+ ./target/release/purr genkey test_key
297+ echo "Hello World!" > test_input.txt
298+ ./target/release/purr encrypt --recipient test_key --input test_input.txt --output test_encrypted.purr
299+ ./target/release/purr decrypt --key test_key --input test_encrypted.purr --output test_decrypted.txt
300+ diff test_input.txt test_decrypted.txt
301+ rm -f test_key.pub test_key.sec test_input.txt test_encrypted.purr test_decrypted.txt
302+
303+ # Code coverage
304+ coverage :
305+ name : Code Coverage
306+ runs-on : ubuntu-latest
307+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
308+ steps :
309+ - uses : actions/checkout@v4
310+
311+ - name : Install Rust
312+ uses : dtolnay/rust-toolchain@stable
313+
314+ - name : Install cargo-tarpaulin
315+ run : cargo install cargo-tarpaulin
316+
317+ - name : Cache cargo registry
318+ uses : actions/cache@v4
319+ with :
320+ path : ~/.cargo/registry
321+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
322+
323+ - name : Cache cargo index
324+ uses : actions/cache@v4
325+ with :
326+ path : ~/.cargo/git
327+ key : ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
328+
329+ - name : Cache cargo build
330+ uses : actions/cache@v4
331+ with :
332+ path : target
333+ key : ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
334+
335+ - name : Run coverage
336+ run : cargo tarpaulin --verbose --all-features --out Html
337+
338+ - name : Upload coverage
339+ uses : actions/upload-artifact@v4
340+ with :
341+ name : coverage-report
342+ path : tarpaulin-report.html
343+
344+ # Notify on failure
345+ notify :
346+ name : Notify on Failure
347+ runs-on : ubuntu-latest
348+ needs : [lint, test, security, deps, docs, integration]
349+ if : failure()
350+ steps :
351+ - name : Notify failure
352+ run : |
353+ echo "One or more CI jobs failed!"
354+ echo "Please check the logs for details."
0 commit comments