name: Phase 8 Integration Tests

on:
  push:
    branches: [main]
    paths:
      - 'apps/coordinator-api/tests/test_phase8_tasks.py'
      - 'apps/coordinator-api/tests/test_phase8_optional_endpoints.py'
      - 'apps/coordinator-api/**'
  pull_request:
    branches: [main]
    paths:
      - 'apps/coordinator-api/tests/test_phase8_tasks.py'
      - 'apps/coordinator-api/tests/test_phase8_optional_endpoints.py'
      - 'apps/coordinator-api/**'

jobs:
  phase8-integration:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.13']
      fail-fast: false
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e .
          pip install -e packages/py/aitbc-crypto
          pip install fastapi uvicorn sqlmodel pydantic-settings aiosqlite slowapi orjson prometheus-client
          pip install pytest pytest-asyncio pytest-cov

      - name: Run Phase 8 health tests (skips if env not set)
        run: |
          cd apps/coordinator-api
          python -m pytest tests/test_phase8_tasks.py -v --tb=short --disable-warnings

      - name: Run optional Phase 8 endpoint tests (skips if env not set)
        run: |
          cd apps/coordinator-api
          python -m pytest tests/test_phase8_optional_endpoints.py -v --tb=short --disable-warnings
