name: 'Setup AuroraView Development Environment'
description: 'Sets up Python, Rust, uv, and just for AuroraView development'

inputs:
  python-version:
    description: 'Python version to use'
    required: true
    default: '3.11'
  rust-components:
    description: 'Additional Rust components to install'
    required: false
    default: ''
  cache-key-suffix:
    description: 'Additional suffix for cache keys'
    required: false
    default: ''
  install-dependencies:
    description: 'Whether to install project dependencies'
    required: false
    default: 'true'

outputs:
  python-version:
    description: 'The Python version that was installed'
    value: ${{ steps.setup-python.outputs.python-version }}
  rust-version:
    description: 'The Rust version that was installed'
    value: ${{ steps.setup-rust.outputs.rustc-version }}

runs:
  using: 'composite'
  steps:
    - name: Setup Python
      id: setup-python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ inputs.python-version }}

    - name: Install uv
      uses: astral-sh/setup-uv@v7
      with:
        python-version: ${{ inputs.python-version }}
        enable-cache: false

    - name: Setup Rust
      id: setup-rust
      uses: dtolnay/rust-toolchain@1.90.0
      with:
        components: ${{ inputs.rust-components }}

    - name: Setup Advanced Caching
      uses: ./.github/actions/cache-setup
      with:
        cache-type: 'build'
        cache-key-suffix: ${{ inputs.cache-key-suffix }}
        python-version: ${{ inputs.python-version }}

    - name: Setup just
      uses: extractions/setup-just@v3

    - name: Install system dependencies (Ubuntu)
      if: runner.os == 'Linux'
      shell: bash
      run: |
        sudo apt-get update
        sudo apt-get install -y \
          libwebkit2gtk-4.1-dev \
          libgtk-3-dev \
          libglib2.0-dev \
          libpango1.0-dev \
          libcairo2-dev
        # X11 and related dev packages needed by active-win-pos-rs and GUI crates on Linux
        sudo apt-get install -y \
          libx11-dev \
          libx11-xcb-dev \
          libxcb1-dev \
          libxcb-render0-dev \
          libxcb-shape0-dev \
          libxcb-xfixes0-dev \
          libxrandr-dev \
          libxi-dev \
          libxfixes-dev \
          libxtst-dev \
          libxdo-dev \
          pkg-config
        # Qt6 dependencies for PySide6
        sudo apt-get install -y \
          libegl1 \
          libxkbcommon0 \
          libdbus-1-3


    - name: Install dependencies
      if: inputs.install-dependencies == 'true'
      shell: bash
      run: just ci-install

