diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..83fe452 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,63 @@ +name: Python CI + +on: + push: + branches: ['**'] + paths: + - 'client/python/**' + - '.github/workflows/python.yml' + pull_request: + branches: ['**'] + paths: + - 'client/python/**' + - '.github/workflows/python.yml' + +defaults: + run: + working-directory: client/python + +jobs: + build_and_test: + name: Build and Test + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12', '3.13'] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install Package and Dev Deps + run: pip install -e ".[dev]" + + - name: Run Tests + run: pytest -v + + lint: + name: Lint and Format Check (ruff) + runs-on: ubuntu-latest + continue-on-error: false + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set Up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install Package and Dev Deps + run: pip install -e ".[dev]" + + - name: Check Formatting + run: ruff format --check . + + - name: Run Ruff Linter + run: ruff check . \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f0873be..4d5ce96 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -42,6 +42,12 @@ jobs: - name: Run Tests run: cargo test --verbose + - name: Upload Server binary + uses: actions/upload-artifact@v4 + with: + name: server-binary + path: target/debug/server + udeps: name: Unused Dependencies (cargo-udeps) runs-on: ubuntu-latest @@ -58,8 +64,11 @@ jobs: - name: Install protoc for gRPC server run: sudo apt-get update && sudo apt-get install -y protobuf-compiler + # Using binstall to maximise workflow speed - name: Install cargo-udeps - run: cargo +nightly install cargo-udeps --locked + uses: taiki-e/install-action@v2 + with: + tool: cargo-udeps - name: Run cargo-udeps run: cargo +nightly udeps --workspace --all-targets --all-features @@ -85,3 +94,76 @@ jobs: - name: Check TOML formatting with taplo run: taplo format --check + + integration: + name: Integration Test + needs: build_and_test + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Download server binary + uses: actions/download-artifact@v4 + with: + name: server-binary + path: target/debug + + # This is very IMP. Kept crashing without it + # File permissions are not maintained during artifact upload (upload-artifact@v4) + - name: Make binary executable + run: chmod +x target/debug/server + + - name: Write keys file + run: | + cat > keys.json <<'EOF' + {"keys":[{"name":"ci-admin","role":"readwrite","key":"my-secret-password"}]} + EOF + + - name: Start Server + env: + VORTEXDB_KEYS_FILE: keys.json + DIMENSION: "3" + STORAGE_TYPE: inmemory + INDEX_TYPE: flat + GRPC_HOST: 0.0.0.0 + GRPC_PORT: "50051" + DISABLE_HTTP: "true" + run: | + ./target/debug/server > server.log 2>&1 & + echo $! > server.pid + + - name: Wait for server to be ready + run: | + for i in {1..30}; do + if (echo > /dev/tcp/127.0.0.1/50051) 2>/dev/null; then + echo "Server is up" + exit 0 + fi + sleep 1 + done + echo "Server did not start in time" + cat server.log + exit 1 + + - name: Set Up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + + - name: Install Package and Dev Deps + working-directory: client/python + run: pip install -e ".[dev]" + + - name: Run example scripts + working-directory: client/python + run: pytest examples/all.py -v + + - name: Dump server logs on failure + if: failure() + run: cat server.log + + - name: Stop server + if: always() + run: kill $(cat server.pid) 2>/dev/null || true diff --git a/client/python/.gitignore b/client/python/.gitignore index cbb552b..6a0ca9c 100644 --- a/client/python/.gitignore +++ b/client/python/.gitignore @@ -4,4 +4,5 @@ __pycache__/ .pytest_cache/ .hatch/ .venv/ -venv/ \ No newline at end of file +venv/ +.ruff_cache/ \ No newline at end of file diff --git a/client/python/pyproject.toml b/client/python/pyproject.toml index 7f4f031..424ddf2 100644 --- a/client/python/pyproject.toml +++ b/client/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "vortexdb" -version = "0.1.5" +version = "0.1.0" description = "Python client for VortexDB" readme = "README.md" requires-python = ">=3.10" @@ -32,6 +32,7 @@ dependencies = [ dev = [ "grpcio-tools>=1.81.1,<2.0.0", "pytest>=7.0", + "ruff==0.15.17", ] [tool.hatch.build.targets.wheel]