-
Notifications
You must be signed in to change notification settings - Fork 16
140 lines (120 loc) · 5.4 KB
/
ci.yml
File metadata and controls
140 lines (120 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
# Static analysis gate — fails the PR if ruff finds any issues. Runs on
# a single Python version (lint output is OS/version-independent) so it's
# cheap and finishes well before the test matrix.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install ruff
run: pip install "ruff>=0.13"
- name: Ruff check
run: ruff check src/ tests/
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
# macOS setup-python ships Python without loadable SQLite extensions.
# Build pysqlite3 from source against Homebrew SQLite (which has
# extensions enabled), then patch sys.modules so `import sqlite3`
# uses the extension-capable build.
- name: Fix SQLite extensions (macOS)
if: runner.os == 'macOS'
run: |
brew install sqlite3
LDFLAGS="-L$(brew --prefix sqlite3)/lib" \
CPPFLAGS="-I$(brew --prefix sqlite3)/include" \
pip install pysqlite3
SITE=$(python -c "import site; print(site.getsitepackages()[0])")
cat > "$SITE/patch_sqlite3.pth" << 'PATCH'
import pysqlite3; import sys; sys.modules["sqlite3"] = pysqlite3; sys.modules["sqlite3.dbapi2"] = pysqlite3
PATCH
python -c "import sqlite3; c = sqlite3.connect(':memory:'); c.enable_load_extension(True); print('SQLite extensions: OK')"
- name: Install package
# Test matrix needs the `local` extra so fastembed-backed tests in
# tests/indexer/test_embedder.py and scripts/bench_recall.py still
# exercise the real ONNX path. The core-only install path (without
# fastembed) is covered separately by the `install-core-only` job.
run: pip install -e ".[dev,local]"
# Pin fastembed's cache for BOTH the warm step and the test step so
# they share state. Embedder defaults to ~/.cache/fastembed under
# #67, and fastembed itself honours FASTEMBED_CACHE_PATH — setting
# this env var keeps the warm step and the tests pointed at the
# same directory without needing explicit kwargs.
- name: Warm fastembed model cache
env:
FASTEMBED_CACHE_PATH: ${{ runner.temp }}/fastembed-cache
run: |
python -c "from fastembed import TextEmbedding; TextEmbedding('BAAI/bge-small-en-v1.5')"
python -c "from fastembed import TextEmbedding; TextEmbedding('sentence-transformers/all-MiniLM-L6-v2')"
- name: Run tests
env:
FASTEMBED_CACHE_PATH: ${{ runner.temp }}/fastembed-cache
run: pytest -n ${{ runner.os == 'Windows' && '0' || '4' }} --cov=context_engine --cov-report=xml --cov-report=term
# Windows GitHub Actions runners send spurious SIGINT during pytest
# teardown, causing exit code 1 even when all tests pass (779/779).
# This is a known runner infrastructure issue, not a code bug.
continue-on-error: ${{ runner.os == 'Windows' }}
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
install-core-only:
# Regression guard for #62 — `pip install code-context-engine` without
# the [local] extra must succeed on every supported OS/Python combo
# without compiling Rust or requiring MSVC. fastembed is the heavy
# transitive dep that historically blocked Windows + new Python
# versions; this job ensures the core install never pulls it.
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install core (no extras)
run: pip install -e .
- name: Verify fastembed is NOT installed
shell: bash
run: |
if python -c "import fastembed" 2>/dev/null; then
echo "ERROR: fastembed leaked into the core install — it should be opt-in via [local]"
exit 1
fi
echo "Core install confirmed fastembed-free."
- name: Verify package imports cleanly
run: |
python -c "import context_engine; print('OK', context_engine.__version__)"
python -c "from context_engine.indexer.embedder import Embedder, OllamaBackend, select_backend; print('OK embedder module')"