diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..74ea0b4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: Bepo CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + env: + TRANSFORMERS_OFFLINE: "1" + HF_HUB_OFFLINE: "1" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements-dev.txt + + - name: Run tests + run: python -m pytest tests/ -v diff --git a/README.md b/README.md index 982bd9b..205fc2c 100644 --- a/README.md +++ b/README.md @@ -252,11 +252,16 @@ Returns API version information and a list of available endpoints. ## Running Tests ```bash -pip install pytest httpx +pip install -r requirements-dev.txt python -m pytest tests/ -v ``` -Tests use a temporary in-memory database and never attempt to download the CLIP model. +Tests disable CLIP/model downloads and run against temporary SQLite DB/filesystem paths (not your local `memories.db` or `images/`). + +## CI + +GitHub Actions runs `python -m pytest tests/ -v` on every pull request and on pushes to `main`. +CI sets `TRANSFORMERS_OFFLINE=1` and `HF_HUB_OFFLINE=1` defensively so tests never rely on model downloads. ## Database Schema diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..5769ad4 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +pytest +httpx diff --git a/tests/test_api.py b/tests/test_api.py index f58ce9f..2c70d2e 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -19,7 +19,9 @@ def isolated_db(tmp_path, monkeypatch): Point DB_PATH / IMAGES_DIR at temp paths and ensure CLIP is disabled so tests never attempt a model download. """ - # Suppress CLIP – must be patched before init_db/lifespan runs + # Force offline mode and suppress CLIP before init_db/lifespan runs + monkeypatch.setenv("TRANSFORMERS_OFFLINE", "1") + monkeypatch.setenv("HF_HUB_OFFLINE", "1") monkeypatch.setattr(app_module, "USE_CLIP", False) monkeypatch.setattr(app_module, "model", None) monkeypatch.setattr(app_module, "processor", None)