name: CI

on:
  push:
    branches: [main, development]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    env:
      # A non-empty dummy key so app.py imports offline; no network call is made at import,
      # and the unit tests never hit Gemini.
      GEMINI_API_KEY: test-key-not-used
    steps:
      - uses: actions/checkout@v4

      - 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 -r requirements-dev.txt

      - name: Syntax check
        run: python -m py_compile app.py db.py scripts/*.py eval/*.py tests/*.py

      - name: Lint (pyflakes: unused imports / undefined names) — informational
        continue-on-error: true
        run: |
          pip install ruff
          ruff check --select F app.py db.py scripts/ eval/ tests/

      - name: Unit tests (offline, no Gemini)
        run: python -m pytest tests/ -q
