Skip to content

Commit 673a645

Browse files
committed
feat: add e2e network tests
1 parent 3de9115 commit 673a645

4 files changed

Lines changed: 564 additions & 1 deletion

File tree

.github/workflows/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
build:
1616
runs-on: ${{ matrix.os }}
1717
container: ${{ matrix.container && matrix.container || '' }}
18+
env:
19+
APIKEY: ${{ secrets.APIKEY }}
1820
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}${{ matrix.variant && format('-{0}', matrix.variant) || '' }} build${{ matrix.skip_test != true && ( matrix.name != 'android' || matrix.arch == 'x86_64' ) && ' + test' || ''}}
1921
timeout-minutes: 60
2022
strategy:
@@ -362,6 +364,10 @@ jobs:
362364
make build/unittest ${{ matrix.make }} SQLITE_AMALGAM=${SQLITE_DIR}/sqlite3.c
363365
echo "::endgroup::"
364366
367+
echo "::group::build e2e binary for android"
368+
make build/e2e ${{ matrix.make }} SQLITE_AMALGAM=${SQLITE_DIR}/sqlite3.c
369+
echo "::endgroup::"
370+
365371
- name: android test sqlite-memory
366372
if: matrix.name == 'android' && matrix.arch == 'x86_64'
367373
uses: reactivecircus/android-emulator-runner@v2.34.0
@@ -382,6 +388,14 @@ jobs:
382388
echo "Testing extension loading..."
383389
adb shell "sqlite3 :memory: '.load /data/local/tmp/memory.so' 'SELECT memory_version();'"
384390
echo "Extension loading test passed!"
391+
if [ "${{ matrix.variant }}" != "local" ]; then
392+
adb push ${{ github.workspace }}/build/e2e /data/local/tmp/
393+
adb push ${{ github.workspace }}/build/vector.so /data/local/tmp/
394+
adb shell "chmod +x /data/local/tmp/e2e"
395+
echo "Running e2e tests..."
396+
adb shell "APIKEY=$APIKEY VECTOR_LIB=/data/local/tmp/vector /data/local/tmp/e2e"
397+
echo "E2E tests passed!"
398+
fi
385399
386400
- name: unix test sqlite-memory
387401
if: matrix.skip_test != true && matrix.os != 'windows-2022' && matrix.name != 'android'
@@ -392,6 +406,15 @@ jobs:
392406
shell: msys2 {0}
393407
run: make test ${{ matrix.make && matrix.make || ''}}
394408

409+
- name: unix e2e sqlite-memory
410+
if: matrix.skip_test != true && matrix.variant != 'local' && matrix.os != 'windows-2022' && matrix.name != 'android'
411+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make e2e ${{ matrix.make && matrix.make || ''}}
412+
413+
- name: windows e2e sqlite-memory
414+
if: matrix.skip_test != true && matrix.variant != 'local' && matrix.name == 'windows'
415+
shell: msys2 {0}
416+
run: make e2e ${{ matrix.make && matrix.make || ''}}
417+
395418
- uses: actions/upload-artifact@v4.6.2
396419
if: always()
397420
with:

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,41 @@ $(BUILD_DIR)/unittest: $(BUILD_DIR)/unittest.o $(TEST_C_OBJECTS) $(TEST_SQLITE_O
396396
$(TEST_LDFLAGS) $(FRAMEWORKS) $(TEST_LINK_EXTRAS) \
397397
-o $@
398398

399+
$(BUILD_DIR)/e2e.o: $(TEST_DIR)/e2e.c | $(BUILD_DIR)
400+
@echo "Compiling e2e.c..."
401+
@$(CC) $(CFLAGS) $(TEST_DEFINES) $(DEFINES) $(INCLUDES) -c $< -o $@
402+
403+
$(BUILD_DIR)/e2e: $(BUILD_DIR)/e2e.o $(TEST_C_OBJECTS) $(TEST_SQLITE_OBJ) $(LLAMA_LIBS) $(CURL_DEPS) | $(BUILD_DIR)
404+
@echo "Linking e2e..."
405+
@$(LINKER) $(BUILD_DIR)/e2e.o $(TEST_C_OBJECTS) $(TEST_SQLITE_OBJ) $(LLAMA_LIBS) \
406+
$(TEST_LDFLAGS) $(FRAMEWORKS) $(TEST_LINK_EXTRAS) \
407+
-o $@
408+
409+
VECTOR_PLATFORM ?= $(PLATFORM)
410+
VECTOR_LIB := $(BUILD_DIR)/vector.$(EXT)
411+
412+
# Detect musl libc (Alpine Linux)
413+
ifeq ($(PLATFORM),linux)
414+
ifeq ($(shell cat /etc/alpine-release 2>/dev/null && echo yes),yes)
415+
VECTOR_PLATFORM := linux-musl
416+
endif
417+
endif
418+
419+
$(VECTOR_LIB): | $(BUILD_DIR)
420+
@echo "Downloading sqlite-vector for $(VECTOR_PLATFORM)-$(ARCH)..."
421+
@VECTOR_TAG=$$(curl -sL https://api.github.com/repos/sqliteai/sqlite-vector/releases/latest | grep '"tag_name"' | head -1 | sed 's/.*: *"\(.*\)".*/\1/') && \
422+
curl -sL -o $(BUILD_DIR)/vector.tar.gz \
423+
"https://github.com/sqliteai/sqlite-vector/releases/download/$${VECTOR_TAG}/vector-$(VECTOR_PLATFORM)-$(ARCH)-$${VECTOR_TAG}.tar.gz" && \
424+
tar -xzf $(BUILD_DIR)/vector.tar.gz -C $(BUILD_DIR) && \
425+
rm -f $(BUILD_DIR)/vector.tar.gz
426+
@test -f $(VECTOR_LIB) || (echo "Error: $(VECTOR_LIB) not found after download" && exit 1)
427+
428+
.PHONY: e2e
429+
e2e: $(BUILD_DEPS) $(TARGET) $(BUILD_DIR)/e2e $(VECTOR_LIB)
430+
@echo "Running e2e tests..."
431+
@VECTOR_LIB=$(CURDIR)/$(VECTOR_LIB) $(BUILD_DIR)/e2e
432+
@echo "E2E tests passed!"
433+
399434
.PHONY: remote
400435
remote:
401436
@$(MAKE) OMIT_LOCAL_ENGINE=1 extension

src/sqlite-memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static int dbmem_database_init (sqlite3 *db) {
349349

350350
// explicitly allows extension loading (only available when linked statically)
351351
// when loaded dynamically, the calling application must enable extension loading
352-
#ifdef SQLITE_CORE
352+
#if defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
353353
rc = sqlite3_enable_load_extension(db, 1);
354354
if (rc != SQLITE_OK) return rc;
355355
#endif

0 commit comments

Comments
 (0)