1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Rust CI
on:
push:
branches:
pull_request:
branches:
permissions:
contents: read
# Cancel in-progress runs if a new commit is pushed to the same pull request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
# ==============================================================================
# Job 1: Check Code Formatting
# Runs on Linux because code styling is OS-agnostic.
# Running this on Windows/macOS is redundant and consumes extra CI minutes.
# ==============================================================================
fmt:
name: CI-Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# ==============================================================================
# Job 2: Run Clippy Lints (On all platforms)
# Helpful if your workspace uses platform-specific conditional compilation
# (e.g., #[cfg(target_os = "windows")]), which triggers different lints on different OSs.
# ==============================================================================
clippy:
name: CI-Clippy (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Keep running on other OSs even if one fails
matrix:
os:
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Run Clippy (warnings as errors)
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
# ==============================================================================
# Job 3: Run Tests (On all platforms)
# Crucial for verifying platform-specific behaviors, file systems, and OS-specific APIs.
# ==============================================================================
test:
name: CI-Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run all workspace tests
run: cargo test --workspace --all-features
# ==============================================================================
# Job 4: Build and Verify Documentation (On all platforms)
# Ensures rustdoc compiles successfully across all operating systems.
# ==============================================================================
docs:
name: CI-Docs (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Build documentation (warnings as errors)
run: cargo doc --no-deps --workspace --all-features
env:
RUSTDOCFLAGS: "-D warnings"