Skip to content

Commit a97cb63

Browse files
committed
ci: add FFI verification workflows for Python, Kotlin, Swift, and Flutter
1 parent dac98b9 commit a97cb63

4 files changed

Lines changed: 193 additions & 0 deletions

File tree

.github/workflows/ffi-flutter.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: FFI - Flutter Bindings
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
verify-flutter:
11+
name: Verify Flutter Bindings
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout CDK
15+
uses: actions/checkout@v4
16+
with:
17+
path: cdk
18+
19+
- name: Checkout CDK Flutter
20+
uses: actions/checkout@v4
21+
with:
22+
repository: cashubtc/cdk_flutter
23+
path: cdk-flutter
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Install Flutter
29+
uses: subosito/flutter-action@v2
30+
with:
31+
channel: 'stable'
32+
33+
- name: Patch Cargo Dependency
34+
run: |
35+
cd cdk-flutter/rust
36+
# Replace crates.io version with local path
37+
# Matches: cdk = { version = "..."... } and replaces with cdk = { path = "../../cdk", ... }
38+
sed -i 's/^cdk = { version = "[^"]*",/cdk = { path = "..\/..\/cdk",/' Cargo.toml
39+
40+
# Verify the change
41+
grep "^cdk =" Cargo.toml
42+
43+
- name: Verify Compilation
44+
run: |
45+
cd cdk-flutter/rust
46+
# Check ensures that the rust code compiles against the local CDK
47+
cargo check

.github/workflows/ffi-kotlin.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: FFI - Kotlin Bindings
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
verify-kotlin:
11+
name: Verify Kotlin Bindings
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout CDK
15+
uses: actions/checkout@v4
16+
with:
17+
path: cdk
18+
19+
- name: Checkout CDK Kotlin
20+
uses: actions/checkout@v4
21+
with:
22+
repository: cashubtc/cdk-kotlin
23+
path: cdk-kotlin
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Install Just
29+
uses: extractions/setup-just@v1
30+
31+
- name: Set up Java
32+
uses: actions/setup-java@v4
33+
with:
34+
distribution: 'temurin'
35+
java-version: '17'
36+
37+
- name: Generate Bindings
38+
run: |
39+
cd cdk-kotlin
40+
# cdk-kotlin justfile expects CDK at ../cdk by default
41+
just generate
42+
43+
- name: Verify Compilation
44+
run: |
45+
cd cdk-kotlin
46+
# Fast check: compiles the code without running emulator tests
47+
just test-compile

.github/workflows/ffi-python.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: FFI - Python Bindings
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
verify-python:
11+
name: Verify Python Bindings
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout CDK
15+
uses: actions/checkout@v4
16+
with:
17+
path: cdk
18+
19+
- name: Checkout CDK Python
20+
uses: actions/checkout@v4
21+
with:
22+
repository: cashubtc/cdk-python
23+
path: cdk-python
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Install Just
29+
uses: extractions/setup-just@v1
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.10"
35+
36+
- name: Install uv
37+
run: pip install uv
38+
39+
- name: Generate Bindings
40+
run: |
41+
cd cdk
42+
# Builds cdk-ffi and generates python bindings to target/bindings/python
43+
just ffi-generate-python
44+
45+
- name: Install and Verify
46+
run: |
47+
# Copy generated bindings to cdk-python source
48+
cp cdk/target/bindings/python/cdk.py cdk-python/src/cdk/
49+
cp cdk/target/bindings/python/libcdk_ffi.so cdk-python/src/cdk/
50+
51+
# Install and Test
52+
cd cdk-python
53+
uv venv
54+
source .venv/bin/activate
55+
uv pip install -e .[dev]
56+
pytest

.github/workflows/ffi-swift.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: FFI - Swift Bindings
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
verify-swift:
11+
name: Verify Swift Bindings
12+
runs-on: macos-latest
13+
steps:
14+
- name: Checkout CDK
15+
uses: actions/checkout@v4
16+
with:
17+
path: cdk
18+
19+
- name: Checkout CDK Swift
20+
uses: actions/checkout@v4
21+
with:
22+
repository: cashubtc/cdk-swift
23+
path: cdk-swift
24+
25+
- name: Install Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Install Just
29+
uses: extractions/setup-just@v1
30+
31+
- name: Generate Bindings
32+
run: |
33+
cd cdk-swift
34+
# Point to the local cdk checkout
35+
export CDK_DIR=../cdk
36+
just generate
37+
38+
- name: Verify Build
39+
run: |
40+
cd cdk-swift
41+
export CDK_DIR=../cdk
42+
# build-native builds for the current platform (macOS) which is faster
43+
just build-native

0 commit comments

Comments
 (0)