# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: test_python

on: 
  # push: []  # Save time on actions
  pull_request:
    branches: [ "*" ]
  push:
    branches: [ "main", "develop", "release" ]
  workflow_dispatch:
  workflow_call:

jobs:
  build:
    runs-on: ubuntu-22.04
    timeout-minutes: 25
    strategy:
      matrix:
        python-version: ['3.10', '3.11', '3.12', '3.13']

    steps:

    - uses: actions/checkout@v4

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@stable

    - name: Install uv
      uses: astral-sh/setup-uv@v5
      with:
        python-version: ${{ matrix.python-version }}
  
    - name: Test
      run: |
        # Install with dev deps
        uv pip install . --group dev

        # Python lint, test, and coverage
        uv run --locked ruff check ./cfsem
        uv run --locked ruff format ./cfsem --check
        uv run --locked ty check ./cfsem
        uv run --locked pytest ./test/

        # Build docs
        sh build_docs.sh
