forked from mediar-ai/screenpipe
-
Notifications
You must be signed in to change notification settings - Fork 0
358 lines (304 loc) · 12.3 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# testing locally with act cli
# act -W .github/workflows/ci.yml --container-architecture linux/amd64 -env ACTIONS_RUNTIME_URL=http://host.docker.internal:8080/ --env ACTIONS_RUNTIME_TOKEN=foo --env ACTIONS_CACHE_URL=http://host.docker.internal:8080/ --artifact-server-path out -j build-ubuntu -P ubuntu-latest=-self-hosted --env-file .env --secret-file .secrets
name: Rust CI
on:
push:
pull_request:
jobs:
test-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y tesseract-ocr libtesseract-dev libavformat-dev libavfilter-dev libavdevice-dev ffmpeg libasound2-dev libgtk-3-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev
sudo apt-get install -y libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev
- name: Copy test image
run: |
mkdir -p target/debug/deps
cp screenpipe-vision/tests/testing_OCR.png target/debug/deps/
- name: Run tests
run: cargo test
test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~\AppData\Local\cargo\
target\
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: setup Bun
uses: oven-sh/setup-bun@v1
- name: Run pre_build.js on
shell: bash
run: bun ./scripts/pre_build.js
working-directory: ./examples/apps/screenpipe-app-tauri
# - name: Run tests
# run: cargo test
- name: Copy test image
shell: bash
run: |
mkdir -p target/debug/deps || true
cp screenpipe-vision/tests/testing_OCR.png target/debug/deps/
- name: Run specific Windows OCR test
run: cargo test test_process_ocr_task_windows
test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~\AppData\Local\cargo\
target\
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: setup Bun
uses: oven-sh/setup-bun@v1
- name: Run pre_build.js on
shell: bash
env:
SKIP_SCREENPIPE_SETUP: true # avoid trying to copy screenpipe binaries, not yet built (next step)
run: bun ./scripts/pre_build.js
working-directory: ./examples/apps/screenpipe-app-tauri
- name: Copy test image
shell: bash
run: |
mkdir -p target/debug/deps || true
cp screenpipe-vision/tests/testing_OCR.png target/debug/deps/
- name: Run specific Apple OCR test
shell: bash
env:
DYLD_LIBRARY_PATH: /Users/runner/work/screenpipe/screenpipe/screenpipe-vision/lib
run: cargo test test_apple_native_ocr
build-cli:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev libgtk-3-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev ffmpeg
sudo apt-get install -y libavutil-dev libavformat-dev libavfilter-dev libavdevice-dev
sudo apt-get install -y pkg-config xvfb pulseaudio xdotool x11-xserver-utils sox
sudo apt-get install -y libx11-dev libxcb1-dev
sudo apt-get install -y scrot
sudo apt-get install -y libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev
sudo apt-get install -y xterm openbox alsa-utils
- name: Build CLI
run: cargo build --release --bin screenpipe
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
RUSTFLAGS: "-C target-cpu=native"
- uses: actions/upload-artifact@v3
with:
name: screenpipe-${{ matrix.os }}
path: target/release/screenpipe*
test-cli:
needs: build-cli
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 90 # Increased timeout
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: screenpipe-${{ matrix.os }}
path: .
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y xvfb pulseaudio ffmpeg imagemagick xdotool x11-xserver-utils xterm openbox alsa-utils sox tesseract-ocr libtesseract-dev
- name: Setup display and window manager (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
# Start Xvfb
Xvfb :99 -ac -screen 0 1024x768x24 &
export DISPLAY=:99
echo "DISPLAY=:99" >> $GITHUB_ENV
sleep 5
# Start window manager
openbox &
sleep 5
# Start a visible application
xterm -e "echo 'Test Window'; while true; do date; sleep 1; done" &
sleep 5
- name: Setup audio (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
# Setup audio
pulseaudio --start
sleep 2
pactl load-module module-null-sink sink_name=virtual_speaker
pactl set-default-sink virtual_speaker
pactl load-module module-virtual-source source_name=virtual_mic master=virtual_speaker.monitor
pactl set-default-source virtual_mic
sleep 5
- name: Debug information (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
echo "Window list:"
xwininfo -root -tree
echo "Display info:"
xdpyinfo | head -n 20
echo "Audio devices:"
pactl list short sinks
pactl list short sources
- name: Start simulations (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
# Start screen and audio simulation
chmod +x ./scripts/simulate_screen_activity.sh
chmod +x ./scripts/simulate_audio_activity.sh
./scripts/simulate_screen_activity.sh &
./scripts/simulate_audio_activity.sh &
- name: Run screenpipe and health checks (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
# Run screenpipe
chmod +x ./screenpipe
mkdir -p ./test_data/logs
RUST_LOG=debug,screenpipe=trace RUST_BACKTRACE=1 ./screenpipe --data-dir ./test_data --fps 1 > ./test_data/logs/screenpipe.log 2>&1 &
CLI_PID=$!
echo "Screenpipe PID: $CLI_PID"
# Wait longer for initialization
sleep 30
# Check if screenpipe is still running
if ! ps -p $CLI_PID > /dev/null; then
echo "Screenpipe process has died"
cat ./test_data/logs/screenpipe.log
exit 1
fi
# Health checks
for i in {1..30}; do
response=$(curl -s http://localhost:3030/health)
echo "Health check $i: $response"
status=$(echo $response | jq -r '.status')
frame_status=$(echo $response | jq -r '.frame_status')
audio_status=$(echo $response | jq -r '.audio_status')
if [[ "$status" == "Healthy" && "$frame_status" == "OK" && "$audio_status" == "OK" ]]; then
echo "Health check passed"
exit 0
fi
# Check if screenpipe is still running
if ! ps -p $CLI_PID > /dev/null; then
echo "Screenpipe process has died during health checks"
break
fi
sleep 10
done
echo "Health check failed after 5 minutes"
echo "Screenpipe log:"
cat ./test_data/logs/screenpipe.log
echo "Xvfb log:"
cat /tmp/.X99-lock
echo "Process list:"
ps aux | grep -E 'Xvfb|pulseaudio|openbox|xterm|screenpipe'
echo "Audio devices:"
pactl list short sinks
pactl list short sources
echo "Network connections:"
netstat -tuln | grep 3030
exit 1
- name: Setup and run CLI (Windows)
if: matrix.os == 'windows-latest'
run: |
# Install FFmpeg
choco install ffmpeg -y
$env:Path += ";C:\ProgramData\chocolatey\bin"
# Set up environment
$env:RUST_LOG = "debug"
$env:RUST_BACKTRACE = "1"
New-Item -ItemType Directory -Force -Path .\test_data\logs
# Start screenpipe and capture its process ID
$screenpipeProcess = Start-Process -FilePath .\screenpipe.exe -ArgumentList "--data-dir", ".\test_data", "--fps", "1" -NoNewWindow -PassThru -RedirectStandardOutput .\test_data\logs\screenpipe.log -RedirectStandardError .\test_data\logs\screenpipe_error.log
$screenpipePID = $screenpipeProcess.Id
Write-Output "Screenpipe started with PID: $screenpipePID"
# Wait for screenpipe to start
Start-Sleep -Seconds 20
# Check if screenpipe is still running
$runningProcess = Get-Process -Id $screenpipePID -ErrorAction SilentlyContinue
if ($null -eq $runningProcess) {
Write-Error "Screenpipe process has exited unexpectedly"
Get-Content .\test_data\logs\screenpipe.log
Get-Content .\test_data\logs\screenpipe_error.log
exit 1
}
# Start screen and audio simulation
Start-Process -FilePath powershell -ArgumentList "-File", ".\scripts\simulate_screen_activity.ps1" -NoNewWindow
Start-Process -FilePath powershell -ArgumentList "-File", ".\scripts\simulate_audio_activity.ps1" -NoNewWindow
# Health checks
$attempts = 30
$interval = 10
for ($i = 0; $i -lt $attempts; $i++) {
Start-Sleep -Seconds $interval
# Check if screenpipe is still running
$runningProcess = Get-Process -Id $screenpipePID -ErrorAction SilentlyContinue
if ($null -eq $runningProcess) {
Write-Error "Screenpipe process has exited unexpectedly during health checks"
Get-Content .\test_data\logs\screenpipe.log
Get-Content .\test_data\logs\screenpipe_error.log
exit 1
}
try {
$response = Invoke-RestMethod -Uri http://localhost:3030/health -ErrorAction Stop
Write-Output "Health check $($i+1): $($response | ConvertTo-Json -Compress)"
if ($response.status -eq "Healthy" -and $response.frame_status -eq "OK" -and $response.audio_status -eq "OK") {
Write-Output "Health check passed"
exit 0
}
} catch {
Write-Output "Error occurred while checking health: $_"
}
}
Write-Error "Health check failed after 5 minutes"
Get-Content .\test_data\logs\screenpipe.log
Get-Content .\test_data\logs\screenpipe_error.log
Write-Output "Process list:"
Get-Process | Where-Object { $_.Name -match 'screenpipe|ffmpeg' } | Format-Table -AutoSize
Write-Output "Network connections:"
netstat -ano | Select-String "3030"
exit 1