name: CI

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

jobs:
  lint-and-test:
    runs-on: ubuntu-latest
    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 -e ".[dev]"

      - name: Syntax check
        run: |
          python -c "
          import ast, pathlib, sys
          errors = []
          for f in pathlib.Path('.').rglob('*.py'):
              if '.venv' in str(f) or '.forgejo' in str(f):
                  continue
              try:
                  ast.parse(f.read_text())
              except SyntaxError as e:
                  errors.append(f'{f}: {e}')
          if errors:
              for e in errors:
                  print(f'SYNTAX ERROR: {e}', file=sys.stderr)
              sys.exit(1)
          print('All Python files pass syntax check')
          "

      - name: Ruff lint
        run: ruff check .

      - name: Ruff format check
        run: ruff format --check .

      - name: Run tests
        run: pytest -v --tb=short
        continue-on-error: true  # Tests don't exist yet — remove this line after Phase 4
