Skip to content

Commit aa9aa8b

Browse files
committed
ci: add test timeout and screenshot watchdog to catch hangs
Background job captures the desktop every 30s during tests. If a test hangs and hits the 20-minute timeout, the last screenshot is uploaded as an artifact for debugging.
1 parent 90ecc39 commit aa9aa8b

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/test-windows-game.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,38 @@ jobs:
5858
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }} `
5959
-p:StridePlatforms=Windows `
6060
-p:StrideGraphicsApis=Direct3D11
61+
- name: Start screenshot watchdog
62+
shell: pwsh
63+
run: |
64+
Start-Job -Name ScreenshotWatchdog -ScriptBlock {
65+
Add-Type -AssemblyName System.Windows.Forms
66+
while ($true) {
67+
Start-Sleep -Seconds 30
68+
try {
69+
$bitmap = [System.Drawing.Bitmap]::new([System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width, [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height)
70+
[System.Drawing.Graphics]::FromImage($bitmap).CopyFromScreen(0, 0, 0, 0, $bitmap.Size)
71+
$bitmap.Save("$env:GITHUB_WORKSPACE\screenshot.png")
72+
} catch {}
73+
}
74+
}
6175
- name: Test
76+
timeout-minutes: 20
6277
run: |
6378
dotnet test build\Stride.Tests.Game.slnf `
6479
--no-build `
6580
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }}
81+
- name: Stop screenshot watchdog
82+
if: always()
83+
shell: pwsh
84+
run: Get-Job -Name ScreenshotWatchdog -ErrorAction SilentlyContinue | Stop-Job -PassThru | Remove-Job
6685
- name: Upload test artifacts
6786
if: always()
6887
uses: actions/upload-artifact@v4
6988
with:
7089
name: test-artifacts-game-common
71-
path: tests/local/
90+
path: |
91+
tests/local/
92+
screenshot.png
7293
if-no-files-found: ignore
7394

7495
#
@@ -146,13 +167,32 @@ jobs:
146167
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }} `
147168
-p:StridePlatforms=Windows `
148169
-p:StrideGraphicsApis=${{ matrix.graphics-api }}
170+
- name: Start screenshot watchdog
171+
shell: pwsh
172+
run: |
173+
Start-Job -Name ScreenshotWatchdog -ScriptBlock {
174+
Add-Type -AssemblyName System.Windows.Forms
175+
while ($true) {
176+
Start-Sleep -Seconds 30
177+
try {
178+
$bitmap = [System.Drawing.Bitmap]::new([System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width, [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height)
179+
[System.Drawing.Graphics]::FromImage($bitmap).CopyFromScreen(0, 0, 0, 0, $bitmap.Size)
180+
$bitmap.Save("$env:GITHUB_WORKSPACE\screenshot.png")
181+
} catch {}
182+
}
183+
}
149184
- name: Test
185+
timeout-minutes: 20
150186
run: |
151187
dotnet test build\Stride.Tests.Game.GPU.slnf `
152188
--no-build `
153189
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }} `
154190
-p:StrideGraphicsApis=${{ matrix.graphics-api }} `
155191
-- RunConfiguration.MaxCpuCount=1
192+
- name: Stop screenshot watchdog
193+
if: always()
194+
shell: pwsh
195+
run: Get-Job -Name ScreenshotWatchdog -ErrorAction SilentlyContinue | Stop-Job -PassThru | Remove-Job
156196
- name: Collect symbols for crash analysis
157197
if: always()
158198
shell: pwsh
@@ -172,4 +212,5 @@ jobs:
172212
path: |
173213
tests/local/
174214
crash-dumps/
215+
screenshot.png
175216
if-no-files-found: ignore

.github/workflows/test-windows-simple.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,34 @@ jobs:
4040
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }} `
4141
-p:StridePlatforms=Windows `
4242
-p:StrideGraphicsApis=Direct3D11
43+
- name: Start screenshot watchdog
44+
shell: pwsh
45+
run: |
46+
Start-Job -Name ScreenshotWatchdog -ScriptBlock {
47+
Add-Type -AssemblyName System.Windows.Forms
48+
while ($true) {
49+
Start-Sleep -Seconds 30
50+
try {
51+
$bitmap = [System.Drawing.Bitmap]::new([System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width, [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height)
52+
[System.Drawing.Graphics]::FromImage($bitmap).CopyFromScreen(0, 0, 0, 0, $bitmap.Size)
53+
$bitmap.Save("$env:GITHUB_WORKSPACE\screenshot.png")
54+
} catch {}
55+
}
56+
}
4357
- name: Test
58+
timeout-minutes: 20
4459
run: |
4560
dotnet test build\Stride.Tests.Simple.slnf `
4661
--no-build `
4762
-p:Configuration=${{ github.event.inputs.build-type || inputs.build-type || 'Debug' }}
63+
- name: Stop screenshot watchdog
64+
if: always()
65+
shell: pwsh
66+
run: Get-Job -Name ScreenshotWatchdog -ErrorAction SilentlyContinue | Stop-Job -PassThru | Remove-Job
67+
- name: Upload debug artifacts
68+
if: cancelled() || failure()
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: debug-simple
72+
path: screenshot.png
73+
if-no-files-found: ignore

0 commit comments

Comments
 (0)