name: Test-PyPI

on:
  workflow_dispatch:
    inputs:
      index:
        description: "Target index: pypi or testpypi"
        required: true
        type: choice
        options:
          - pypi
          - testpypi

jobs:
  build-test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
        python-version: ['3.12', '3.13', '3.14']
    defaults:
      run:
        shell: bash -l {0}

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive

      - name: Dependencies
        run: |
          pip install pytest mypy

      - name: Install PyPi
        if: ${{ inputs.index == 'pypi' }}
        run: |
          pip install clingo-funasp

      - name: Install PyPi Test
        if: ${{ inputs.index != 'pypi' }}
        run: |
          pip install -i https://test.pypi.org/simple/ clingo-funasp

      - name: Test
        run: |
          cd lib/python-api/tests && pytest -v

      - name: Mypy
        run: |
          cd lib/python-api/tests && mypy -v *.py
