Skip to content

Commit cdd271c

Browse files
committed
Add CI job running the Dart package tests
uniffi-dart-test.yml builds the Dart package (host cdylib + bindings via cargo make dart-package) and runs dart test on PRs/pushes touching livekit-uniffi or its dependencies. The dart build keeps symbols (CARGO_PROFILE_RELEASE_STRIP=false) so library-mode bindgen can read the UNIFFI_META_* metadata, which the release strip removes on Linux.
1 parent e17d256 commit cdd271c

2 files changed

Lines changed: 86 additions & 2 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: UniFFI Dart tests
2+
3+
# Builds the Dart package (dev mode: host cdylib + generated bindings) and runs
4+
# its test suite, exercising the FFI boundary end-to-end. Scoped to changes that
5+
# can affect the livekit-uniffi Dart bindings.
6+
7+
on:
8+
push:
9+
branches: ["main"]
10+
pull_request:
11+
branches: ["main"]
12+
paths:
13+
- "livekit-uniffi/**"
14+
- "livekit-api/**"
15+
- "livekit-protocol/**"
16+
- "Cargo.lock"
17+
- "Cargo.toml"
18+
- ".cargo/**"
19+
- ".github/workflows/uniffi-dart-test.yml"
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
dart-test:
26+
name: Dart package tests
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
30+
with:
31+
submodules: true
32+
33+
- name: Setup Rust toolchain
34+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
35+
with:
36+
cache: false
37+
rustflags: ""
38+
39+
- name: Install Protoc
40+
uses: arduino/setup-protoc@a8b67ba40b37d35169e222f3bb352603327985b6 # v2.1.0
41+
with:
42+
version: "25.2"
43+
repo-token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Setup Dart
46+
uses: dart-lang/setup-dart@65eb853c7ba17dde3be364c3d2858773e7144260 # v1.7.2
47+
with:
48+
sdk: stable
49+
50+
- name: Cache cargo registry
51+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
52+
with:
53+
path: |
54+
~/.cargo/registry/index/
55+
~/.cargo/registry/cache/
56+
~/.cargo/git/db/
57+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
58+
restore-keys: |
59+
${{ runner.os }}-cargo-registry-
60+
61+
- name: Cache cargo target
62+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
63+
with:
64+
path: target/
65+
key: ${{ runner.os }}-cargo-target-dart-${{ hashFiles('**/Cargo.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-cargo-target-dart-
68+
69+
- name: Install cargo-make
70+
run: cargo install --locked cargo-make
71+
72+
- name: Build Dart package
73+
working-directory: livekit-uniffi
74+
run: cargo make dart-package
75+
76+
- name: Run Dart tests
77+
working-directory: livekit-uniffi/packages/dart
78+
run: |
79+
dart pub get
80+
dart test

livekit-uniffi/Makefile.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ run_task = "android-publish-maven-local"
625625
[tasks.bindgen-dart]
626626
description = "Generate Dart bindings"
627627
dependencies = ["build", "locate-lib"]
628-
env = { LANG = "dart" }
628+
# Library-mode bindgen reads UNIFFI_META_* symbols from the cdylib. The release
629+
# profile's `strip = "symbols"` removes them on Linux (macOS strips less
630+
# aggressively), leaving no metadata to generate from — so keep symbols here.
631+
env = { LANG = "dart", CARGO_PROFILE_RELEASE_STRIP = "false" }
629632
script_runner = "@duckscript"
630633
script = """
631634
out_dir = join_path ${PACKAGES_DIR} ${LANG}
@@ -700,5 +703,6 @@ dependencies = [
700703

701704
[tasks.dart-package]
702705
description = "Build a consumable Dart package with bindings, hook, and (dev) native lib"
703-
env = { LANG = "dart" }
706+
# See bindgen-dart: keep symbols so library-mode bindgen can read metadata.
707+
env = { LANG = "dart", CARGO_PROFILE_RELEASE_STRIP = "false" }
704708
run_task = "dart-package-flow"

0 commit comments

Comments
 (0)