Skip to content

Commit 5cefd51

Browse files
committed
[build] Add Linux/Mac screenshots
1 parent 45fbb01 commit 5cefd51

File tree

1 file changed

+122
-23
lines changed

1 file changed

+122
-23
lines changed

.github/workflows/screenshot.yml

Lines changed: 122 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Take a screenshot of the DVR-Scan UI and upload it as an artifact.
1+
# Take screenshots of the DVR-Scan UI on Windows, Linux, and macOS and upload them as artifacts.
22
name: Screenshot UI
33

44
on:
@@ -8,15 +8,13 @@ env:
88
ffmpeg_version: "7.1"
99

1010
jobs:
11-
run-ui-and-screenshot:
11+
screenshot-windows:
1212
runs-on: windows-latest
13+
env:
14+
UV_SYSTEM_PYTHON: 1
1315
strategy:
1416
matrix:
1517
python-version: ["3.12"]
16-
resolution:
17-
- {width: 1920, height: 1080, scale: 100}
18-
- {width: 2560, height: 1440, scale: 150}
19-
- {width: 3840, height: 2160, scale: 200}
2018

2119
steps:
2220
- uses: actions/checkout@v4
@@ -49,20 +47,15 @@ jobs:
4947
run: |
5048
7z e ffmpeg-${{ env.ffmpeg_version }}-full_build.7z ffmpeg.exe -r
5149
52-
- name: Set screen resolution to ${{ matrix.resolution.width }}x${{ matrix.resolution.height }}
53-
uses: any-user/[email protected]
54-
with:
55-
width: ${{ matrix.resolution.width }}
56-
height: ${{ matrix.resolution.height }}
57-
58-
- name: Set display scaling to ${{ matrix.resolution.scale }}%
59-
run: |
60-
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "LogPixels" -Value ([int]($env:SCALE * 96 / 100))
61-
Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "Win8DpiScaling" -Value 1
62-
Rundll32.exe user32.dll, UpdatePerUserSystemParameters
63-
env:
64-
SCALE: ${{ matrix.resolution.scale }}
65-
shell: powershell
50+
# - name: Set display properties (${{ matrix.resolution.width }}x${{ matrix.resolution.height }} @ ${{ matrix.resolution.scale }})
51+
# run: |
52+
# Set-DisplayResolution -Width ${{ matrix.resolution.width }} -Height ${{ matrix.resolution.height }} -Force
53+
# Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "LogPixels" -Value ([int]($env:SCALE * 96 / 100))
54+
# Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "Win8DpiScaling" -Value 1
55+
# Rundll32.exe user32.dll, UpdatePerUserSystemParameters
56+
# env:
57+
# SCALE: ${{ matrix.resolution.scale }}
58+
# shell: powershell
6659

6760
- name: Run DVR-Scan
6861
run: |
@@ -76,13 +69,119 @@ jobs:
7669
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
7770
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
7871
$graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
79-
$bitmap.Save("dvr-scan-screenshot-${{ matrix.resolution.scale }}.png", [System.Drawing.Imaging.ImageFormat]::Png)
72+
$bitmap.Save("dvr-scan-screenshot-windows.png", [System.Drawing.Imaging.ImageFormat]::Png)
8073
$graphics.Dispose()
8174
$bitmap.Dispose()
8275
shell: powershell
8376

8477
- name: Upload Screenshot
8578
uses: actions/upload-artifact@v4
8679
with:
87-
name: dvr-scan-screenshot-${{ matrix.resolution.scale }}
88-
path: dvr-scan-screenshot-${{ matrix.resolution.scale }}.png
80+
name: dvr-scan-screenshot-windows
81+
path: dvr-scan-screenshot-windows.png
82+
83+
screenshot-linux:
84+
runs-on: ubuntu-latest
85+
env:
86+
UV_SYSTEM_PYTHON: 1
87+
strategy:
88+
matrix:
89+
python-version: ["3.12"]
90+
resolution:
91+
- {width: 1920, height: 1080}
92+
- {width: 2560, height: 1440}
93+
- {width: 3840, height: 2160}
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Set up Python ${{ matrix.python-version }}
99+
uses: actions/setup-python@v5
100+
with:
101+
python-version: ${{ matrix.python-version }}
102+
cache: 'pip'
103+
104+
- name: Install uv and set the python version
105+
uses: astral-sh/setup-uv@v4
106+
with:
107+
version: "0.5.11"
108+
python-version: ${{ matrix.python-version }}
109+
110+
- name: Install System Dependencies
111+
run: |
112+
sudo apt-get update
113+
sudo apt-get install -y xvfb scrot
114+
115+
- name: Install Python Dependencies
116+
run: |
117+
uv pip install --upgrade pip build wheel virtualenv setuptools
118+
uv pip install -r requirements.txt
119+
120+
- name: Run UI Test
121+
run: |
122+
# Start Xvfb in the background on display :99
123+
Xvfb :99 -screen 0 ${{ matrix.resolution.width }}x${{ matrix.resolution.height }}x24 &
124+
125+
# Set the DISPLAY environment variable for the following commands
126+
export DISPLAY=:99
127+
128+
# Run the application in the background
129+
python -m dvr_scan.app &
130+
131+
# Wait for the application to launch
132+
sleep 10
133+
134+
# Take a screenshot
135+
scrot -d 0 "dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}.png"
136+
137+
- name: Upload Screenshot
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}
141+
path: "dvr-scan-screenshot-linux-${{ matrix.resolution.width }}x${{ matrix.resolution.height }}.png"
142+
143+
# TODO: Resolution matrix
144+
screenshot-macos:
145+
runs-on: macos-latest
146+
env:
147+
UV_SYSTEM_PYTHON: 1
148+
strategy:
149+
matrix:
150+
python-version: ["3.12"]
151+
152+
steps:
153+
- uses: actions/checkout@v4
154+
155+
- name: Set up Python ${{ matrix.python-version }}
156+
uses: actions/setup-python@v5
157+
with:
158+
python-version: ${{ matrix.python-version }}
159+
cache: 'pip'
160+
161+
- name: Install uv and set the python version
162+
uses: astral-sh/setup-uv@v4
163+
with:
164+
version: "0.5.11"
165+
python-version: ${{ matrix.python-version }}
166+
167+
- name: Install Python Dependencies
168+
run: |
169+
uv pip install --upgrade pip build wheel virtualenv setuptools
170+
uv pip install -r requirements.txt
171+
172+
- name: Run UI Test
173+
run: |
174+
# Run the application in the background
175+
python -m dvr_scan.app &
176+
177+
# Wait for the application to launch
178+
sleep 10
179+
180+
# Take a screenshot
181+
screencapture "dvr-scan-screenshot-macos.png"
182+
183+
- name: Upload Screenshot
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: dvr-scan-screenshot-macos
187+
path: "dvr-scan-screenshot-macos.png"

0 commit comments

Comments
 (0)