ci: Re-run benchmark for data validation #14
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: Foundry Local Performance Benchmark | |
| on: | |
| push: | |
| branches: | |
| - 'perf/foundry-local-benchmark-*' | |
| jobs: | |
| benchmark: | |
| runs-on: windows-2025 | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: read | |
| checks: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Add msbuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| # CLI branch only: Install Foundry Local CLI | |
| - name: Install Foundry Local CLI | |
| if: contains(github.ref, 'benchmark-cli') | |
| shell: pwsh | |
| run: | | |
| Write-Host "Installing Foundry Local CLI via winget..." | |
| winget install Microsoft.FoundryLocal --accept-source-agreements --accept-package-agreements --silent | |
| # Refresh PATH | |
| $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") | |
| # Verify installation | |
| $foundryPath = Get-Command foundry -ErrorAction SilentlyContinue | |
| if ($foundryPath) { | |
| Write-Host "Foundry CLI installed at: $($foundryPath.Source)" | |
| foundry --version | |
| } else { | |
| Write-Error "Foundry CLI installation failed - 'foundry' command not found" | |
| exit 1 | |
| } | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-x64-nuget-perf-${{ hashFiles('**/packages.lock.json', 'Directory.Packages.props', '**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-x64-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore AIDevGallery.sln -r win-x64 /p:Configuration=Release /p:Platform=x64 | |
| - name: Build AIDevGallery.Utils | |
| run: dotnet build AIDevGallery.Utils --no-restore /p:Configuration=Release | |
| - name: Build Test Project | |
| run: dotnet build AIDevGallery.Tests -r win-x64 -f net9.0-windows10.0.26100.0 /p:Configuration=Release /p:Platform=x64 | |
| - name: Run FirstCatalogQuery (100 fresh processes) | |
| shell: pwsh | |
| run: | | |
| $env:PERFORMANCE_OUTPUT_PATH = "${{ github.workspace }}\PerfResults" | |
| New-Item -ItemType Directory -Force -Path $env:PERFORMANCE_OUTPUT_PATH | Out-Null | |
| $testDll = "AIDevGallery.Tests\bin\x64\Release\net9.0-windows10.0.26100.0\win-x64\AIDevGallery.Tests.dll" | |
| for ($i = 1; $i -le 100; $i++) { | |
| Write-Host "`n=== FirstCatalogQuery Run $i/100 ===" | |
| dotnet test $testDll ` | |
| --filter "TestCategory=FirstCatalogQuery" ` | |
| --logger "console;verbosity=detailed" ` | |
| --verbosity quiet | |
| Write-Host "Exit code: $LASTEXITCODE" | |
| } | |
| - name: Run SubsequentCatalogQuery (100 iterations in one process) | |
| shell: pwsh | |
| run: | | |
| $env:PERFORMANCE_OUTPUT_PATH = "${{ github.workspace }}\PerfResults" | |
| $testDll = "AIDevGallery.Tests\bin\x64\Release\net9.0-windows10.0.26100.0\win-x64\AIDevGallery.Tests.dll" | |
| Write-Host "`n=== SubsequentCatalogQuery (100 iterations) ===" | |
| New-Item -ItemType Directory -Force -Path "${{ github.workspace }}\TestResults" | Out-Null | |
| dotnet test $testDll ` | |
| --filter "TestCategory=SubsequentCatalogQuery" ` | |
| --logger "trx;LogFileName=${{ github.workspace }}\TestResults\SubsequentCatalogQuery.trx" ` | |
| --logger "console;verbosity=detailed" ` | |
| --results-directory "${{ github.workspace }}\TestResults" ` | |
| --verbosity quiet | |
| - name: Show Results Summary | |
| if: always() | |
| shell: pwsh | |
| run: | | |
| Write-Host "`n=== Performance Results ===" | |
| $files = Get-ChildItem -Path "${{ github.workspace }}\PerfResults" -Filter "*.json" -ErrorAction SilentlyContinue | |
| Write-Host "Found $($files.Count) result files" | |
| foreach ($f in $files) { | |
| Write-Host "`n--- $($f.Name) ---" | |
| Get-Content $f.FullName | Write-Host | |
| } | |
| - name: Upload Performance Results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: perf-results-${{ contains(github.ref, 'benchmark-cli') && 'cli' || 'sdk' }} | |
| path: | | |
| PerfResults/ | |
| TestResults/ | |
| - name: Display Test Report | |
| if: always() | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: Performance Benchmark - ${{ contains(github.ref, 'benchmark-cli') && 'CLI' || 'SDK' }} | |
| path: 'TestResults/*.trx' | |
| reporter: dotnet-trx | |
| fail-on-error: false |