name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
    
    steps:
    - uses: actions/checkout@v4
    
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    
    - name: Set up Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    
    - name: Create virtual environment
      run: |
        python -m venv .venv
        echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH
        echo "VIRTUAL_ENV=${{ github.workspace }}/.venv" >> $GITHUB_ENV
    
    - name: Install dependencies
      run: |
        pip install --upgrade pip
        pip install maturin pytest networkx pandas
    
    - name: Build and install
      env:
        PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
      run: |
        source .venv/bin/activate
        cd python-groggy
        maturin develop
    
    - name: Run tests
      run: |
        source .venv/bin/activate
        pytest tests/
