name: "setup-uv-env"
description: "Composite action to setup the Python and uv environment."

inputs:
  python-version:
    required: false
    description: "The python version to use"
    default: "3.11"
  is-toolkit:
    required: false
    description: "Whether this is a toolkit package"
    default: "false"
  is-contrib:
    required: false
    description: "Whether this is a contrib package"
    default: "false"
  is-lib:
    required: false
    description: "Whether this is a library package"
    default: "false"
  working-directory:
    required: false
    description: "Working directory for the installation (used for toolkits)"
    default: "."

runs:
  using: "composite"
  steps:
    - name: Install uv
      uses: astral-sh/setup-uv@v6
      with:
        working-directory: ${{ inputs.working-directory }}
        python-version: ${{ inputs.python-version }}

    - name: Install toolkit dependencies
      if: inputs.is-toolkit == 'true'
      working-directory: ${{ inputs.working-directory }}
      run: |
        echo "Installing dependencies for ${{ inputs.working-directory }}"
        make install-local
      shell: bash

    - name: Install contrib dependencies
      if: inputs.is-contrib == 'true'
      working-directory: ${{ inputs.working-directory }}
      run: |
        echo "Installing dependencies for ${{ inputs.working-directory }}"
        make install
      shell: bash

    - name: Install libs dependencies
      if: inputs.is-toolkit != 'true'
      run: uv sync --extra all --extra dev
      shell: bash
