Skip to content

Commit d433e1d

Browse files
author
Dylan Storey
committed
feat(rust): bundle C extension from source for cargo add support
Rust bindings now compile the C extension from source via build.rs, enabling `cargo add graphqlite` to work without manual extension builds. - Add build.rs to compile C sources with cc crate - Add bundled_init.c for direct FFI initialization (no extension API) - Commit pre-generated Flex/Bison outputs to src/generated/ - Simplify GraphManager to use standard Graph::open() - Remove unnecessary cfg gates between bundled/non-bundled modes - Bump version to 0.2.1 Closes GQLITE-T-0091
1 parent a7790ac commit d433e1d

File tree

20 files changed

+10264
-793
lines changed

20 files changed

+10264
-793
lines changed

.github/workflows/ci-fast.yml

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 127 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,125 @@
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: Cargo check
52+
working-directory: bindings/rust
53+
run: cargo check
54+
55+
- name: Cargo clippy
56+
working-directory: bindings/rust
57+
run: cargo clippy -- -D warnings
58+
59+
python-check:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: '3.11'
68+
69+
- name: Install dependencies
70+
run: |
71+
sudo apt-get update
72+
sudo apt-get install -y bison flex libsqlite3-dev
73+
74+
- name: Build extension
75+
run: make extension
76+
77+
- name: Install Python package
78+
working-directory: bindings/python
79+
run: pip install -e ".[dev]"
80+
81+
- name: Run Python tests
82+
working-directory: bindings/python
83+
run: pytest tests/ -v
84+
85+
windows-build:
86+
runs-on: windows-latest
87+
defaults:
88+
run:
89+
shell: msys2 {0}
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Setup MSYS2
94+
uses: msys2/setup-msys2@v2
95+
with:
96+
msystem: MINGW64
97+
update: true
98+
install: >-
99+
mingw-w64-x86_64-gcc
100+
mingw-w64-x86_64-sqlite3
101+
mingw-w64-x86_64-libsystre
102+
bison
103+
flex
104+
make
105+
106+
- name: Build extension
107+
run: make extension
108+
109+
- name: Run functional tests
110+
run: make test-functional
111+
112+
# =============================================================================
113+
# Full Tests - Run after fast tests pass
114+
# =============================================================================
115+
116+
full-build-unix:
117+
needs: [build-and-test, rust-check, python-check, windows-build]
9118
strategy:
10119
fail-fast: false
11120
matrix:
12121
os: [ubuntu-latest, macos-latest]
13-
14122
runs-on: ${{ matrix.os }}
15-
16123
steps:
17124
- uses: actions/checkout@v4
18125

@@ -31,12 +138,7 @@ jobs:
31138
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
32139
echo "SQLITE_PREFIX=$(brew --prefix sqlite)" >> $GITHUB_ENV
33140
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'
141+
- name: Build extension
40142
run: make extension
41143

42144
- name: Run unit tests (Linux)
@@ -55,14 +157,13 @@ jobs:
55157
if: runner.os == 'macOS'
56158
run: make test-functional EXTRA_INCLUDES="-I$HOMEBREW_PREFIX/include" EXTRA_LIBS="-L$HOMEBREW_PREFIX/lib" SQLITE="$SQLITE_PREFIX/bin/sqlite3"
57159

58-
rust-tests:
160+
full-rust-tests:
161+
needs: [build-and-test, rust-check, python-check, windows-build]
59162
strategy:
60163
fail-fast: false
61164
matrix:
62165
os: [ubuntu-latest, macos-latest]
63-
64166
runs-on: ${{ matrix.os }}
65-
66167
steps:
67168
- uses: actions/checkout@v4
68169

@@ -81,7 +182,6 @@ jobs:
81182
brew install bison flex sqlite
82183
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
83184
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH
84-
echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
85185
86186
- name: Build extension (Linux)
87187
if: runner.os == 'Linux'
@@ -95,14 +195,13 @@ jobs:
95195
working-directory: bindings/rust
96196
run: cargo test --lib --test integration -- --test-threads=1
97197

98-
python-tests-linux:
198+
full-python-tests-linux:
199+
needs: [build-and-test, rust-check, python-check, windows-build]
99200
strategy:
100201
fail-fast: false
101202
matrix:
102203
python-version: ['3.9', '3.10', '3.11', '3.12']
103-
104204
runs-on: ubuntu-latest
105-
106205
steps:
107206
- uses: actions/checkout@v4
108207

@@ -127,9 +226,9 @@ jobs:
127226
working-directory: bindings/python
128227
run: pytest tests/ -v
129228

130-
python-tests-macos:
229+
full-python-tests-macos:
230+
needs: [build-and-test, rust-check, python-check, windows-build]
131231
runs-on: macos-latest
132-
133232
steps:
134233
- uses: actions/checkout@v4
135234

@@ -144,22 +243,20 @@ jobs:
144243
run: make extension
145244

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

150248
- name: Run Python tests
151249
working-directory: bindings/python
152250
run: |
153251
SQLITE_PREFIX=$(brew --prefix sqlite)
154252
DYLD_LIBRARY_PATH="$SQLITE_PREFIX/lib:$DYLD_LIBRARY_PATH" python3 -m pytest tests/ -v
155253
156-
build-and-test-windows:
254+
full-windows-tests:
255+
needs: [build-and-test, rust-check, python-check, windows-build]
157256
runs-on: windows-latest
158-
159257
defaults:
160258
run:
161259
shell: msys2 {0}
162-
163260
steps:
164261
- uses: actions/checkout@v4
165262

@@ -182,7 +279,6 @@ jobs:
182279
- name: Run functional tests
183280
run: make test-functional
184281

185-
# Python binding tests (native Windows Python)
186282
- name: Set up Python
187283
uses: actions/setup-python@v5
188284
with:
@@ -194,7 +290,6 @@ jobs:
194290
pip install -e "./bindings/python[dev]"
195291
cd bindings/python && pytest tests/ -v
196292
197-
# Rust binding tests (native Windows Rust)
198293
- name: Install Rust toolchain
199294
uses: dtolnay/rust-toolchain@stable
200295

@@ -203,9 +298,14 @@ jobs:
203298
working-directory: bindings/rust
204299
run: cargo test --lib --test integration -- --test-threads=1
205300

301+
# =============================================================================
302+
# Performance Tests - Main branch only
303+
# =============================================================================
304+
206305
performance-tests:
306+
if: github.ref == 'refs/heads/main'
307+
needs: [build-and-test, rust-check, python-check, windows-build]
207308
runs-on: ubuntu-latest
208-
209309
steps:
210310
- uses: actions/checkout@v4
211311

0 commit comments

Comments
 (0)