Skip to content

Commit 02dd53d

Browse files
author
Dylan Storey
committed
feat(rust): bundle pre-built extension binaries
Switch from compiling C extension at build time to bundling pre-built binaries that are loaded at runtime via SQLite's load_extension(). This avoids MSVC compatibility issues on Windows and simplifies the build process - no C compiler needed for Rust users. - Add platform.rs for binary extraction and loading - Embed platform-specific binaries via include_bytes!() - Extract to temp directory on first use, cache path - Update CI to copy built extensions before Rust tests
1 parent a7790ac commit 02dd53d

File tree

24 files changed

+10440
-819
lines changed

24 files changed

+10440
-819
lines changed

.github/workflows/ci-fast.yml

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 143 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,128 @@
1-
name: CI Full
1+
name: CI
22

33
on:
44
push:
55
branches: [main]
6+
pull_request:
7+
branches: [main]
68

79
jobs:
8-
build-and-test-unix:
10+
# =============================================================================
11+
# Fast Tests - Run first on all PRs and pushes
12+
# =============================================================================
13+
14+
build-and-test:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y bison flex libsqlite3-dev libcunit1-dev
23+
24+
- name: Build extension
25+
run: make extension
26+
27+
- name: Run unit tests
28+
run: make test-unit
29+
30+
- name: Run functional tests
31+
run: make test-functional
32+
33+
rust-check:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Install Rust toolchain
39+
uses: dtolnay/rust-toolchain@stable
40+
with:
41+
components: clippy
42+
43+
- name: Install dependencies
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y bison flex libsqlite3-dev
47+
48+
- name: Build extension
49+
run: make extension
50+
51+
- name: Copy extension to Rust libs
52+
run: cp build/graphqlite.so bindings/rust/libs/graphqlite-linux-x86_64.so
53+
54+
- name: Cargo check
55+
working-directory: bindings/rust
56+
run: cargo check
57+
58+
- name: Cargo clippy
59+
working-directory: bindings/rust
60+
run: cargo clippy -- -D warnings
61+
62+
python-check:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: '3.11'
71+
72+
- name: Install dependencies
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y bison flex libsqlite3-dev
76+
77+
- name: Build extension
78+
run: make extension
79+
80+
- name: Install Python package
81+
working-directory: bindings/python
82+
run: pip install -e ".[dev]"
83+
84+
- name: Run Python tests
85+
working-directory: bindings/python
86+
run: pytest tests/ -v
87+
88+
windows-build:
89+
runs-on: windows-latest
90+
defaults:
91+
run:
92+
shell: msys2 {0}
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Setup MSYS2
97+
uses: msys2/setup-msys2@v2
98+
with:
99+
msystem: MINGW64
100+
update: true
101+
install: >-
102+
mingw-w64-x86_64-gcc
103+
mingw-w64-x86_64-sqlite3
104+
mingw-w64-x86_64-libsystre
105+
bison
106+
flex
107+
make
108+
109+
- name: Build extension
110+
run: make extension
111+
112+
- name: Run functional tests
113+
run: make test-functional
114+
115+
# =============================================================================
116+
# Full Tests - Run after fast tests pass
117+
# =============================================================================
118+
119+
full-build-unix:
120+
needs: [build-and-test, rust-check, python-check, windows-build]
9121
strategy:
10122
fail-fast: false
11123
matrix:
12124
os: [ubuntu-latest, macos-latest]
13-
14125
runs-on: ${{ matrix.os }}
15-
16126
steps:
17127
- uses: actions/checkout@v4
18128

@@ -31,12 +141,7 @@ jobs:
31141
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
32142
echo "SQLITE_PREFIX=$(brew --prefix sqlite)" >> $GITHUB_ENV
33143
34-
- name: Build extension (Linux)
35-
if: runner.os == 'Linux'
36-
run: make extension
37-
38-
- name: Build extension (macOS)
39-
if: runner.os == 'macOS'
144+
- name: Build extension
40145
run: make extension
41146

42147
- name: Run unit tests (Linux)
@@ -55,14 +160,19 @@ jobs:
55160
if: runner.os == 'macOS'
56161
run: make test-functional EXTRA_INCLUDES="-I$HOMEBREW_PREFIX/include" EXTRA_LIBS="-L$HOMEBREW_PREFIX/lib" SQLITE="$SQLITE_PREFIX/bin/sqlite3"
57162

