name: Run examples

on:
  pull_request:
    paths:
      - '.github/workflows/examples.yml'
      - 'examples/**.py'
      - 'cmaes/**.py'

jobs:
  examples:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          architecture: x64
      - name: Install dependencies
        run: |
          pip install -U pip setuptools
          pip install --progress-bar off optuna numpy scipy gpytorch torch
          pip install --progress-bar off -U .
      - run: python examples/quadratic_2d_function.py
      - run: python examples/ipop_cma.py
      - run: python examples/bipop_cma.py
      - run: python examples/ellipsoid_function.py
      - run: python examples/optuna_sampler.py
      - run: python examples/lra_cma.py
      - run: python examples/ws_cma.py
      - run: python examples/cma_with_margin_binary.py
      - run: python examples/cma_with_margin_integer.py
      - run: python examples/safecma.py
      - run: python examples/cma_sop.py
  examples-cmawm-without-scipy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'
          architecture: x64
          check-latest: true
      - name: Install dependencies
        run: |
          pip install -U pip setuptools
          pip install --progress-bar off -U .
      - run: python examples/cma_with_margin_binary.py
      - run: python examples/cma_with_margin_integer.py
