name: 'Setup Windows environment'

inputs:
  python-version:
    description: 'Version of python to set up'
    required: false
    default: '3.14'
  use-ccache:
    description: 'Whether to enable ccache'
    required: false
    default: 'true'

runs:
  using: 'composite'
  steps:
    - name: Use ccache
      if: ${{ inputs.use-ccache == 'true' }}
      uses: hendrikmuhs/ccache-action@v1.2
      with:
        key: ccache-${{ runner.os }}-${{ runner.arch }}-cpu
        max-size: 1GB

    - name: Setup Visual Studio cmd
      shell: cmd
      run: |
        :: Find out path to VS.
        pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
        for /f "delims=" %%x in ('.\vswhere.exe -latest -property InstallationPath') do set VSPATH=%%x
        popd
        :: Import VS vars.
        call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" x64
        :: Export to all steps.
        >>%GITHUB_ENV% set

    - uses: astral-sh/setup-uv@v7

    - name: Setup Python venv
      shell: cmd
      run: |
        uv venv --python ${{ inputs.python-version }}
        call ".venv/Scripts/activate.bat"
        >>%GITHUB_ENV% set
