# CI for extraction-service (TypeScript + Python)
# Triggers on changes to extraction-service or extraction package
name: CI — Extraction Service

on:
  push:
    branches: [main]
    paths:
      - 'services/extraction-service/**'
      - 'packages/extraction/**'
      - 'packages/errors/**'
      - 'packages/cosmos/**'
      - 'packages/config/**'
      - 'packages/auth/**'
      - 'packages/fastify-core/**'
  pull_request:
    branches: [main]
    paths:
      - 'services/extraction-service/**'
      - 'packages/extraction/**'

jobs:
  typescript:
    name: TypeScript (build + test)
    uses: ./.github/workflows/reusable-pnpm-workspace.yml
    with:
      node-version: '22'
      pnpm-version: '10'
      command: |
        pnpm -r --filter @lysnrai/extraction-service... build
        pnpm --filter @lysnrai/extraction-service test
        pnpm --filter @lysnrai/extraction-service exec tsc --noEmit

  python:
    name: Python sidecar (lint + test)
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: services/extraction-service/python
    steps:
      - uses: actions/checkout@v4

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

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install pytest pytest-asyncio httpx ruff

      - name: Lint
        run: ruff check src/ tests/

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