Skip to content

Commit b7353b7

Browse files
ci: add Android and Rust CI workflows
- test-android.yaml: builds Rust .so for all ABIs with NDK, runs connected Android tests on emulator - rust-ci.yaml: builds, tests, clippy, and fmt checks on changes to floresta-ffi/ - Adapted from bitcoindevkit/bdk-ffi CI configuration
1 parent 6ece9bf commit b7353b7

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

.github/workflows/rust-ci.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Rust Continuous Integration
2+
3+
on:
4+
push:
5+
paths:
6+
- "floresta-ffi/**"
7+
pull_request:
8+
paths:
9+
- "floresta-ffi/**"
10+
11+
permissions: {}
12+
13+
jobs:
14+
test:
15+
name: "Run tests"
16+
runs-on: ubuntu-24.04
17+
defaults:
18+
run:
19+
working-directory: floresta-ffi
20+
21+
steps:
22+
- name: "Checkout"
23+
uses: actions/checkout@v5
24+
with:
25+
persist-credentials: false
26+
27+
- name: "Set up Rust"
28+
uses: actions-rust-lang/setup-rust-toolchain@v1
29+
with:
30+
cache: false
31+
32+
- name: "Check Cargo.lock"
33+
run: |
34+
if ! cargo check --locked; then
35+
echo "::error::Cargo.lock is stale. Run 'cargo generate-lockfile'."
36+
exit 1
37+
fi
38+
39+
- name: "Build"
40+
run: cargo build
41+
42+
- name: "Test"
43+
run: cargo test
44+
45+
check:
46+
name: "Run clippy and fmt"
47+
needs: test
48+
runs-on: ubuntu-24.04
49+
defaults:
50+
run:
51+
working-directory: floresta-ffi
52+
steps:
53+
- name: "Checkout"
54+
uses: actions/checkout@v5
55+
with:
56+
persist-credentials: false
57+
58+
- uses: actions-rust-lang/setup-rust-toolchain@v1
59+
with:
60+
cache: false
61+
components: clippy, rustfmt
62+
63+
- name: "Check fmt"
64+
run: cargo fmt --all -- --check
65+
66+
- name: "Check clippy"
67+
run: cargo clippy --all-targets
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Test Android
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- "floresta-ffi/**"
8+
- "floresta-android/**"
9+
pull_request:
10+
paths:
11+
- "floresta-ffi/**"
12+
- "floresta-android/**"
13+
14+
permissions: {}
15+
16+
jobs:
17+
test:
18+
name: "Test Android library"
19+
runs-on: ubuntu-24.04
20+
21+
steps:
22+
- name: "Checkout PR branch"
23+
uses: actions/checkout@v5
24+
with:
25+
persist-credentials: false
26+
27+
- name: "Set up JDK"
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: temurin
31+
java-version: 17
32+
33+
- name: "Set up Android SDK"
34+
uses: android-actions/setup-android@v3
35+
36+
- name: "Set up Android NDK"
37+
uses: nttld/setup-ndk@v1
38+
with:
39+
ndk-version: r26c
40+
41+
- name: "Set up Rust"
42+
uses: actions-rust-lang/setup-rust-toolchain@v1
43+
with:
44+
cache: false
45+
46+
- name: "Build Android library"
47+
run: |
48+
cd floresta-android
49+
bash ./scripts/release/build-release-linux-x86_64.sh
50+
51+
- name: "Free Disk Space (Ubuntu)"
52+
uses: AdityaGarg8/remove-unwanted-software@v5
53+
with:
54+
remove-dotnet: true
55+
remove-haskell: true
56+
remove-codeql: true
57+
remove-docker-images: true
58+
remove-large-packages: false
59+
60+
- name: "Enable KVM"
61+
run: |
62+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
63+
sudo udevadm control --reload-rules
64+
sudo udevadm trigger --name-match=kvm
65+
66+
- name: "Run Android connected tests"
67+
uses: reactivecircus/android-emulator-runner@v2
68+
with:
69+
api-level: 34
70+
target: google_apis
71+
arch: x86_64
72+
profile: Nexus 6
73+
emulator-options: "-no-window -gpu swiftshader_indirect -no-snapshot"
74+
script: cd floresta-android && ./gradlew connectedAndroidTest --console=plain

0 commit comments

Comments
 (0)