Skip to content

Commit cf18581

Browse files
authored
Update sqlite vec (#367)
* Update sqlitevec Update iOS libs Fix script # Conflicts: # example/ios/Podfile.lock # scripts/turnOnLibsql.js * Podfile * Log on android * Log on android * Change to 20 seconds * Wait for device to fully boot * script * script * Fixes build warning in prepared statement constructor * script * logs * Try different android emulator settings * script * Double await time * Sleep a minute * sleep longer * Do not sleep * Clear device space * add ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL * Increase poll time * Comment out test * Turn off sqlitevec * lock * Turn off sqlitevec * Disable avd cache
1 parent 4cc2c29 commit cf18581

File tree

19 files changed

+234
-85
lines changed

19 files changed

+234
-85
lines changed

.github/workflows/ci.yml

Lines changed: 121 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,58 +14,6 @@ jobs:
1414
- name: Typecheck files
1515
run: yarn typecheck
1616

17-
test-android:
18-
runs-on: ubuntu-latest
19-
env:
20-
TURBO_CACHE_DIR: .turbo/android
21-
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
24-
25-
- name: Turn off addons
26-
run: |
27-
node ./scripts/turnOffEverything.js
28-
29-
- name: Setup
30-
uses: ./.github/actions/setup
31-
32-
- name: Install JDK
33-
uses: actions/setup-java@v3
34-
with:
35-
distribution: 'zulu'
36-
java-version: '17'
37-
38-
- name: Finalize Android SDK
39-
run: |
40-
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
41-
42-
- name: Cache Gradle
43-
uses: actions/cache@v4
44-
with:
45-
path: |
46-
~/.gradle/wrapper
47-
~/.gradle/caches
48-
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
49-
restore-keys: |
50-
${{ runner.os }}-gradle-
51-
52-
- name: Enable KVM
53-
run: |
54-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
55-
sudo udevadm control --reload-rules
56-
sudo udevadm trigger --name-match=kvm
57-
58-
- name: Give execute permissions to script
59-
run: chmod +x ./scripts/test-android.sh
60-
61-
- name: run tests
62-
uses: reactivecircus/android-emulator-runner@v2
63-
with:
64-
api-level: 29
65-
emulator-options: -no-window -no-boot-anim -no-audio -no-snapshot-load
66-
script: |
67-
./scripts/test-android.sh
68-
6917
test-ios:
7018
runs-on: macos-latest
7119
steps:
@@ -234,55 +182,156 @@ jobs:
234182
run: |
235183
./scripts/test-ios.sh
236184
237-
test-android-sqlcipher:
185+
test-android:
238186
runs-on: ubuntu-latest
239-
env:
240-
TURBO_CACHE_DIR: .turbo/android
187+
timeout-minutes: 20
241188
steps:
189+
- name: Free Disk Space (Ubuntu)
190+
uses: insightsengineering/disk-space-reclaimer@v1
191+
with:
192+
# this might remove tools that are actually needed,
193+
# if set to "true" but frees about 6 GB
194+
tools-cache: false
195+
196+
# all of these default to true, but feel free to set to
197+
# "false" if necessary for your workflow
198+
android: false
199+
dotnet: true
200+
haskell: true
201+
large-packages: true
202+
swap-storage: true
203+
docker-images: true
204+
242205
- name: Checkout
243206
uses: actions/checkout@v4
244207

245-
- name: Turn on SQLCipher
208+
- name: Turn off addons
246209
run: |
247-
node ./scripts/turnOnSQLCipher.js
210+
node ./scripts/turnOffEverything.js
248211
249212
- name: Setup
250213
uses: ./.github/actions/setup
251214

252215
- name: Install JDK
253216
uses: actions/setup-java@v3
254217
with:
255-
distribution: 'zulu'
256-
java-version: '17'
218+
distribution: "temurin"
219+
java-version: "17"
257220

258-
- name: Finalize Android SDK
221+
- name: Enable KVM
259222
run: |
260-
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
223+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
224+
sudo udevadm control --reload-rules
225+
sudo udevadm trigger --name-match=kvm
261226
262-
- name: Cache Gradle
263-
uses: actions/cache@v4
227+
- name: Gradle cache
228+
uses: gradle/actions/setup-gradle@v3
229+
230+
# - name: AVD cache
231+
# uses: actions/cache@v4
232+
# id: avd-cache
233+
# with:
234+
# path: |
235+
# ~/.android/avd/*
236+
# ~/.android/adb*
237+
# key: avd-29
238+
239+
- name: create AVD and generate snapshot for caching
240+
# if: steps.avd-cache.outputs.cache-hit != 'true'
241+
uses: reactivecircus/android-emulator-runner@v2
264242
with:
265-
path: |
266-
~/.gradle/wrapper
267-
~/.gradle/caches
268-
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
269-
restore-keys: |
270-
${{ runner.os }}-gradle-
243+
api-level: 29
244+
force-avd-creation: false
245+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
246+
disable-animations: false
247+
script: echo "Generated AVD snapshot for caching."
248+
249+
- name: Give execute permissions to script
250+
run: chmod +x ./scripts/test-android.sh
251+
252+
- name: run tests
253+
uses: reactivecircus/android-emulator-runner@v2
254+
with:
255+
api-level: 29
256+
force-avd-creation: false
257+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
258+
disable-animations: true
259+
script: |
260+
./scripts/test-android.sh
261+
262+
test-android-sqlcipher:
263+
runs-on: ubuntu-latest
264+
timeout-minutes: 20
265+
steps:
266+
- name: Free Disk Space (Ubuntu)
267+
uses: insightsengineering/disk-space-reclaimer@v1
268+
with:
269+
# this might remove tools that are actually needed,
270+
# if set to "true" but frees about 6 GB
271+
tools-cache: false
272+
273+
# all of these default to true, but feel free to set to
274+
# "false" if necessary for your workflow
275+
android: false
276+
dotnet: true
277+
haskell: true
278+
large-packages: true
279+
swap-storage: true
280+
docker-images: true
281+
- name: Checkout
282+
uses: actions/checkout@v4
283+
284+
- name: Turn on SQLCipher
285+
run: |
286+
node ./scripts/turnOnSQLCipher.js
287+
288+
- name: Setup
289+
uses: ./.github/actions/setup
290+
291+
- name: Install JDK
292+
uses: actions/setup-java@v3
293+
with:
294+
distribution: "temurin"
295+
java-version: "17"
271296

272297
- name: Enable KVM
273298
run: |
274299
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
275300
sudo udevadm control --reload-rules
276301
sudo udevadm trigger --name-match=kvm
277302
303+
- name: Gradle cache
304+
uses: gradle/actions/setup-gradle@v3
305+
306+
# - name: AVD cache
307+
# uses: actions/cache@v4
308+
# id: avd-cache
309+
# with:
310+
# path: |
311+
# ~/.android/avd/*
312+
# ~/.android/adb*
313+
# key: avd-29
314+
315+
- name: create AVD and generate snapshot for caching
316+
# if: steps.avd-cache.outputs.cache-hit != 'true'
317+
uses: reactivecircus/android-emulator-runner@v2
318+
with:
319+
api-level: 29
320+
force-avd-creation: false
321+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
322+
disable-animations: false
323+
script: echo "Generated AVD snapshot for caching."
324+
278325
- name: Give execute permissions to script
279326
run: chmod +x ./scripts/test-android.sh
280327

281328
- name: run tests
282329
uses: reactivecircus/android-emulator-runner@v2
283330
with:
284331
api-level: 29
285-
emulator-options: -no-window -no-boot-anim -no-audio -no-snapshot-load
332+
force-avd-creation: false
333+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
334+
disable-animations: true
286335
script: |
287336
adb wait-for-device
288337
adb shell input keyevent 82
@@ -303,8 +352,8 @@ jobs:
303352
- name: Install JDK
304353
uses: actions/setup-java@v3
305354
with:
306-
distribution: 'zulu'
307-
java-version: '17'
355+
distribution: "zulu"
356+
java-version: "17"
308357

309358
- name: Finalize Android SDK
310359
run: |
-1.9 KB
Binary file not shown.
-324 Bytes
Binary file not shown.

android/src/main/libsqlitevec/x86/libsqlite_vec.so

100644100755
528 Bytes
Binary file not shown.
336 Bytes
Binary file not shown.

cpp/PreparedStatementHostObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class PreparedStatementHostObject : public jsi::HostObject {
4040
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propNameID) override;
4141

4242
private:
43-
std::shared_ptr<ThreadPool> _thread_pool;
4443
#ifdef OP_SQLITE_USE_LIBSQL
4544
DB _db;
4645
libsql_stmt_t _stmt;
@@ -49,6 +48,7 @@ class PreparedStatementHostObject : public jsi::HostObject {
4948
// This shouldn't be de-allocated until sqlite3_finalize is called on it
5049
sqlite3_stmt *_stmt;
5150
#endif
51+
std::shared_ptr<ThreadPool> _thread_pool;
5252
};
5353

5454
} // namespace opsqlite

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ EXTERNAL SOURCES:
20272027
SPEC CHECKSUMS:
20282028
FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db
20292029
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
2030-
op-sqlite: 137a619945c21df76fda2744680061b8f3251839
2030+
op-sqlite: a0d8cbee3fc5f8c8b67272c3b07c3b4f07b5b17f
20312031
OpServer: 9b3ebdeeb095950e760e3c39853cd06849421b35
20322032
RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554
20332033
RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
"node": ">=18"
4646
},
4747
"op-sqlite": {
48-
"libsql": true,
48+
"libsql": false,
4949
"sqlcipher": false,
5050
"iosSqlite": false,
5151
"fts5": true,
5252
"rtree": true,
5353
"crsqlite": false,
54-
"sqliteVec": false,
54+
"sqliteVec": true,
5555
"performanceMode": true,
5656
"tokenizers": [
5757
"wordtokenizer",

example/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default function App() {
1717
const [openTime, setOpenTime] = useState(0);
1818

1919
useEffect(() => {
20+
console.log("App has started 🟢")
2021
const work = async () => {
2122
let start = performance.now();
2223
open({
@@ -26,9 +27,11 @@ export default function App() {
2627

2728
try {
2829
const results = await runTests();
30+
console.log("TESTS FINISHED 🟢")
2931
setServerResults(allTestsPassed(results));
3032
setResults(results);
3133
} catch (e) {
34+
console.log(`TEST FAILED 🟥 ${e}`)
3235
setServerResults(false);
3336
}
3437

example/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ server.get('/ping', async (_req, res) => {
1313

1414
server.get('/results', async (_req, res) => {
1515
res.statusCode = 200;
16+
res.contentType = 'application/json';
1617
res.content = JSON.stringify({passed});
17-
// res.json({passed}, 200);
1818
});
1919

2020
server.listen(9000);
21-
// console.log('Server listening on port 9000');
21+
console.log('🟢 HTTP Server listening on port 9000');
2222

2323
export function stopServer() {
2424
server.stop();

0 commit comments

Comments
 (0)