Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 173 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: CI

on:
pull_request:
branches: [main, master, develop]
paths-ignore:
- "README.md"
- "README_zh-CN.md"
- "**/*.md"
push:
branches: [main, master, develop]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
check:
if: github.repository == 'ob-labs/seekdb-rs'
name: Check (fmt, clippy, build)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-action@stable
with:
components: clippy, rustfmt

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@2
with:
key: ${{ runner.os }}-check

- name: Check formatting
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --all-targets -- -D warnings

- name: Build (default features)
run: cargo build --all-targets

- name: Build (server only)
run: cargo build --no-default-features --features server

test:
if: github.repository == 'ob-labs/seekdb-rs'
name: Test (server only)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-action@stable

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@2
with:
key: ${{ runner.os }}-test

- name: Run tests (server only)
run: cargo test --no-default-features --features server --all-targets
env:
SEEKDB_INTEGRATION: ""

test-default:
if: github.repository == 'ob-labs/seekdb-rs'
name: Test (default features)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-action@stable
- name: Cache
uses: Swatinem/rust-cache@2
with:
key: ${{ runner.os }}-test-default
- name: Run tests (default features)
run: cargo test --all-targets
env:
SEEKDB_INTEGRATION: ""

# Server-mode tests against real SeekDB container (same as seekdb-js).
test-server:
if: github.repository == 'ob-labs/seekdb-rs'
name: Test server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-action@stable

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@2
with:
key: ${{ runner.os }}-test-server

- name: Build
run: cargo build --all-targets

- name: Start seekdb container
run: |
docker run --name seekdb-server -p 2881:2881 -d oceanbase/seekdb:latest
echo "Waiting for port 2881..."
for i in $(seq 1 60); do
if nc -z 127.0.0.1 2881 2>/dev/null; then
echo "Port 2881 is open"
break
fi
if [ "$i" -eq 60 ]; then
echo "Timeout waiting for port 2881"
docker logs seekdb-server
exit 1
fi
sleep 1
done
docker logs seekdb-server

- name: Run server tests
run: cargo test --all-targets
env:
SEEKDB_INTEGRATION: "1"
SERVER_HOST: 127.0.0.1
SERVER_PORT: 2881
SERVER_USER: root
SERVER_PASSWORD: ""
SERVER_DATABASE: test
SERVER_TENANT: sys

# Embedded-mode tests on multiple platforms (align with seekdb-js test-embedded).
test-embedded:
if: github.repository == 'ob-labs/seekdb-rs'
name: Test embedded (${{ matrix.platform }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux-x64
runner: ubuntu-latest
- platform: linux-arm64
runner: ubuntu-22.04-arm
- platform: darwin-arm64
runner: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-action@stable

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@2
with:
key: ${{ runner.os }}-${{ matrix.platform }}-embedded

- name: Build (embedded) and run embedded tests
run: |
cargo test --no-default-features --features embedded \
--test embedded_integration_client \
--test embedded_integration_collection_dml \
--test embedded_integration_query \
--test embedded_integration_hybrid \
--test embedded_integration_embedding
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
target/
Cargo.lock
AGENTS.md
.DS_Store
.DS_Store
libseekdb
seekdb.db
tests/seekdb.db
38 changes: 38 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ publish = true
repository = "https://github.com/ob-labs/seekdb-rs"
keywords = ["seekdb", "oceanbase", "vector-database", "mysql", "rag"]
categories = ["database", "api-bindings", "asynchronous", "network-programming"]
build = "build.rs"

[features]
default = ["server", "embedding"]
server = []
embedding = ["reqwest", "tokenizers", "ort", "hf-hub"]
sync = []
embedded = ["build-reqwest", "zip", "embedding"]

[dependencies]
async-trait = "0.1"
Expand All @@ -29,4 +31,40 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
reqwest = { version = "0.11", features = ["json", "gzip", "rustls-tls", "blocking"], optional = true }
tokenizers = { version = "0.15", optional = true }
ort = { version = "2.0.0-rc.10", optional = true }
ndarray = { version = "0.15", optional = true }
hf-hub = { version = "0.4.3", default-features = false, features = ["ureq"], optional = true }

[build-dependencies]
bindgen = { version = "0.71", default-features = false, features = ["runtime"] }
build-reqwest = { package = "reqwest", version = "0.12", default-features = false, features = ["blocking", "rustls-tls"], optional = true }
zip = { version = "1", default-features = false, features = ["deflate"], optional = true }

# Examples (run with e.g. cargo run --example simple_example --no-default-features --features embedded,embedding)
[[example]]
name = "simple_example"
required-features = ["embedded", "embedding"]
[[example]]
name = "complete_example"
required-features = ["embedded"]
[[example]]
name = "hybrid_search_example"
required-features = ["embedded", "embedding"]

[dev-dependencies]
# Server integration tests: tests/integration_*.rs are auto-discovered.
# Embedded integration tests: harness = false so main() uses current-thread runtime and block_on.
[[test]]
name = "embedded_integration_client"
harness = false
[[test]]
name = "embedded_integration_collection_dml"
harness = false
[[test]]
name = "embedded_integration_hybrid"
harness = false
[[test]]
name = "embedded_integration_query"
harness = false
[[test]]
name = "embedded_integration_embedding"
harness = false
Loading