|
| 1 | +name: Test Samples (Screenshots) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + build-type: |
| 7 | + description: Build |
| 8 | + default: Debug |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - Debug |
| 12 | + - Release |
| 13 | + schedule: |
| 14 | + # Daily at 04:00 UTC. |
| 15 | + - cron: '0 4 * * *' |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: test-samples-screenshots-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + Run: |
| 23 | + name: Capture & compare all samples (${{ matrix.graphics-api }}, ${{ github.event.inputs.build-type || 'Debug' }}) |
| 24 | + # Single job per graphics API: the harness + orchestrator + comparator are sample-agnostic, so a |
| 25 | + # matrix-per-sample would build the engine 15× for the same artifacts. Sequential capture |
| 26 | + # via xunit's DisableParallelization keeps total compute low (~1× engine build + ~5 min of |
| 27 | + # actual sample runs) at comparable wall-clock to a 15-parallel matrix. Per-API parallelism |
| 28 | + # is unavoidable (each API needs its own engine build). |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + graphics-api: [Direct3D11, Direct3D12, Vulkan] |
| 33 | + runs-on: windows-2025-vs2026 |
| 34 | + # TODO: drop continue-on-error once D3D12 and Vulkan captures are stable. |
| 35 | + continue-on-error: ${{ matrix.graphics-api != 'Direct3D11' }} |
| 36 | + env: |
| 37 | + # Software rendering is the default in the autotesting harness; set STRIDE_TESTS_GPU=1 to opt into the GPU. |
| 38 | + STRIDE_TESTS_RENDERDOC: "error" |
| 39 | + DOTNET_DbgEnableMiniDump: "1" |
| 40 | + DOTNET_DbgMiniDumpType: "1" |
| 41 | + DOTNET_DbgMiniDumpName: "${{ github.workspace }}\\crash-dumps\\dotnet_%p.dmp" |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + lfs: true |
| 46 | + submodules: true |
| 47 | + |
| 48 | + - uses: actions/setup-dotnet@v4 |
| 49 | + with: |
| 50 | + dotnet-version: '10.0.x' |
| 51 | + |
| 52 | + - name: Configure crash dumps |
| 53 | + shell: pwsh |
| 54 | + run: | |
| 55 | + reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d 1 /f |
| 56 | + $dumpDir = "${{ github.workspace }}\crash-dumps" |
| 57 | + New-Item -Path $dumpDir -ItemType Directory -Force | Out-Null |
| 58 | + reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpFolder /t REG_EXPAND_SZ /d $dumpDir /f |
| 59 | + reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpType /t REG_DWORD /d 1 /f |
| 60 | + reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" /v DumpCount /t REG_DWORD /d 10 /f |
| 61 | +
|
| 62 | + # nuget.config declares `bin/packages` as the `stride-local` source. NuGet validates every |
| 63 | + # source path at restore time; on a fresh CI checkout that dir doesn't exist yet (it gets |
| 64 | + # populated by Stride's auto-pack-deploy on first build), so we materialize it as empty. |
| 65 | + - name: Pre-create bin/packages so restore doesn't fail on missing local source |
| 66 | + shell: pwsh |
| 67 | + run: New-Item -ItemType Directory -Path bin/packages -Force | Out-Null |
| 68 | + |
| 69 | + # PackageStore at test runtime calls Settings.LoadDefaultSettings(null) which only loads |
| 70 | + # user + machine configs, NOT the workspace's nuget.config (no walkup with null root). |
| 71 | + # Locally this works because the dev's user config has Stride.AutoPackDeploy's |
| 72 | + # %LocalAppData%\Stride\NugetDev as a source. CI's runneradmin user has no such config, |
| 73 | + # so add bin/packages explicitly to the user config. --configfile forces the write to |
| 74 | + # the user config rather than walking up to the workspace's nuget.config (which would |
| 75 | + # conflict with the existing 'stride-local' source declared there). |
| 76 | + - name: Register bin/packages with user NuGet config |
| 77 | + shell: pwsh |
| 78 | + run: | |
| 79 | + New-Item -Path "$env:APPDATA\NuGet" -ItemType Directory -Force | Out-Null |
| 80 | + dotnet nuget add source "${{ github.workspace }}\bin\packages" --name stride-local --configfile "$env:APPDATA\NuGet\NuGet.Config" |
| 81 | +
|
| 82 | + # Stride.Games.AutoTesting must be built explicitly so its auto-pack-deploy lands the .nupkg |
| 83 | + # in bin/packages — the sample projects consume it via <PackageReference>, not via the |
| 84 | + # ProjectReference graph the test project would otherwise transitively pull. The engine |
| 85 | + # is built with StrideGraphicsApis pinned to the matrix entry so the resulting nupkg only |
| 86 | + # contains binaries for that API; the regenerated samples then link against those. |
| 87 | + - name: Build harness assembly (packs Stride.Games.AutoTesting into bin/packages) |
| 88 | + run: | |
| 89 | + dotnet build sources\engine\Stride.Games.AutoTesting\Stride.Games.AutoTesting.csproj ` |
| 90 | + -p:StrideNativeBuildMode=Clang ` |
| 91 | + -nr:false -v:m -p:WarningLevel=0 ` |
| 92 | + -p:Configuration=${{ github.event.inputs.build-type || 'Debug' }} ` |
| 93 | + -p:StrideGraphicsApi=${{ matrix.graphics-api }} ` |
| 94 | + -p:StrideGraphicsApis=${{ matrix.graphics-api }} |
| 95 | +
|
| 96 | + # Install Stride.Dependencies.Lavapipe and register its ICD with the Vulkan loader |
| 97 | + # so the samples' Vulkan path resolves a software driver on the CI runner (no GPU). |
| 98 | + # On Windows the loader reads HKLM\SOFTWARE\Khronos\Vulkan\Drivers — VK_DRIVER_FILES |
| 99 | + # env var alone isn't reliable across runner Vulkan SDK versions. Mirrors the |
| 100 | + # SwiftShader registration in test-windows-game.yml. |
| 101 | + - name: Install Lavapipe and register its Vulkan ICD (Vulkan only) |
| 102 | + if: matrix.graphics-api == 'Vulkan' |
| 103 | + shell: pwsh |
| 104 | + run: | |
| 105 | + $tmpDir = "${{ runner.temp }}\lavapipe-fetch" |
| 106 | + New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null |
| 107 | + Set-Content -Path "$tmpDir\LavapipeFetch.csproj" -Value '<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net10.0</TargetFramework></PropertyGroup></Project>' |
| 108 | + dotnet add "$tmpDir\LavapipeFetch.csproj" package Stride.Dependencies.Lavapipe |
| 109 | + $icd = Get-ChildItem -Recurse -Path "$env:USERPROFILE\.nuget\packages\stride.dependencies.lavapipe" -Filter "lvp_icd*.json" -ErrorAction SilentlyContinue | Where-Object { $_.DirectoryName -match 'win-x64' } | Select-Object -First 1 |
| 110 | + if (-not $icd) { throw "Lavapipe ICD not found in NuGet cache after restore." } |
| 111 | + New-Item -Path "HKLM:\SOFTWARE\Khronos\Vulkan\Drivers" -Force | Out-Null |
| 112 | + New-ItemProperty -Path "HKLM:\SOFTWARE\Khronos\Vulkan\Drivers" -Name $icd.FullName -Value 0 -PropertyType DWord -Force | Out-Null |
| 113 | + Write-Host "Registered Lavapipe ICD: $($icd.FullName)" |
| 114 | +
|
| 115 | + # Builds the test project plus its transitive ProjectReferences. StrideGraphicsApi (singular) |
| 116 | + # selects the test SDK output path; StrideGraphicsApis (plural) keeps the engine deps aligned |
| 117 | + # with the harness build above. |
| 118 | + - name: Build test project |
| 119 | + run: | |
| 120 | + dotnet build samples\Tests\Stride.Samples.Tests.csproj ` |
| 121 | + -p:StrideNativeBuildMode=Clang ` |
| 122 | + -nr:false -v:m -p:WarningLevel=0 ` |
| 123 | + -p:Configuration=${{ github.event.inputs.build-type || 'Debug' }} ` |
| 124 | + -p:StrideGraphicsApi=${{ matrix.graphics-api }} ` |
| 125 | + -p:StrideGraphicsApis=${{ matrix.graphics-api }} |
| 126 | +
|
| 127 | + - name: Run sample screenshot tests |
| 128 | + env: |
| 129 | + # Comparator opts a few non-deterministic tests (ParticlesSample, SpriteStudioDemo, |
| 130 | + # AnimatedModel) into a Claude vision second-opinion when LPIPS is over threshold. |
| 131 | + # Key is bound to a budget-capped Anthropic workspace; the fallback only runs on |
| 132 | + # frames that already failed LPIPS so cost is bounded even when noisy. |
| 133 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 134 | + run: | |
| 135 | + dotnet test samples\Tests\Stride.Samples.Tests.csproj ` |
| 136 | + --no-build ` |
| 137 | + --filter "FullyQualifiedName~Stride.Samples.Tests.SampleScreenshotTests" ` |
| 138 | + --logger "trx;LogFileName=screenshots.trx" ` |
| 139 | + --results-directory TestResults ` |
| 140 | + -p:Configuration=${{ github.event.inputs.build-type || 'Debug' }} ` |
| 141 | + -p:StrideGraphicsApi=${{ matrix.graphics-api }} |
| 142 | +
|
| 143 | + - name: Publish test report |
| 144 | + if: always() |
| 145 | + uses: phoenix-actions/test-reporting@v15 |
| 146 | + with: |
| 147 | + name: 'Sample screenshot regression (${{ matrix.graphics-api }})' |
| 148 | + path: TestResults/*.trx |
| 149 | + reporter: dotnet-trx |
| 150 | + output-to: step-summary |
| 151 | + list-tests: 'failed' |
| 152 | + |
| 153 | + - name: Upload test artifacts (captures + done.json + TRX) |
| 154 | + if: always() |
| 155 | + uses: actions/upload-artifact@v4 |
| 156 | + with: |
| 157 | + name: screenshots-${{ matrix.graphics-api }} |
| 158 | + path: | |
| 159 | + screenshot-out/ |
| 160 | + TestResults/ |
| 161 | + if-no-files-found: warn |
| 162 | + |
| 163 | + - name: Upload crash dumps |
| 164 | + if: always() |
| 165 | + uses: actions/upload-artifact@v4 |
| 166 | + with: |
| 167 | + name: crash-dumps-${{ matrix.graphics-api }} |
| 168 | + path: crash-dumps/ |
| 169 | + if-no-files-found: ignore |
0 commit comments