Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,73 @@
./gradlew :examples:simple_client:build
./gradlew :examples:quic_client:build

swift-bindings:
name: Swift Bindings
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
with:
components: llvm-tools-preview

- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov

- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-swift-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-swift-

- name: Build Rust, Generate Swift Bindings, and Verify swift build
run: ./scripts/build_swift_bindings.sh --coverage --test

- name: Export coverage to lcov
run: |
PROFDATA_VAR=$(cargo +stable llvm-cov show-env | grep LLVM_PROFDATA) || true
PROFDATA_TOOL=$(echo "$PROFDATA_VAR" | cut -d= -f2- | tr -d '"' | tr -d "'" | xargs)
if [ -z "$PROFDATA_TOOL" ] || [ ! -x "$PROFDATA_TOOL" ]; then
export PATH="$(rustc --print=target-libdir)/../bin:$PATH"
PROFDATA_TOOL=$(which llvm-profdata)
fi
if ls target/llvm-cov-target/*.profraw 2>/dev/null; then
"$PROFDATA_TOOL" merge -sparse target/llvm-cov-target/*.profraw \
-o target/llvm-cov-target/swift-cov.profdata
llvm-cov export -format=lcov \
--instr-profile target/llvm-cov-target/swift-cov.profdata \
-object target/debug/libflowsdk_ffi.dylib \
> lcov-swift.info
else
echo "No profraw files found; skipping lcov export."
fi

- name: Upload coverage artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: swift-coverage-data
path: |
lcov-swift.info
target/llvm-cov-target/swift-cov.profdata
target/llvm-cov-target/*.profraw
retention-days: 7

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'CI' step
Uses Step
uses 'codecov/codecov-action' with ref 'v4', not a pinned commit hash
with:
files: lcov-swift.info
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

coverage:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
name: Code Coverage
runs-on: ubuntu-latest
Expand Down Expand Up @@ -286,6 +353,8 @@
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest

Expand Down
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@ Cargo.lock
*.profraw
*.profdata


# FFI generated code
# Swift: runtime library copies and XCFramework build artifacts (populated by build_swift_bindings.sh)
swift/.build/
swift/.swiftpm/
swift/lib/
swift/Generated/
swift/xcframework-intermediates/
swift/FlowSDK.xcframework/


# FFI generated code (regenerated by scripts/build_*_bindings.sh; feature-dependent)
swift/Sources/FlowSDK/flowsdk_ffi.swift
swift/Sources/flowsdk_ffi/flowsdk_ffi.h
kotlin/package/src/main/kotlin/uniffi/flowsdk_ffi/flowsdk_ffi.kt
python/package/flowsdk/flowsdk_ffi.py
python/package/flowsdk/libflowsdk_ffi.dylib
python/package/flowsdk/libflowsdk_ffi.so
Expand All @@ -22,6 +33,7 @@ python/examples/*.so
python/examples/*.dll

python/**/*.pyc
python/package/flowsdk.egg-info/

# Kotlin Examples (generated files)
kotlin/package/src/main/resources/libflowsdk_ffi.dylib
Expand Down
24 changes: 12 additions & 12 deletions examples/no_io_tokio_quic_client_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ async fn run_example() -> Result<(), Box<dyn std::error::Error>> {
event = client.next_event() => {
let Some(event) = event else { break; };
match event {
MqttEvent::Connected(_) => {
if !subscribed {
let sub_cmd = SubscribeCommand::builder().add_topic("test/topic/wrapper", 1).build()?;
client.subscribe(sub_cmd).await.map_err(|e| e.to_string())?;
subscribed = true;
}
MqttEvent::Connected(_)
if !subscribed =>
{
let sub_cmd = SubscribeCommand::builder().add_topic("test/topic/wrapper", 1).build()?;
client.subscribe(sub_cmd).await.map_err(|e| e.to_string())?;
subscribed = true;
}
MqttEvent::Subscribed(res) => {
MqttEvent::Subscribed(res)
if !published =>
{
println!("Subscribed: ID={:?}", res.packet_id);
if !published {
let pub_cmd = PublishCommand::builder().topic("test/topic/wrapper").payload("Hello!".to_string()).qos(1).build()?;
client.publish(pub_cmd).await.map_err(|e| e.to_string())?;
published = true;
}
let pub_cmd = PublishCommand::builder().topic("test/topic/wrapper").payload("Hello!".to_string()).qos(1).build()?;
client.publish(pub_cmd).await.map_err(|e| e.to_string())?;
published = true;
}
MqttEvent::Published(res) => {
println!("Published: ID={:?}", res.packet_id);
Expand Down
Loading
Loading