branch: externals/vecdb
commit 5430f014076d305120e8cd0eca64d6ce8d19e167
Merge: e89d5a9a3a 4cc8a17431
Author: Andrew Hyatt <[email protected]>
Commit: GitHub <[email protected]>
Add Continuous Integration, setting up postgres, chroma, and qdrant (#3)
---
.github/workflows/ci.yaml | 87 +++++++++++++++++++++++++++++++++++++++++++++++
vecdb-psql.el | 2 ++
vecdb.el | 2 +-
3 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
new file mode 100644
index 0000000000..6550501458
--- /dev/null
+++ b/.github/workflows/ci.yaml
@@ -0,0 +1,87 @@
+name: CI
+
+on:
+ # Triggers the workflow on push or pull request events but only for the
"main" branch
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "*" ]
+
+jobs:
+ simple-tests:
+ runs-on: ubuntu-latest
+ environment: Continuous Integration
+ strategy:
+ matrix:
+ emacs_version:
+ - 29.1
+ - 29.4
+ steps:
+ - name: Set up Emacs
+ uses: jcs090218/setup-emacs@master
+ with:
+ version: ${{matrix.emacs_version}}
+
+ - name: Install Eldev
+ uses: emacs-eldev/setup-eldev@v1
+
+ - name: Check out the source code
+ uses: actions/checkout@v4
+
+ - name: Byte-compile the project
+ run: |
+ eldev -dtT compile --warnings-as-errors
+
+ - name: Lint the project
+ run: |
+ eldev -p -dtT lint
+
+ - name: Test the project
+ # We don't set up the env variables so no integration tests will be run
+ run: |
+ eldev -p -dtT test
+ integration-tests:
+ runs-on: ubuntu-latest
+ environment: Continuous Integration
+ services:
+ postgres:
+ image: pgvector/pgvector:pg16
+ env:
+ POSTGRES_USER: postgres
+ POSTGRES_HOST_AUTH_METHOD: trust
+ ports:
+ - 5432:5432
+ chromadb:
+ image: chromadb/chroma
+ ports:
+ - 8000:8000
+ qdrant:
+ image: qdrant/qdrant
+ ports:
+ - 6333:6333
+ steps:
+ - name: Set up Emacs
+ uses: jcs090218/setup-emacs@master
+ with:
+ version: 29.4
+
+ - name: Install Eldev
+ uses: emacs-eldev/setup-eldev@v1
+
+ - name: Check out the source code
+ uses: actions/checkout@v4
+
+ - name: Postgres setup
+ # Create the "test" database
+ run: |
+ psql -h localhost -U postgres -c "CREATE DATABASE test;"
+
+ - name: Test the project
+ env:
+ CHROMA_URL: http://localhost:8000
+ QDRANT_URL: http://localhost:6333
+ QDRANT_API_KEY: ""
+ PSQL_DB: test
+ PSQL_USERNAME: postgres
+ run: |
+ eldev -p -dtT test
diff --git a/vecdb-psql.el b/vecdb-psql.el
index 40dc662180..534894902c 100644
--- a/vecdb-psql.el
+++ b/vecdb-psql.el
@@ -78,6 +78,8 @@ DBNAME is the database name, which must have been created by
the user."
(cl-defmethod vecdb-create ((provider vecdb-psql-provider)
(collection vecdb-collection))
"Create COLLECTION in database PROVIDER."
+ (pg-exec (vecdb-psql-get-connection provider)
+ (format "CREATE EXTENSION IF NOT EXISTS vector;"))
(pg-exec (vecdb-psql-get-connection provider)
(format "CREATE TABLE IF NOT EXISTS %s (
id INTEGER PRIMARY KEY,
diff --git a/vecdb.el b/vecdb.el
index a0bb0fae5f..945c406b90 100644
--- a/vecdb.el
+++ b/vecdb.el
@@ -76,7 +76,7 @@ An ID may be an integer or a string, and is used to uniquely
identify the item."
(cl-defgeneric vecdb-get-item (provider collection id)
"Get items with ID from the COLLECTION with PROVIDER.
-If the item does not exist, return `nil'."
+If the item does not exist, return nil."
(ignore collection id)
(signal 'not-implemented
(list "vecdb-get not implemented for" (vecdb-provider-name
provider))))