Repository navigation
466 lines (453 loc) · 20.9 KB
/
Copy pathmain.yml
File metadata and controls
466 lines (453 loc) · 20.9 KB
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
permissions:
contents: read
name: Rust CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
concurrency:
# The decision point for every `workflow_call`-able workflow here; the others
# carry a one-line pointer rather than a copy of this.
#
# Cancelling is scoped to `pull_request`. A push to main and a run started by
# `release.yml` calling this workflow must both finish, so neither may cancel
# the other. `github.event_name` is in the group for exactly that: it is what
# keeps a release validating main out of the same group as a `push` run on
# main, which would otherwise cancel it. docker.yml already grouped on the
# event name for this reason before any of these did.
#
# `release.yml` calls main.yml, e2e.yml and docker.yml today; miri.yml,
# supply-chain.yml and wasm.yml expose `workflow_call` without a caller yet,
# and are grouped the same way so adding one is not a silent cancellation bug.
group: rust-ci-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
PROTOC_VERSION: '3.25.3'
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
# The target dir is restored fresh each run (Swatinem cache), so incremental
# state is always cold and only bloats artifacts; worse, sccache refuses to
# cache incremental compilations, so leaving it on excludes the workspace
# crates from caching entirely.
CARGO_INCREMENTAL: "0"
jobs:
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
components: rustfmt
- name: Check Bartender image pins
env:
RUSTC_WRAPPER: ""
run: cargo xt ci sync-bartender-image --check
- run: cargo fmt --all -- --check
generated:
name: Generated Artifacts
runs-on: ubuntu-latest
# The vendored whatspec files are regenerated, never edited, and the tool
# that writes them pins the exact IR commit — so a hand-edit or a
# half-refreshed tree is a diff this job can name. Lives beside `format`
# rather than in a build job: it needs rustfmt and git, not protoc (--check
# never rebuilds the descriptor) and not a compiled workspace.
# Bounded because the step fetches an external repository: a hung fetch
# would otherwise hold a required check open for the full six hours.
timeout-minutes: 15
steps:
# This job never pushes, and the codegen shells out to `git fetch` against
# a different repository; the checkout token has no business being left in
# .git/config for that.
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
components: rustfmt
# RUSTC_WRAPPER is set workspace-wide, so cargo needs sccache on PATH even
# in a job this small.
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- run: cargo run -p whatspec-codegen -- --check
clippy:
name: Clippy Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
components: clippy
# The voip example (built under --all-targets) links cpal, which needs ALSA headers.
- name: Install ALSA dev headers
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install protoc
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }}
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
- name: Run Clippy
run: cargo clippy --all-targets -- -D warnings
test:
name: Build & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Reclaim unused Android SDK space
run: |
df -h /
sudo rm -rf --one-file-system /usr/local/lib/android
df -h /
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
# The voip example (built under --all-targets) links cpal, which needs ALSA headers.
- name: Install ALSA dev headers
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
# cargo-nextest ships pre-built binaries (nexte.st/docs/installation/pre-built-binaries),
# which is what install-action fetches — no compile step on the runner.
- name: Install protoc and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }},cargo-nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
# No separate build step. There used to be one, and it was pure waste: in
# three different spellings, `cargo build --all-targets`, `cargo test
# --all-targets --no-run`, and finally nextest's own `--no-run` build, the
# step below went on to recompile the same thirteen crates anyway. Measured
# on the runner with the last of those, which differs from the step below
# only by `--no-run`: 223s to build, then 189s recompiling before the first
# test ran. Whatever cargo is keying on there, nothing the build step
# produced was reusable, so the workspace is compiled once, here.
#
# What that gives up is a job whose default-feature targets all link:
# benches and examples are not test targets, so nextest does not build
# them. `Clippy Linter` still compiles them on this same push, and `Build &
# Lint (all features)` still links them with all features on. The seam left
# is a target that links with all features and not with the default set.
- name: Run tests
env:
NEXTEST_PROFILE: ci
TEST_TIMINGS_DIR: ${{ runner.temp }}/test-timings
run: cargo xt ci nextest-timed workspace -- --workspace --exclude e2e-tests
- name: Publish test timings
if: always()
uses: actions/upload-artifact@v7
with:
name: test-timings-build-and-test
path: ${{ runner.temp }}/test-timings
retention-days: 14
if-no-files-found: warn
# v4 artifacts are immutable and scoped to the run, not the attempt,
# and `if: always()` means attempt 1 uploaded even when it failed. So
# a rerun of a failed job would 409 here and finish red with green
# tests, which is the opposite of what these reports are for. Same
# reason on every timing upload below and in e2e.yml.
overwrite: true
# nextest cannot run doctests (nextest-rs/nextest#16) and silently reports
# none, so they need their own libtest step — the workspace has ~200 doc
# examples whose compilation is asserted nowhere else.
- name: Run doctests
run: cargo test --workspace --exclude e2e-tests --doc --verbose
waproto-serde:
name: waproto serde representations
runs-on: ubuntu-latest
# waproto serde tests are feature-gated and produce zero tests under the
# default feature set, so each representation has to be built on its own.
# Its own job rather than two more steps on `Build & Test`: 11 tests that
# run in 20ms cost ~104s of recompiling waproto with a different feature
# set, and paying that on the workflow's most-read job put it on the
# critical path for nothing. Here it runs beside everything else.
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
- name: Install protoc and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }},cargo-nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
# No doctest counterpart: the features only swap derives on generated
# code, whose doc comments `Build & Test` already builds.
- name: Test waproto serde representations
env:
NEXTEST_PROFILE: ci
TEST_TIMINGS_DIR: ${{ runner.temp }}/test-timings
run: cargo xt ci test-waproto-features
- name: Publish test timings
if: always()
uses: actions/upload-artifact@v7
with:
name: test-timings-waproto-serde
path: ${{ runner.temp }}/test-timings
retention-days: 14
if-no-files-found: warn
overwrite: true
test-all-features:
name: Build & Lint (all features)
runs-on: ubuntu-latest
# Runs on every PR (no voip path filter): the voip-gated code is scattered across the client,
# handler, send and stanza layers, so enumerating its files in a path filter kept leaking. The
# webrtc/opus tree compiles once and is cached (sccache), so the steady-state cost is the
# workspace recompile with voip on, not the deps. The heavy relay e2e tests stay out of `--lib`.
steps:
- uses: actions/checkout@v7
- name: Reclaim unused Android SDK space
run: |
df -h /
sudo rm -rf --one-file-system /usr/local/lib/android
df -h /
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
# The voip example (built under --all-features --all-targets) links cpal,
# which needs ALSA on Linux.
- name: Install ALSA dev headers
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install protoc and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }},cargo-nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
- name: Build (all features)
run: cargo build --workspace --exclude e2e-tests --all-features --all-targets --verbose
- name: Clippy (all features)
run: cargo clippy --workspace --exclude e2e-tests --all-features --all-targets -- -D warnings
# There is no `cargo test --all-features` because a few features cannot
# share a build with the rest. `cargo xt ci test-features` derives the
# set that can from cargo metadata and carries the exclusions with their
# reasons, so a feature added tomorrow is tested without editing CI.
# Compiling a test is not running it: the two `--all-features` steps above
# build the codec suite, its golden checksums and every C/Go ground-truth
# vector among them, but nothing executed them until a step actually
# enabled `voip-mlow` and ran it. That is what this loop does.
- name: Test (every shareable feature)
env:
NEXTEST_PROFILE: ci
TEST_TIMINGS_DIR: ${{ runner.temp }}/test-timings
run: cargo xt ci test-feature-packages wacore wacore-libsignal whatsapp-rust
- name: Publish test timings
if: always()
uses: actions/upload-artifact@v7
with:
name: test-timings-all-features
path: ${{ runner.temp }}/test-timings
retention-days: 14
if-no-files-found: warn
overwrite: true
rustdoc:
name: Rustdoc
runs-on: ubuntu-latest
env:
# Broken intra-doc links and malformed doc attributes are only surfaced by
# rustdoc, never by clippy or rustc, so they need their own gate.
RUSTDOCFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v7
- name: Reclaim unused Android SDK space
run: |
df -h /
sudo rm -rf --one-file-system /usr/local/lib/android
df -h /
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
# The voip-cli member links cpal, which needs ALSA headers.
- name: Install ALSA dev headers
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install protoc
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }}
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
# --all-features so the voip-gated docs are covered too. Default features
# alone would leave their links unchecked, and docs.rs builds with features
# on (hence the `cfg(docsrs)` in the workspace check-cfg).
- name: Build docs
run: cargo doc --workspace --no-deps --all-features
feature-matrix-crates:
name: Feature Matrix (crates)
runs-on: ubuntu-latest
env:
RUSTC_WRAPPER: ""
# The host-only task derives publishable crates from cargo metadata.
outputs:
crates: ${{ steps.crates.outputs.crates }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
- id: crates
run: cargo xt ci feature-matrix-crates --github-output
feature-matrix:
name: Feature Matrix (${{ matrix.crate }})
runs-on: ubuntu-latest
needs: feature-matrix-crates
# Individual features are only ever exercised in the combinations the other
# jobs happen to build (default / --all-features), so a feature whose gates
# are wrong compiles fine there and breaks for a downstream consumer that
# picks it alone.
strategy:
# One crate per runner. `cargo hack` walks a crate's features serially, so
# a single job spent its whole time on seven walks that shared nothing but
# the dependency build, with whatsapp-rust alone most of it. Each leg is
# also an independent question, so one failing must not withdraw the
# verdict on the others.
fail-fast: false
matrix:
crate: ${{ fromJSON(needs.feature-matrix-crates.outputs.crates) }}
steps:
- uses: actions/checkout@v7
# No Android SDK reclaim here, unlike the three jobs that build the whole
# workspace. A runner starts this leg with 87G free and one crate's
# `check` comes nowhere near it, so the `rm -rf` bought 10G nothing asked
# for at a price that ran from 18s to 188s per leg: on wacore-binary it
# was 188s of deleting against 13s of actual checking. That was one step
# when this was a single job, and splitting it per crate multiplied it by
# the number of published crates. The `df` closing the check step below is
# what keeps this claim answerable rather than asserted.
# Pinned toolchain: .cargo/config.toml carries nightly-only rustflags
# (-Zshare-generics) for this target, and this job does not clear them.
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
- name: Install protoc
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }}
- name: Install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
# Each leg builds a different feature set into the same target dir;
# without this they would all write one cache entry and race for it.
key: ${{ matrix.crate }}
# --no-dev-deps: dev-dependencies enable features on the crate under test
# (wacore/test-util, for one), which would mask exactly the gaps this
# job looks for.
- name: Check each feature
run: |
cargo hack check --each-feature --no-dev-deps -p ${{ matrix.crate }}
df -h /
test-stable:
name: Test Stable (MSRV)
runs-on: ubuntu-latest
# .cargo/config.toml sets nightly-only rustflags (-Zshare-generics) for the
# x86_64-linux target; a set-but-empty RUSTFLAGS takes precedence over
# config rustflags, keeping this stable-toolchain job buildable.
env:
RUSTFLAGS: ""
NEXTEST_PROFILE: ci
steps:
- uses: actions/checkout@v7
# Pinned rather than `@stable`: this version is the workspace MSRV
# (`rust-version` in the root Cargo.toml). To raise the floor, bump both
# together — a floating `stable` would silently let the declared MSRV rot.
#
# And it is not Dependabot's to raise. This ref is a Rust version, not a
# release of the action, so the updater bumps it by comparing numbers and
# has no way to know the toolchain has to exist and has to match the
# declared floor. It once moved this to 1.100.0 — numerically the largest
# ref, a Rust release that does not exist — and every pull request in the
# repository failed at `rustup`, before a line was compiled. The
# `dependabot.yml` entry beside this one is what keeps the pin ours.
- uses: dtolnay/rust-toolchain@1.94.1
# The pre-built nextest binary is toolchain-independent — it drives this
# MSRV cargo the same way it drives the nightly one.
- name: Install protoc and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: protoc@${{ env.PROTOC_VERSION }},cargo-nextest
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.11
# Cache the target dir too: sccache can't cache proc-macros, build scripts
# or bins (linker-output crate types), and those recompile every run.
# Swatinem restores them; sccache still fills in after a Cargo.lock change.
- name: Cache Rust build (registry + target)
uses: Swatinem/rust-cache@v2
with:
cache-targets: "true"
# These crates used to be reachable here only with `--no-default-features`,
# because their default `simd` feature pulled in `portable_simd` and so
# needed nightly. There is no SIMD in the tree any more and no feature
# gating it, so this now runs what ships. One nextest invocation retains
# one complete JUnit report and, unlike the host xtask, remains buildable
# by the published Rust 1.94 floor.
- name: Test stable core crates
run: cargo nextest run -p wacore-binary -p wacore-appstate -p wacore --lib
# `rust-version` is published metadata for every member, but only the
# three crates above are exercised at that toolchain. This compiles the
# rest of the publishable set so the declared floor is a checked promise
# rather than an assertion. Check-only: the tests that matter here
# already ran above, and this is about the toolchain accepting the code.
- name: Check the remaining published crates at MSRV
run: >
cargo check --no-default-features --verbose
-p whatsapp-rust -p wacore-derive -p wacore-libsignal -p wacore-noise -p waproto
-p whatsapp-rust-ureq-http-client
-p whatsapp-rust-sqlite-storage -p whatsapp-rust-tokio-transport
# Standalone API hosts run in consumers.yml through the central xtask
# registry; its driver uses nightly while each MSRV host uses 1.94.1.
- name: Publish test timings
if: always()
uses: actions/upload-artifact@v7
with:
name: test-timings-msrv
path: target/nextest/ci/junit.xml
retention-days: 14
if-no-files-found: warn
overwrite: true