name: Validate

on:
  push:
  pull_request:

permissions:
  contents: read

concurrency:
  group: validate-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  validate:
    timeout-minutes: 15
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        python-version: ["3.11", "3.12", "3.13"]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v7

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

      - name: Install runtime and validation dependencies
        run: python -m pip install -e ".[dev]"

      - name: Validate repository
        run: python scripts/validate_repo.py

      - name: Run script and runtime tests
        run: python -m unittest discover -s scripts/tests

      - name: Run packaged behavior eval fixtures
        run: python scripts/run_behavior_evals.py --all-packaged

      - name: Validate Agent Skills packages
        run: python scripts/validate_agent_skills.py

      - name: Run CLI smoke checks
        run: |
          gamedesignos --version
          python -m gamedesignos --version
          gamedesignos doctor --json

      - name: Build wheel and source distribution
        run: python -m build

      - name: Rebuild wheel from source distribution
        run: python scripts/smoke_sdist_rebuild.py

      - name: Install wheel over editable runtime
        run: python -m pip install --force-reinstall --no-deps --no-index --find-links dist gamedesignos

      - name: Smoke test installed wheel outside checkout
        run: python scripts/smoke_installed_wheel.py
