name: Tests
on: [push, pull_request]
jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']
        numpy-version: ['1.21', '1.26', '2.0', 'dev']
        exclude:
          - python-version: '3.11'
            numpy-version: '1.21'
          - python-version: '3.12'
            numpy-version: '1.21'
      fail-fast: true
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Dependencies
        run: |
          python -m pip install --upgrade pip
          if [ "${{ matrix.numpy-version }}" == "dev" ]; then
            PIP_EXTRA='numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple'
          elif [ "${{ matrix.numpy-version }}" == "1.21" ]; then
            PIP_EXTRA='numpy==1.21.*'
          else
            PIP_EXTRA='numpy==1.26.*'
          fi

          if [ "${{ matrix.python-version }}" == "3.9" ]; then
            sed -i '/^ndonnx/d' requirements-dev.txt
          fi

          python -m pip install -r requirements-dev.txt $PIP_EXTRA

      - name: Run Tests
        run: |
          if [[ "${{ matrix.numpy-version }}" == "1.21" || "${{ matrix.numpy-version }}" == "dev" ]]; then
             PYTEST_EXTRA=(-k "numpy and not jax and not torch and not dask and not sparse")
          fi
          pytest -v "${PYTEST_EXTRA[@]}"

          # Make sure it installs
          python -m pip install .
