name: CI

on:
  push:
    branches: [main, 'feature/**', 'fix/**']
  pull_request:
    branches: [main]

jobs:
  python:
    name: Python tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: pip

      # circuitforge-core is a sibling on dev machines but a public GitHub
      # mirror in CI — install from there to avoid path-dependency issues.
      - name: Install circuitforge-core
        run: pip install --no-cache-dir git+https://github.com/CircuitForgeLLC/circuitforge-core.git

      - name: Install snipe (dev extras)
        run: pip install --no-cache-dir -e ".[dev]"

      - name: Lint
        run: ruff check .

      - name: Test
        run: pytest tests/ -v --tb=short

  frontend:
    name: Frontend typecheck + tests
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: web
    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: npm
          cache-dependency-path: web/package-lock.json

      - name: Install dependencies
        run: npm ci

      - name: Typecheck + build
        run: npm run build

      - name: Unit tests
        run: npm run test
