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
permissions:
contents: read
name: WASM Build
on:
push:
branches:
pull_request:
branches:
workflow_call:
env:
CARGO_TERM_COLOR: always
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:
wasm:
name: Build whatsapp-rust (wasm32, release)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2026-06-16
targets: wasm32-unknown-unknown
- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.10
# 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"
# Mirrors how whatsapp-rust-bridge consumes the crate: lib only (the
# binary pulls tokio/sqlite), no default features. Guards against code
# reachable from wasm regressing on tokio/std-only APIs.
# getrandom needs both the wasm_js feature (declared for wasm32 in
# Cargo.toml) and this backend cfg.
- name: Build whatsapp-rust lib for wasm32 (release)
env:
RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'
run: >
cargo build -p whatsapp-rust --lib --release
--target wasm32-unknown-unknown
--no-default-features
# The sans-IO VoIP core (wacore::voip: the CallEngine, the portable run_call driver,
# the RelayTransport seam, the MLow codec, SRTP/SFrame crypto) must stay wasm-buildable
# so the WASM bridge can drive 1:1 calls. whatsapp-rust's `voip` feature compile-errors on
# wasm (it pulls webrtc-rs + libopus FFI), so the guard is on the pure core here.
- name: Build wacore VoIP core for wasm32 (release)
env:
RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'
run: >
cargo build -p wacore --lib --release
--target wasm32-unknown-unknown
--no-default-features --features "voip,js"