ci: enhance CI workflow to support pysqlite3 installation across mult… #44
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.9', '3.10', '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 SQLite on Linux | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y sqlite3 libsqlite3-dev | |
| - name: Install SQLite on macOS | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew update | |
| brew install sqlite | |
| # Ensure Homebrew sqlite is first on PATH for the job | |
| echo "PATH=$(brew --prefix sqlite)/bin:$PATH" >> $GITHUB_ENV | |
| - name: Install SQLite on Windows | |
| if: runner.os == 'Windows' | |
| shell: powershell | |
| run: | | |
| choco install sqlite -y | |
| # Chocolatey puts sqlite3.exe in C:\ProgramData\chocolatey\bin which is on PATH | |
| - name: Show sqlite version | |
| run: sqlite3 --version | |
| - name: Assert sqlite >= 3.41 (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| python - <<'PY' | |
| import sys, subprocess | |
| try: | |
| out = subprocess.check_output(['sqlite3', '--version']).decode().split()[0] | |
| except Exception as e: | |
| print('Could not run sqlite3 --version:', e) | |
| sys.exit(1) | |
| parts = out.split('.') | |
| major = int(parts[0]) if len(parts) > 0 else 0 | |
| minor = int(parts[1]) if len(parts) > 1 else 0 | |
| if (major, minor) < (3, 41): | |
| print(f'Found sqlite {out}; sqlite >= 3.41 is required.') | |
| sys.exit(1) | |
| print('sqlite OK', out) | |
| PY | |
| - name: Assert sqlite >= 3.41 (Windows) | |
| if: runner.os == 'Windows' | |
| shell: powershell | |
| run: | | |
| $ver = (sqlite3 --version).Split()[0] | |
| $parts = $ver.Split('.') | |
| $major = [int]$parts[0] | |
| $minor = [int]$parts[1] | |
| if ($major -lt 3 -or ($major -eq 3 -and $minor -lt 41)) { | |
| Write-Error "Found sqlite $ver; sqlite >= 3.41 is required." | |
| exit 1 | |
| } | |
| Write-Host "sqlite OK $ver" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install -r requirements-dev.txt | |
| - name: Use pysqlite3 on Linux (enable SQLite extensions in Python) | |
| if: runner.os == 'Linux' | |
| run: | | |
| pip install pysqlite3-binary | |
| python - <<'PY' | |
| import textwrap, pathlib | |
| pathlib.Path('sitecustomize.py').write_text(textwrap.dedent(''' | |
| import pysqlite3 as sqlite3 | |
| import sys | |
| sys.modules['sqlite3'] = sqlite3 | |
| sys.modules['sqlite3.dbapi2'] = sqlite3 | |
| ''').lstrip()) | |
| print('Wrote sitecustomize.py override for Linux') | |
| PY | |
| echo "PYTHONPATH=$PWD:$PYTHONPATH" >> $GITHUB_ENV | |
| - name: Use pysqlite3 on macOS (enable SQLite extensions in Python) | |
| if: runner.os == 'macOS' | |
| run: | | |
| pip install pysqlite3-binary | |
| python - <<'PY' | |
| import textwrap, pathlib | |
| pathlib.Path('sitecustomize.py').write_text(textwrap.dedent(''' | |
| import pysqlite3 as sqlite3 | |
| import sys | |
| sys.modules['sqlite3'] = sqlite3 | |
| sys.modules['sqlite3.dbapi2'] = sqlite3 | |
| ''').lstrip()) | |
| print('Wrote sitecustomize.py override for macOS') | |
| PY | |
| echo "PYTHONPATH=$PWD:$PYTHONPATH" >> $GITHUB_ENV | |
| - name: Use pysqlite3 on Windows (enable SQLite extensions in Python) | |
| if: runner.os == 'Windows' | |
| shell: powershell | |
| run: | | |
| pip install pysqlite3-binary | |
| python - <<'PY' | |
| import textwrap, pathlib | |
| pathlib.Path('sitecustomize.py').write_text(textwrap.dedent(''' | |
| import pysqlite3 as sqlite3 | |
| import sys | |
| sys.modules['sqlite3'] = sqlite3 | |
| sys.modules['sqlite3.dbapi2'] = sqlite3 | |
| ''').lstrip()) | |
| print('Wrote sitecustomize.py override for Windows') | |
| PY | |
| "$env:PYTHONPATH=$pwd;${env:PYTHONPATH}" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| - name: Lint with ruff | |
| run: ruff check . | |
| - name: Format check with ruff | |
| run: ruff format --check . | |
| - name: Type check with mypy | |
| run: mypy sqlite_vec_client/ | |
| - name: Test with pytest | |
| run: pytest --cov=sqlite_vec_client --cov-report=term |