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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Cross-platform CI
on:
push:
branches:
pull_request:
branches:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# Job 1: Linux, Windows, macOS (x86_64 and ARM64)
test-mainstream:
name: ${{ matrix.os }} (${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x86_64
- os: windows-latest
arch: x86_64
- os: macos-15-intel # Intel x86_64
arch: x86_64
- os: macos-latest # Apple Silicon ARM64
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --verbose
- name: Run Tests
run: cargo test --verbose -- --nocapture
- name: Build FFI (release)
run: cargo build --features ffi --release
env:
RUSTFLAGS: "-C panic=abort"
- name: Setup MSVC
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
- name: Build C example (unix)
if: matrix.os != 'windows-latest'
run: cc -I./include examples/ffi.c -L./target/release -lbtree_store -o ffi
- name: Run C example (linux)
if: matrix.os == 'ubuntu-latest'
run: LD_LIBRARY_PATH=./target/release ./ffi
- name: Run C example (macos)
if: startsWith(matrix.os, 'macos')
run: DYLD_LIBRARY_PATH=./target/release ./ffi
- name: Build C example (windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
set BTREE_LIB=btree_store.lib
if exist target\release\btree_store.dll.lib set BTREE_LIB=btree_store.dll.lib
cl /I include examples\ffi.c /Fe:ffi.exe /link /LIBPATH:target\release %BTREE_LIB%
- name: Run C example (windows)
if: matrix.os == 'windows-latest'
shell: cmd
run: |
if exist target\release\btree_store.dll copy target\release\btree_store.dll .
ffi.exe
# Job 2: FreeBSD (Runs in a VM on top of Linux)
test-freebsd:
name: FreeBSD (x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
pkg install -y rust
run: |
cargo test --verbose -- --nocapture
RUSTFLAGS="-C panic=abort" cargo build --features ffi --release
cc -I./include examples/ffi.c -L./target/release -lbtree_store -o ffi
LD_LIBRARY_PATH=./target/release ./ffi
# Job 3: Linux ARM64 (Cross-compile check)
# This verifies that the code compiles for Linux on ARM.
# We use 'cross' to simplify cross-compilation.
test-linux-arm64:
name: Linux (ARM64 cross-compile)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-unknown-linux-gnu
- name: Install cross
run: cargo install cross
- name: Build for ARM64
run: cross build --target aarch64-unknown-linux-gnu --features ffi --verbose
# Note: Running tests for ARM64 on x86_64 requires QEMU via cross.
# If you want to actually run the tests:
- name: Run tests for ARM64
run: cross test --target aarch64-unknown-linux-gnu --features ffi --verbose -- --nocapture