name: SessionID KPI Integration Test

on:
  workflow_dispatch:

jobs:
  integration-test:
    runs-on: ubuntu-latest

    permissions:
      contents: read

    env:
      # Read SESSION_ID from repo secrets. REQUIRED.
      SESSION_ID: ${{ secrets.MC_TEST_SESSIONID }}
      # Optional: enable debug logging in app
      DEBUG_LOG: "true"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install system deps
        run: |
          sudo apt-get update
          sudo apt-get install -y libatlas-base-dev gfortran
          sudo apt-get install -y --no-install-recommends \
            libgl1 \
            libglib2.0-0 \
            gcc \
            python3-dev
          sudo rm -rf /var/lib/apt/lists/*
      - name: Install Python dependencies
        run: |
          python -m pip install --upgrade pip
          pip install --no-cache-dir -r requirements-apps.txt
          pip install --no-cache-dir aimodelshare --no-dependencies
          # Test-only dependencies (keep if not in requirements-apps.txt)
          pip install --no-cache-dir pytest pytest-timeout

      - name: Run integration tests
        run: |
          pytest -q --disable-warnings --maxfail=1 tests/test_sessionid_kpi_integration.py