58-
rust-tests:
163+
full-rust-tests:
164+
needs: [build-and-test, rust-check, python-check, windows-build]
59165
strategy:
60166
fail-fast: false
61167
matrix:
62-
os: [ubuntu-latest, macos-latest]
63-
168+
include:
169+
- os: ubuntu-latest
170+
lib_name: graphqlite-linux-x86_64.so
171+
ext_file: graphqlite.so
172+
- os: macos-latest
173+
lib_name: graphqlite-macos-aarch64.dylib
174+
ext_file: graphqlite.dylib
64175
runs-on: ${{ matrix.os }}
65-
66176
steps:
67177
- uses: actions/checkout@v4
68178

@@ -81,28 +191,24 @@ jobs:
81191
brew install bison flex sqlite
82192
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
83193
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH
84-
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
85194
86-
- name: Build extension (Linux)
87-
if: runner.os == 'Linux'
195+
- name: Build extension
88196
run: make extension
89197

90-
- name: Build extension (macOS)
91-
if: runner.os == 'macOS'
92-
run: make extension
198+
- name: Copy extension to Rust libs
199+
run: cp build/${{ matrix.ext_file }} bindings/rust/libs/${{ matrix.lib_name }}
93200

94201
- name: Run Rust tests
95202
working-directory: bindings/rust
96203
run: cargo test --lib --test integration -- --test-threads=1
97204

98-
python-tests-linux:
205+
full-python-tests-linux:
206+
needs: [build-and-test, rust-check, python-check, windows-build]
99207
strategy:
100208
fail-fast: false
101209
matrix:
102210
python-version: ['3.9', '3.10', '3.11', '3.12']
103-
104211
runs-on: ubuntu-latest
105-
106212
steps:
107213
- uses: actions/checkout@v4
108214

@@ -127,9 +233,9 @@ jobs:
127233
working-directory: bindings/python
128234
run: pytest tests/ -v
129235

130-
python-tests-macos:
236+
full-python-tests-macos:
237+
needs: [build-and-test, rust-check, python-check, windows-build]
131238
runs-on: macos-latest
132-
133239
steps:
134240
- uses: actions/checkout@v4
135241

@@ -144,22 +250,20 @@ jobs:
144250
run: make extension
145251

146252
- name: Install Python package
147-
run: |
148-
python3 -m pip install -e "./bindings/python[dev]"
253+
run: python3 -m pip install -e "./bindings/python[dev]"
149254

150255
- name: Run Python tests
151256
working-directory: bindings/python
152257
run: |
153258
SQLITE_PREFIX=$(brew --prefix sqlite)
154259
DYLD_LIBRARY_PATH="$SQLITE_PREFIX/lib:$DYLD_LIBRARY_PATH" python3 -m pytest tests/ -v
155260
156-
build-and-test-windows:
261+
full-windows-tests:
262+
needs: [build-and-test, rust-check, python-check, windows-build]
157263
runs-on: windows-latest
158-
159264
defaults:
160265
run:
161266
shell: msys2 {0}
162-
163267
steps:
164268
- uses: actions/checkout@v4
165269

@@ -182,7 +286,6 @@ jobs:
182286
- name: Run functional tests
183287
run: make test-functional
184288

185-
# Python binding tests (native Windows Python)
186289
- name: Set up Python
187290
uses: actions/setup-python@v5
188291
with:
@@ -194,7 +297,9 @@ jobs:
194297
pip install -e "./bindings/python[dev]"
195298
cd bindings/python && pytest tests/ -v
196299
197-
# Rust binding tests (native Windows Rust)
300+
- name: Copy extension to Rust libs
301+
run: cp build/graphqlite.dll bindings/rust/libs/graphqlite-windows-x86_64.dll
302+
198303
- name: Install Rust toolchain
199304
uses: dtolnay/rust-toolchain@stable
200305

@@ -203,9 +308,14 @@ jobs:
203308
working-directory: bindings/rust
204309
run: cargo test --lib --test integration -- --test-threads=1
205310

311+
# =============================================================================
312+
# Performance Tests - Main branch only
313+
# =============================================================================
314+
206315
performance-tests:
316+
if: github.ref == 'refs/heads/main'
317+
needs: [build-and-test, rust-check, python-check, windows-build]
207318
runs-on: ubuntu-latest
208-
209319
steps:
210320
- uses: actions/checkout@v4
211321

0 commit comments

Comments
 (0)