first add
This commit is contained in:
85
Makefile
Normal file
85
Makefile
Normal file
@@ -0,0 +1,85 @@
|
||||
.PHONY: help db-up db-down db-logs py-install-all test test-sqlite test-pg test-pg-once examples
|
||||
|
||||
PY_VERSIONS ?= 3.10 3.11 3.12 3.13
|
||||
|
||||
help:
|
||||
@echo "Targets:"
|
||||
@echo " db-up - start Postgres (docker compose)"
|
||||
@echo " db-down - stop Postgres (docker compose)"
|
||||
@echo " db-logs - tail DB logs"
|
||||
@echo " test - run all tests (incl. smoke)"
|
||||
@echo " test-sqlite - run fast smoke tests on SQLite"
|
||||
@echo " test-pg - run PG integration once on current Python"
|
||||
@echo " test-pg-once - run PG integration across Python 3.10–3.13"
|
||||
@echo " py-install-all - install Python versions with uv"
|
||||
@echo " examples - run example scripts (requires SQL_* env)"
|
||||
|
||||
db-up:
|
||||
docker compose up -d
|
||||
|
||||
db-down:
|
||||
docker compose down -v
|
||||
|
||||
db-logs:
|
||||
docker compose logs -f
|
||||
|
||||
# Fast local tests. Runs whatever pytest finds (no network/install).
|
||||
test:
|
||||
pytest -ra
|
||||
|
||||
# Only the SQLite-backed smoke test (fast, no Postgres required).
|
||||
test-sqlite:
|
||||
pytest -ra tests/test_smoke.py
|
||||
|
||||
# Single-run Postgres integration on the active interpreter.
|
||||
test-pg:
|
||||
@[ -n "$$SQL_HOST" ] || [ -n "$$PGHOST" ] || (echo "Set SQL_HOST/PGHOST (and SQL_PORT/PGPORT, SQL_USER/PGUSER, SQL_PASSWORD/PGPASSWORD, SQL_DATABASE)" && exit 1)
|
||||
@[ -n "$$SQL_PORT" ] || [ -n "$$PGPORT" ] || (echo "Set SQL_PORT/PGPORT" && exit 1)
|
||||
@[ -n "$$SQL_USER" ] || [ -n "$$PGUSER" ] || (echo "Set SQL_USER/PGUSER" && exit 1)
|
||||
@[ -n "$$SQL_PASSWORD" ] || [ -n "$$PGPASSWORD" ] || (echo "Set SQL_PASSWORD/PGPASSWORD" && exit 1)
|
||||
@[ -n "$$SQL_DATABASE" ] || [ -n "$$PGDATABASE" ] || (echo "Set SQL_DATABASE/PGDATABASE" && exit 1)
|
||||
pytest -ra -m integration tests/test_pg_integration.py
|
||||
|
||||
test-pg-once:
|
||||
@[ -n "$$SQL_HOST" ] || [ -n "$$PGHOST" ] || (echo "Set SQL_HOST/PGHOST (and SQL_PORT/PGPORT, SQL_USER/PGUSER, SQL_PASSWORD/PGPASSWORD, SQL_DATABASE)" && exit 1)
|
||||
@[ -n "$$SQL_PORT" ] || [ -n "$$PGPORT" ] || (echo "Set SQL_PORT/PGPORT" && exit 1)
|
||||
@[ -n "$$SQL_USER" ] || [ -n "$$PGUSER" ] || (echo "Set SQL_USER/PGUSER" && exit 1)
|
||||
@[ -n "$$SQL_PASSWORD" ] || [ -n "$$PGPASSWORD" ] || (echo "Set SQL_PASSWORD/PGPASSWORD" && exit 1)
|
||||
@[ -n "$$SQL_DATABASE" ] || [ -n "$$PGDATABASE" ] || (echo "Set SQL_DATABASE/PGDATABASE" && exit 1)
|
||||
uv python install $(PY_VERSIONS)
|
||||
@for py in $(PY_VERSIONS); do \
|
||||
echo "==> PG CRUD test on $$py"; \
|
||||
UV_VENV_CLEAR=1 uv venv -p $$py .venv-$$py; \
|
||||
. .venv-$$py/bin/activate; \
|
||||
uv pip install -e . pytest; \
|
||||
pytest -ra -m integration tests/test_pg_integration.py || exit $$?; \
|
||||
deactivate; \
|
||||
done
|
||||
|
||||
py-install-all:
|
||||
uv python install $(PY_VERSIONS)
|
||||
|
||||
# Run examples against a configured Postgres.
|
||||
# Requires env vars: SQL_HOST/PGHOST, SQL_PORT/PGPORT, SQL_USER/PGUSER, SQL_PASSWORD/PGPASSWORD, SQL_DATABASE/PGDATABASE
|
||||
examples:
|
||||
@[ -n "$$SQL_HOST" ] || [ -n "$$PGHOST" ] || (echo "Set SQL_HOST/PGHOST (and SQL_PORT/PGPORT, SQL_USER/PGUSER, SQL_PASSWORD/PGPASSWORD, SQL_DATABASE)" && exit 1)
|
||||
@[ -n "$$SQL_PORT" ] || [ -n "$$PGPORT" ] || (echo "Set SQL_PORT/PGPORT" && exit 1)
|
||||
@[ -n "$$SQL_USER" ] || [ -n "$$PGUSER" ] || (echo "Set SQL_USER/PGUSER" && exit 1)
|
||||
@[ -n "$$SQL_PASSWORD" ] || [ -n "$$PGPASSWORD" ] || (echo "Set SQL_PASSWORD/PGPASSWORD" && exit 1)
|
||||
@[ -n "$$SQL_DATABASE" ] || [ -n "$$PGDATABASE" ] || (echo "Set SQL_DATABASE/PGDATABASE" && exit 1)
|
||||
uv python install 3.12
|
||||
UV_VENV_CLEAR=1 uv venv -p 3.12 .venv-examples
|
||||
. .venv-examples/bin/activate; \
|
||||
uv pip install -e .; \
|
||||
set -e; \
|
||||
echo "==> Running examples/01_sync_crud.py"; \
|
||||
python examples/01_sync_crud.py; \
|
||||
echo "==> Running examples/02_bulk_and_filters.py"; \
|
||||
python examples/02_bulk_and_filters.py; \
|
||||
echo "==> Running examples/03_relationships.py"; \
|
||||
python examples/03_relationships.py; \
|
||||
echo "==> Running examples/04_async_crud.py"; \
|
||||
python examples/04_async_crud.py; \
|
||||
echo "==> Running examples/05_cheminformatics.py"; \
|
||||
python examples/05_cheminformatics.py; \
|
||||
deactivate
|
||||
Reference in New Issue
Block a user