Add whisper support #23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Validation | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "tests/**" | |
| - "samples/**" | |
| - "*.sln" | |
| - "*.csproj" | |
| - ".github/workflows/pr-validation.yml" | |
| env: | |
| OPENVINO_VERSION: "2025.2.0.0" | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| jobs: | |
| build-and-test: | |
| name: Build and Test | |
| runs-on: windows-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Cache OpenVINO Runtime | |
| id: cache-openvino | |
| uses: actions/cache@v3 | |
| with: | |
| path: build/native/openvino_genai_windows_${{ env.OPENVINO_VERSION }}_x86_64 | |
| key: openvino-runtime-${{ env.OPENVINO_VERSION }} | |
| - name: Download OpenVINO Runtime | |
| if: steps.cache-openvino.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| Write-Host "Downloading OpenVINO GenAI Runtime $env:OPENVINO_VERSION..." | |
| $outputPath = "build/native" | |
| New-Item -ItemType Directory -Force -Path $outputPath | |
| $url = "https://storage.openvinotoolkit.org/repositories/openvino_genai/packages/pre-release/${env:OPENVINO_VERSION}/openvino_genai_windows_${env:OPENVINO_VERSION}_x86_64.zip" | |
| $zipPath = "$outputPath/openvino_genai.zip" | |
| Write-Host "URL: $url" | |
| Write-Host "Output path: $zipPath" | |
| try { | |
| # Use WebClient instead of Invoke-WebRequest for better compatibility | |
| $webClient = New-Object System.Net.WebClient | |
| $webClient.DownloadFile($url, $zipPath) | |
| $webClient.Dispose() | |
| Write-Host "Download completed successfully" | |
| Write-Host "Extracting archive..." | |
| Add-Type -AssemblyName System.IO.Compression.FileSystem | |
| [System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $outputPath) | |
| Remove-Item $zipPath | |
| Write-Host "OpenVINO Runtime downloaded and extracted successfully" | |
| } | |
| catch { | |
| Write-Host "Error downloading OpenVINO runtime: $_" | |
| Write-Host "Error details: $($_.Exception.Message)" | |
| exit 1 | |
| } | |
| - name: Setup OpenVINO DLLs | |
| shell: pwsh | |
| run: | | |
| $runtimePath = "build/native/openvino_genai_windows_${env:OPENVINO_VERSION}_x86_64/runtime" | |
| $targetPath = "build/native/runtimes/win-x64/native" | |
| New-Item -ItemType Directory -Force -Path $targetPath | |
| # Copy Release DLLs | |
| Copy-Item "$runtimePath/bin/intel64/Release/*.dll" -Destination $targetPath -Force | |
| Copy-Item "$runtimePath/3rdparty/tbb/bin/*.dll" -Destination $targetPath -Force | |
| Write-Host "Copied $(Get-ChildItem $targetPath -Filter *.dll | Measure-Object).Count DLL files" | |
| - name: Build Whisper C++ Wrapper | |
| shell: pwsh | |
| run: | | |
| Write-Host "Building Whisper C++ wrapper..." | |
| # Set up build directory | |
| $buildDir = "build/native/wrapper" | |
| New-Item -ItemType Directory -Force -Path $buildDir | |
| # Set paths | |
| $openvinoPath = "build/native/openvino_genai_windows_${env:OPENVINO_VERSION}_x86_64" | |
| $targetPath = "build/native/runtimes/win-x64/native" | |
| # Configure CMake | |
| cmake -S src/native -B $buildDir ` | |
| -DCMAKE_BUILD_TYPE=Release ` | |
| -DCMAKE_PREFIX_PATH="$openvinoPath" ` | |
| -DOpenVINOGenAI_DIR="$openvinoPath/cmake" | |
| # Build the wrapper | |
| cmake --build $buildDir --config Release | |
| # Copy the wrapper DLL to the target directory | |
| Copy-Item "$buildDir/Release/openvino_genai_c.dll" -Destination $targetPath -Force | |
| Write-Host "Whisper wrapper built and copied successfully" | |
| - name: Restore dependencies | |
| run: dotnet restore OpenVINO.NET.sln | |
| - name: Build solution | |
| run: dotnet build OpenVINO.NET.sln --configuration Release --no-restore /p:TreatWarningsAsErrors=true | |
| env: | |
| CI: true | |
| - name: Run unit tests | |
| run: | | |
| dotnet test tests/OpenVINO.NET.GenAI.Tests/OpenVINO.NET.GenAI.Tests.csproj ` | |
| --configuration Release ` | |
| --no-build ` | |
| --verbosity normal ` | |
| --logger "trx;LogFileName=test-results.trx" ` | |
| --collect:"XPlat Code Coverage" ` | |
| --results-directory ./TestResults ` | |
| --filter "FullyQualifiedName!~WhisperIntegrationTests" | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: TestResults/ | |
| - name: Test Report | |
| uses: dorny/test-reporter@v2 | |
| if: always() | |
| with: | |
| name: .NET Test Results | |
| path: TestResults/*.trx | |
| reporter: dotnet-trx | |
| fail-on-error: true | |
| - name: Code Coverage Report | |
| if: false # Disabled: Container action not supported on Windows runners | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: TestResults/**/coverage.cobertura.xml | |
| badge: true | |
| format: markdown | |
| output: both | |
| - name: Add Coverage PR Comment | |
| if: false # Disabled: Depends on code coverage report | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| recreate: true | |
| path: code-coverage-results.md | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: windows-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore OpenVINO.NET.sln | |
| - name: Check formatting | |
| run: dotnet format OpenVINO.NET.sln --verify-no-changes --verbosity diagnostic | |
| - name: Run code analysis | |
| run: | | |
| dotnet build OpenVINO.NET.sln --configuration Release /p:EnableNETAnalyzers=true /p:AnalysisMode=AllEnabledByDefault |