Skip to content

Commit da0bdbb

Browse files
jpheinclaude
andcommitted
ci: gate postgres-backend tests against a pgvector service container
Adds a new test-postgres job to .github/workflows/ci.yml. Runs in parallel with the existing test-linux / test-windows / test-macos / lint matrix; doesn't disturb their behavior. Service container: pgvector/pgvector:pg16 (public Docker Hub image, PG16 + pgvector pre-installed). Bound on localhost:5432 in the job network. Pre-test setup step creates the vector extension inside the mempalace_test database (idempotent IF NOT EXISTS). Test scope: tests/test_backends_postgres.py only. The full pytest suite is already exercised by test-linux without the postgres extra; running it again with TEST_POSTGRES_DSN set would double the suite time on every PR for the marginal coverage of three additional tests. The targeted job gives us the regression signal we want — postgres backend works end-to-end against a real database — without the cost. AGE is deliberately not in the CI image. The apache/age + pgvector combined image we deploy on the homelab (mempalace-db on disks) isn't needed in CI yet — no test in the repo exercises AGE-specific behavior. When the knowledge-graph layer lands and adds AGE tests, the CI image swap is a separate concern (push our mempalace-db:0.1 image to ghcr.io/jphein, or build inline in CI). Until then, pgvector-only is the cheapest correct substrate. The CREATE EXTENSION step uses a Python heredoc with the DSN passed via env var (PGURL) rather than inline psql — avoids the postgresql-client install on the runner and removes one shell-quoting surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1d5486f commit da0bdbb

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,41 @@ jobs:
5353
- run: pip install "ruff>=0.4.0,<0.5"
5454
- run: ruff check .
5555
- run: ruff format --check .
56+
57+
test-postgres:
58+
runs-on: ubuntu-latest
59+
services:
60+
postgres:
61+
image: pgvector/pgvector:pg16
62+
env:
63+
POSTGRES_PASSWORD: postgres
64+
POSTGRES_DB: mempalace_test
65+
ports:
66+
- 5432:5432
67+
options: >-
68+
--health-cmd pg_isready
69+
--health-interval 5s
70+
--health-timeout 5s
71+
--health-retries 10
72+
steps:
73+
- uses: actions/checkout@v6
74+
- uses: actions/setup-python@v6
75+
with:
76+
python-version: "3.11"
77+
cache: 'pip'
78+
- run: pip install -e ".[dev,postgres]"
79+
- name: Create pgvector extension
80+
env:
81+
PGURL: postgresql://postgres:postgres@localhost:5432/mempalace_test
82+
run: |
83+
python - <<'PY'
84+
import os, psycopg2
85+
conn = psycopg2.connect(os.environ["PGURL"])
86+
conn.autocommit = True
87+
conn.cursor().execute("CREATE EXTENSION IF NOT EXISTS vector")
88+
print("vector extension ready")
89+
PY
90+
- name: Run postgres backend tests
91+
env:
92+
TEST_POSTGRES_DSN: postgresql://postgres:postgres@localhost:5432/mempalace_test
93+
run: python -m pytest tests/test_backends_postgres.py -v

0 commit comments

Comments
 (0)