Skip to content

Commit f85c66a

Browse files
committed
Add ci for python tests
1 parent eb0bd86 commit f85c66a

3 files changed

Lines changed: 87 additions & 2 deletions

File tree

.github/workflows/python-test.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Python Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- python/**
9+
- rust/lance-graph/**
10+
- .github/workflows/python-test.yml
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
RUSTFLAGS: "-C debuginfo=1"
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-24.04
23+
timeout-minutes: 30
24+
strategy:
25+
matrix:
26+
python-version: ["3.11"]
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Setup Rust
34+
uses: actions-rust-lang/setup-rust-toolchain@v1
35+
- uses: Swatinem/rust-cache@v2
36+
with:
37+
workspaces: python
38+
- name: Install dependencies
39+
run: |
40+
sudo apt update
41+
sudo apt install -y protobuf-compiler
42+
- name: Install Python dependencies
43+
working-directory: python
44+
run: |
45+
python -m pip install --upgrade pip
46+
pip install maturin[patchelf]
47+
pip install -e .[tests]
48+
- name: Build Python extension
49+
working-directory: python
50+
run: maturin develop
51+
- name: Run tests
52+
working-directory: python
53+
run: pytest python/tests/ -v
54+
- name: Run doctests
55+
working-directory: python
56+
run: |
57+
if [ -f python/lance_graph/__init__.py ]; then
58+
python -m doctest python/lance_graph/__init__.py || echo "No doctests found"
59+
fi
60+
61+
lint:
62+
runs-on: ubuntu-24.04
63+
timeout-minutes: 15
64+
steps:
65+
- uses: actions/checkout@v4
66+
- name: Set up Python
67+
uses: actions/setup-python@v4
68+
with:
69+
python-version: "3.11"
70+
- name: Install dependencies
71+
working-directory: python
72+
run: |
73+
python -m pip install --upgrade pip
74+
pip install -e .[dev]
75+
- name: Run ruff format check
76+
working-directory: python
77+
run: ruff format --check python/
78+
- name: Run ruff lint
79+
working-directory: python
80+
run: ruff check python/
81+
- name: Run pyright type check
82+
working-directory: python
83+
run: pyright

python/python/lance_graph/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import importlib.util
66
import sys
77
from pathlib import Path
8-
from types import ModuleType
8+
from typing import TYPE_CHECKING
9+
10+
if TYPE_CHECKING:
11+
from types import ModuleType
912

1013

1114
def _load_bindings() -> ModuleType:

python/python/tests/test_graph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import pyarrow as pa
55
import pytest
6-
76
from lance_graph import CypherQuery, GraphConfig
87

98

0 commit comments

Comments
 (0)