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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: CI
on:
push:
branches:
paths-ignore:
- 'CHANGELOG.md'
- 'README.md'
pull_request:
branches:
paths-ignore:
- 'CHANGELOG.md'
- 'README.md'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
jobs:
# ── Stage 1: Lint (fast gate — fails early before burning compute) ────────
# Pattern lifted from ZeroClaw: run fmt + clippy first. If either fails,
# every downstream job is skipped. Avoids burning ~25 min on the
# cross-platform build/test matrix for a PR that won't lint anyway.
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install Rust (from rust-toolchain.toml)
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- uses: swatinem/rust-cache@v2
with:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install ALSA dev (for local-stt feature)
run: sudo apt-get update -qq && sudo apt-get install -y libasound2-dev
- name: Check formatting
# Soft-fail: legacy un-formatted code blocks shouldn't block PRs
# yet. Promote to hard-fail once a fmt sweep lands on main.
continue-on-error: true
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --locked --lib --bins --tests --all-features -- -D warnings
# ── Stage 2: Build verification (parallel, gated on lint) ────────────────
# Cross-platform BUILD on Windows + macOS confirms target compatibility
# without running tests there (tests run on Linux only — see `test`
# below). Why: Windows runners are 3-5x slower than Linux for cargo,
# and most of our test surface is platform-independent. ZeroClaw uses
# the same pattern. If a Windows/macOS-specific test ever regresses
# we can promote it via the matrix.
build:
name: Build (${{ matrix.target }})
needs:
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
# release.yml uses --all-features on Windows too (line 147),
# so the local-stt/local-tts crate chain DOES build on
# windows-msvc. Mirror that here to catch any platform
# regression before release time.
features: --all-features
- os: macos-latest
target: aarch64-apple-darwin
features: --all-features
steps:
- uses: actions/checkout@v4
- name: Install Rust (from rust-toolchain.toml)
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: ${{ matrix.target }}
# rust-cache deliberately skipped on Windows — ZeroClaw confirmed
# the cache rarely pays off there and sometimes flakes the runner.
- uses: swatinem/rust-cache@v2
if: runner.os != 'Windows'
with:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install CMake (Windows)
if: runner.os == 'Windows'
uses: lukka/get-cmake@latest
- name: Install NASM (Windows)
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@v1
- name: Build (Windows)
if: runner.os == 'Windows'
env:
AWS_LC_SYS_CMAKE_BUILDER: "1"
run: cargo build --locked --profile ci --target ${{ matrix.target }} ${{ matrix.features }}
- name: Build (macOS)
if: runner.os == 'macOS'
env:
CFLAGS: -march=armv8-a+crypto
CXXFLAGS: -march=armv8-a+crypto
run: cargo build --locked --profile ci --target ${{ matrix.target }} ${{ matrix.features }}
# ── Stage 3: Test on Linux (gated on lint, parallel with build) ──────────
# Tests run on Linux only — Windows/macOS get build verification via
# the `build` job above. ZeroClaw uses the same split because the
# cross-platform matrix triples wall-clock for little extra coverage
# on this codebase (most tests are platform-independent).
#
# Stays on `cargo test` for now: a few timing-sensitive tests
# (rate_limiter pacing) rely on cargo test's threadpool semantics
# and fail under nextest's process-per-test isolation. nextest
# migration is a follow-up once those tests are made portable.
test:
name: Test (Linux)
needs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install Rust (from rust-toolchain.toml)
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- uses: swatinem/rust-cache@v2
with:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install mold + ALSA dev (Linux)
run: sudo apt-get update -qq && sudo apt-get install -y mold clang libasound2-dev
- name: Run tests
env:
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: clang
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: "-C link-arg=-fuse-ld=mold"
run: cargo test --locked --profile ci --all-features --verbose
# ── Stage 4: Security (parallel with test/build, gated on lint) ──────────
audit:
name: Cargo Audit
needs:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Install Rust (from rust-toolchain.toml)
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-audit
- name: Run cargo audit
# Ignored advisory:
# RUSTSEC-2024-0437 protobuf 2.x via prometheus 0.13.4 → crabrace 0.1.0
# DOS-class (uncontrolled recursion). No upstream fix without a
# major-version bump in the prometheus chain we don't control.
# Re-evaluate when crabrace ships a release that drops prometheus
# 0.13.x.
run: cargo audit --ignore RUSTSEC-2024-0437
# ── Stage 5: Coverage (gated on lint, runs only on main pushes) ──────────
# Coverage runs only on main to save PR wall-clock — tarpaulin is the
# slowest job (~12 min). PRs still get full test coverage via the
# `test` job above; this job just publishes the report.
coverage:
name: Code Coverage
needs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
with:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Rust (from rust-toolchain.toml)
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install ALSA dev
run: sudo apt-get update -qq && sudo apt-get install -y libasound2-dev
- name: Install tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Generate coverage
run: cargo tarpaulin --locked --out Xml --no-default-features --features "telegram,whatsapp,discord,slack,trello"
# Note: local-stt excluded — tarpaulin uses rust-lld which can't handle
# duplicate ggml symbols from whisper-rs-sys + llama-cpp-sys-2.
# local-tts added when feature lands on main.
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./cobertura.xml
# ── Required gate ────────────────────────────────────────────────────────
# Single status check for branch protection. Internal job structure
# can change without touching branch protection settings.
# Coverage is intentionally excluded — it's main-only.
ci-gate:
name: CI Required Gate
if: always()
needs:
runs-on: ubuntu-latest
steps:
- name: Check results
run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
echo "::error::One or more CI jobs failed or were cancelled"
exit 1
fi