Automatically add Debian packages to GitHub release #52
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: Python Integration Tests | |
on: [push, pull_request, workflow_dispatch] | |
permissions: | |
contents: read | |
jobs: | |
python-tests: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
pgvector: | |
- version: 0.8.0 | |
pg: | |
- major: 13 | |
minor: 16 | |
- major: 14 | |
minor: 13 | |
- major: 15 | |
minor: 7 | |
- major: 16 | |
minor: 3 | |
- major: 17 | |
minor: 0 | |
env: | |
PG_SRC_DIR: pgbuild | |
PG_INSTALL_DIR: postgresql | |
MAKE_JOBS: 6 | |
PG_CONFIG_PATH: postgresql/bin/pg_config | |
PGDATA: /tmp/pgdata | |
PGPORT: 5432 | |
steps: | |
- name: Checkout pgvectorscale | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Linux Packages | |
uses: ./.github/actions/install-packages | |
- name: Install PostgreSQL ${{ matrix.pg.major }} | |
uses: ./.github/actions/install-postgres | |
with: | |
pg-version: ${{ matrix.pg.major }}.${{ matrix.pg.minor }} | |
pg-src-dir: ~/${{ env.PG_SRC_DIR }} | |
pg-install-dir: ~/${{ env.PG_INSTALL_DIR }} | |
- name: Install pgvector ${{ matrix.pgvector.version }} | |
uses: ./.github/actions/install-pgvector | |
with: | |
pgvector-version: ${{ matrix.pgvector.version }} | |
pg-install-dir: ~/${{ env.PG_INSTALL_DIR }} | |
- name: Install pgrx | |
uses: ./.github/actions/install-pgrx | |
with: | |
pg-install-dir: ~/${{ env.PG_INSTALL_DIR }} | |
pgrx-version: 0.12.9 | |
- name: Build and install pgvectorscale | |
run: | | |
cd pgvectorscale | |
cargo clean | |
# Ensure we use the correct PostgreSQL version that was installed | |
export PATH=~/${{ env.PG_INSTALL_DIR }}/bin:$PATH | |
export PG_CONFIG=~/${{ env.PG_INSTALL_DIR }}/bin/pg_config | |
# Reinitialize pgrx to ensure it uses the correct PostgreSQL version | |
cargo pgrx init --pg${{ matrix.pg.major }}=$PG_CONFIG | |
# Install with explicit version matching | |
cargo pgrx install --no-default-features --features pg${{ matrix.pg.major }} | |
- name: Install Python dependencies | |
run: | | |
pip install -r tests/requirements.txt | |
- name: Initialize and start PostgreSQL | |
run: | | |
export PATH=~/${{ env.PG_INSTALL_DIR }}/bin:$PATH | |
# Initialize the database with trust authentication for all connections | |
initdb -D ${{ env.PGDATA }} --auth-local=trust --auth-host=trust | |
# Start PostgreSQL server | |
pg_ctl -D ${{ env.PGDATA }} -l /tmp/postgres.log start | |
# Wait for PostgreSQL to start | |
sleep 5 | |
# Create test user and database (using current user, no password needed with trust auth) | |
createuser -s postgres || true # may already exist | |
createdb test_db || true # may already exist | |
- name: Setup test database with extensions | |
run: | | |
export PATH=~/${{ env.PG_INSTALL_DIR }}/bin:$PATH | |
# Install extensions in the test database (no -U needed with trust auth) | |
psql -h localhost -p 5432 -d test_db -c "CREATE EXTENSION IF NOT EXISTS vector;" | |
psql -h localhost -p 5432 -d test_db -c "CREATE EXTENSION IF NOT EXISTS vectorscale;" | |
- name: Run Python tests | |
env: | |
DATABASE_URL: postgresql+asyncpg://postgres@localhost:5432/test_db | |
run: | | |
export PATH=~/${{ env.PG_INSTALL_DIR }}/bin:$PATH | |
pytest tests/ -v --tb=short | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: python-test-results-pg${{ matrix.pg.major }} | |
path: | | |
pytest.log | |
test-results.xml | |
retention-days: 7 |