name: Test

on: [push, pull_request]

env:
  FORCE_COLOR: 1

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
        cython-version: ["0.29", "3.0"]
        os: [ubuntu-22.04]
        exclude:
          - python-version: "3.13-dev"
            cython-version: "0.29"

    steps:
      - uses: actions/checkout@v4

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

      - name: Install Linux dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y libattr1-dev libfuse-dev
          sudo apt-get install -y pkg-config gcc

      - name: Install Python dependencies (misc)
        run: pip install setuptools pytest sphinx

      - name: Install Python dependencies (Cython 0.29)
        if: ${{ matrix.cython-version == '0.29' }}
        run: pip install "Cython<3"

      - name: Install Python dependencies (Cython 3.0)
        if: ${{ matrix.cython-version == '3.0' }}
        run: pip install "Cython>=3"

      - name: Test
        run: |
          set -e
          python setup.py build_cython
          python setup.py build_ext --inplace
          pytest -v -rs test/

          sphinx-build -b html rst doc/html
