name: CI

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

jobs:
  test:
    name: Clean Windows Runner Test
    runs-on: windows-latest
    timeout-minutes: 15

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

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

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[dev,web]"

      - name: Code Quality (ruff)
        run: |
          ruff check .

      - name: Run Hermetic Offline Pytest Suite
        run: |
          pytest -v

      - name: Run Automated Release Gate
        run: |
          python scripts/release_gate.py

  headless:
    name: Headless Run (no GUI dependencies)
    runs-on: windows-latest
    timeout-minutes: 15
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Install dependencies without GUI extras
        run: |
          python -m pip install --upgrade pip
          pip install -e ".[dev,web]"
          pip uninstall -y customtkinter

      # A test module importing customtkinter at module scope aborts collection
      # of the WHOLE session instead of skipping itself, which takes the release
      # gate down with it. This job fails if that guard is ever dropped again.
      - name: Suite must skip, not abort, without GUI dependencies
        run: |
          pytest -q
