name: ytld-sub CI (Windows)

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master
jobs:
  test-unit:
    runs-on: windows-latest
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.10"

    - name: Run unit tests with coverage
      run: |
        curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
        tar -xf ffmpeg.zip
        move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
        move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
        
        python -m pip install -e .[test]
        python -m pytest --reruns 3 --reruns-delay 5 tests/unit

  test-integration:
    runs-on: windows-latest
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.10"

    - name: Run integration tests with coverage
      run: |
        curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
        tar -xf ffmpeg.zip
        move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
        move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
        
        python -m pip install -e .[test]
        python -m pytest --reruns 3 --reruns-delay 5 tests/integration --ignore tests/integration/prebuilt_presets


  test-integration-prebuilt-presets:
    runs-on: windows-latest
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.10"

    - name: Run prebuilt preset integration tests with coverage
      run: |
        curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
        tar -xf ffmpeg.zip
        move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
        move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
        
        python -m pip install -e .[test]
        python -m pytest --reruns 3 --reruns-delay 5 tests/integration/prebuilt_presets

  test-e2e:
    runs-on: windows-latest
    permissions:
      contents: read

    steps:
    - uses: actions/checkout@v3

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.10"

    - name: Run e2e tests with coverage
      run: |
        curl.exe -L -o ffmpeg.zip https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip
        tar -xf ffmpeg.zip
        move "ffmpeg-master-latest-win64-gpl\bin\ffmpeg.exe" "ffmpeg.exe"
        move "ffmpeg-master-latest-win64-gpl\bin\ffprobe.exe" "ffprobe.exe"
        
        python -m pip install -e .[test]
        python -m pytest tests/e2e
