name: Windows

on:
  # release:
  #   types: [published]
  push:
    branches:
      - unittests

permissions:
  contents: read

jobs:
  test-windows:
    runs-on: windows-latest
    steps:
      - name: Checkout DPRS repo
        uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.14"

      - name: Add user bin to PATH on Windows
        shell: powershell
        run: |
          $userBinPath = "$env:USERPROFILE\.local\bin"
          Add-Content -Path $env:GITHUB_PATH -Value $userBinPath

      # https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
      - name: Download and install MSVC redistributable
        run: |
          # Download the latest supported Visual C++ Redistributable (2015-2022)
          # You can find the direct download link on the official Microsoft website
          # For x64 systems, use the vc_redist.x64.exe
          Invoke-WebRequest -Uri "https://aka.ms/vc14/vc_redist.x64.exe" -OutFile "vc_redist.x64.exe"
          .\vc_redist.x64.exe /install /quiet /norestart
        shell: powershell
 
      - name: Install DPRS
        run: |
          python -m pip install --upgrade pip
          pip install dprs

      - name: Check Python path
        shell: powershell
        run: python -c "import sys; print(sys.path)"

      - name: Check Python details
        run: |
          python --version
          where python
          pip list
      - name: Run version no. unit test
        run: python -m unittest discover tests -p "*dprs*"
      - name: Run all unit tests
        run: python -m unittest discover tests 
      - name: Run demo dp_check_1d.py in Python
        shell: powershell
        run: |
          # $userBinPath = "$env:USERPROFILE\.local\bin"
          # Add-Content -Path $env:GITHUB_PATH -Value $userBinPath
          python demos\dp_check_1d.py
      # - name: Run DemoDP.ipynb in IPython
      #   shell: powershell
      #   run: |
      #     # $userBinPath = "$env:USERPROFILE\.local\bin"
      #     # Add-Content -Path $env:GITHUB_PATH -Value $userBinPath
      #     cd demos
      #     dir
      #     ipython DemoDP.ipynb
      # - name: Run SimulationDP.ipynb in IPython
      #   shell: powershell
      #   run: |
      #     # $userBinPath = "$env:USERPROFILE\.local\bin"
      #     # Add-Content -Path $env:GITHUB_PATH -Value $userBinPath
      #     cd demos
      #     dir
      #     ipython SimulationDP.ipynb

