Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Integration test (#449)

Adejumo David Adewalecdbd6472d0f9
diff --git a/.github/scripts/audio_test.wav b/.github/scripts/audio_test.wav
new file mode 100644
index 000000000..439add262
Binary files /dev/null and b/.github/scripts/audio_test.wav differ
diff --git a/.github/scripts/check_logs.sh b/.github/scripts/check_logs.sh
new file mode 100755
index 000000000..5fbf57f71
--- /dev/null
+++ b/.github/scripts/check_logs.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+tail -n 100 screenpipe_output.log
+if grep -q "panic" screenpipe_output.log; then
+ echo "CLI crashed"
+ exit 1
+fi
+if ! grep -q "Server starting on 127.0.0.1:3030" screenpipe_output.log; then
+ echo "Server did not start correctly"
+ exit 1
+fi
+if grep -q "No windows found" screenpipe_output.log; then
+ echo "No windows were detected"
+ exit 1
+fi
+if grep -q "tesseract not found" screenpipe_output.log; then
+ echo "Tesseract OCR not found"
+ exit 1
+fi
+echo "CLI ran successfully without crashing"
diff --git a/.github/scripts/install_dependencies.sh b/.github/scripts/install_dependencies.sh
new file mode 100755
index 000000000..c86d7949d
--- /dev/null
+++ b/.github/scripts/install_dependencies.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+sudo apt-get update
+sudo apt-get install -y xvfb ffmpeg libasound2-dev libgtk-3-dev libwebkit2gtk-4.0-dev libavformat-dev libavfilter-dev libavdevice-dev x11-utils x11-apps xdotool openbox xterm fonts-liberation tesseract-ocr libtesseract-dev imagemagick fonts-dejavu alsa-utils pulseaudio pulseaudio-utils
diff --git a/.github/scripts/run_screenpipe.sh b/.github/scripts/run_screenpipe.sh
new file mode 100755
index 000000000..2e065b64c
--- /dev/null
+++ b/.github/scripts/run_screenpipe.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+export XDG_RUNTIME_DIR=/run/user/$(id -u)
+export PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native
+./target/release/screenpipe --debug > screenpipe_output.log 2>&1 &
+SCREENPIPE_PID=$!
+echo $SCREENPIPE_PID > screenpipe.pid
+sleep 60
diff --git a/.github/scripts/setup_audio.sh b/.github/scripts/setup_audio.sh
new file mode 100755
index 000000000..94d7f095e
--- /dev/null
+++ b/.github/scripts/setup_audio.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+pulseaudio --kill || true
+sleep 2
+pulseaudio --start --log-target=syslog --system=false --disallow-exit --exit-idle-time=-1 --daemon
+pulseaudio --check
+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
+echo "defaults.pcm.card 0" > ~/.asoundrc
+echo "defaults.ctl.card 0" >> ~/.asoundrc
+pactl list short sinks
+pactl list short sources
+pactl info
diff --git a/.github/scripts/setup_display.sh b/.github/scripts/setup_display.sh
new file mode 100755
index 000000000..59fad9ceb
--- /dev/null
+++ b/.github/scripts/setup_display.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+Xvfb :99 -ac -screen 0 1280x1024x24 &
+echo "DISPLAY=:99" >> $GITHUB_ENV
+sleep 3
+export DISPLAY=:99
+mkdir -p ~/.config/openbox
+echo '<openbox_config><menu><file>menu.xml</file></menu></openbox_config>' > ~/.config/openbox/rc.xml
+openbox --config-file ~/.config/openbox/rc.xml &
+sleep 3
+xterm -fa 'Liberation Mono' -fs 10 -e "while true; do echo 'Keeping xterm open'; sleep 60; done" &
+sleep 3
+xdpyinfo || echo "xdpyinfo failed"
+xrandr || echo "xrandr failed"
+xwininfo -root -children || echo "xwininfo failed"
diff --git a/.github/scripts/stop_screenpipe.sh b/.github/scripts/stop_screenpipe.sh
new file mode 100755
index 000000000..cd49d52e5
--- /dev/null
+++ b/.github/scripts/stop_screenpipe.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+kill $(cat screenpipe.pid)
+sleep 5
diff --git a/.github/scripts/test_audio_capture.sh b/.github/scripts/test_audio_capture.sh
new file mode 100755
index 000000000..76f1b7602
--- /dev/null
+++ b/.github/scripts/test_audio_capture.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+ls -l .github/scripts/audio_test.wav
+pulseaudio --check
+ps aux | grep pulseaudio
+ls -l /run/user/$(id -u)/pulse/
+PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native paplay --verbose .github/scripts/audio_test.wav
+sleep 30
+cat screenpipe_output.log
+if grep -qi "human world" screenpipe_output.log; then
+ echo "Audio capture test passed: 'human world' found in logs"
+elif grep -qi "audio" screenpipe_output.log; then
+ echo "Audio capture test partially passed: Audio-related output found"
+else
+ echo "Audio capture test failed"
+ tail -n 100 screenpipe_output.log
+ exit 1
+fi
diff --git a/.github/scripts/test_ocr.sh b/.github/scripts/test_ocr.sh
new file mode 100755
index 000000000..9e7498441
--- /dev/null
+++ b/.github/scripts/test_ocr.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+convert -size 300x100 xc:white -font DejaVu-Sans -pointsize 24 -fill black -draw "text 10,50 'Hello, Screenpipe OCR'" test_image.png
+DISPLAY=:99 display test_image.png &
+DISPLAY_PID=$!
+sleep 30
+kill $DISPLAY_PID
+if grep -qi "Hello, Screenpipe OCR" screenpipe_output.log; then
+ echo "OCR test passed: Text was recognized"
+else
+ echo "OCR test failed: Text was not recognized"
+ echo "Last 100 lines of log:"
+ tail -n 100 screenpipe_output.log
+ exit 1
+fi
diff --git a/.github/scripts/verify_tesseract.sh b/.github/scripts/verify_tesseract.sh
new file mode 100755
index 000000000..dea543572
--- /dev/null
+++ b/.github/scripts/verify_tesseract.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+tesseract --version
+ldconfig -p | grep tesseract
+ls -l /usr/lib/x86_64-linux-gnu/libtesseract*
diff --git a/.github/workflows/linux-integration-test.yml b/.github/workflows/linux-integration-test.yml
new file mode 100644
index 000000000..022e4007e
--- /dev/null
+++ b/.github/workflows/linux-integration-test.yml
@@ -0,0 +1,72 @@
+name: Linux Integration Test
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ test-linux:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set up Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+
+ - name: Install dependencies
+ run: .github/scripts/install_dependencies.sh
+
+ - name: Verify Tesseract installation
+ run: .github/scripts/verify_tesseract.sh
+
+ - name: Build CLI
+ run: cargo build --release
+
+ - name: Set up virtual display with window manager
+ run: .github/scripts/setup_display.sh
+
+ - name: Setup audio
+ run: .github/scripts/setup_audio.sh
+
+ - name: Run Screenpipe
+ run: .github/scripts/run_screenpipe.sh
+
+ - name: Test OCR
+ run: .github/scripts/test_ocr.sh
+
+ - name: Test Audio Capture
+ run: .github/scripts/test_audio_capture.sh
+
+ - name: Stop screenpipe
+ run: .github/scripts/stop_screenpipe.sh
+
+ - name: Check for crashes and expected behavior
+ run: .github/scripts/check_logs.sh
+
+ - name: Upload logs
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: screenpipe-logs
+ path: screenpipe_output.log
+
+ - name: Upload captured data
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: screenpipe-data
+ path: |
+ ~/.screenpipe/data/
+
+ - name: Upload test image
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: test-image
+ path: test_image.png
diff --git a/.github/workflows/windows-integration-test.yml b/.github/workflows/windows-integration-test.yml
new file mode 100644
index 000000000..803d54ac5
--- /dev/null
+++ b/.github/workflows/windows-integration-test.yml
@@ -0,0 +1,109 @@
+name: Windows CLI Integration Test
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ test-windows:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Set up Rust
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+
+ - name: Install dependencies
+ shell: pwsh
+ run: |
+ choco install ffmpeg openssl
+ echo "C:\ProgramData\chocolatey\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
+
+ - name: Install Scream on Windows
+ shell: powershell
+ run: |
+ Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/4.0/Scream4.0.zip -OutFile Scream4.0.zip
+ Expand-Archive -Path Scream4.0.zip -DestinationPath Scream
+ openssl req -batch -verbose -x509 -newkey rsa -keyout ScreamCertificate.pvk -out ScreamCertificate.cer -nodes -extensions v3_req
+ openssl pkcs12 -export -nodes -in ScreamCertificate.cer -inkey ScreamCertificate.pvk -out ScreamCertificate.pfx -passout pass:
+
+ - name: Setup MSVC Dev Cmd
+ uses: ilammy/msvc-dev-cmd@v1
+
+ - name: Sign and Install Scream Driver on Windows
+ shell: powershell
+ run: |
+ signtool sign /v /fd SHA256 /f ScreamCertificate.pfx Scream\Install\driver\x64\Scream.cat
+ Import-Certificate -FilePath ScreamCertificate.cer -CertStoreLocation Cert:\LocalMachine\root
+ Import-Certificate -FilePath ScreamCertificate.cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
+ Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
+ timeout-minutes: 5
+
+ - name: Start Windows Audio Service
+ shell: powershell
+ run: net start audiosrv
+
+ - name: Build CLI
+ run: cargo build --release
+
+ - name: Run CLI and generate activity
+ shell: pwsh
+ run: |
+ $env:RUST_LOG = "debug"
+ $process = Start-Process -FilePath ".\target\release\screenpipe.exe" -ArgumentList "--debug" -PassThru -RedirectStandardOutput "screenpipe_output.log" -RedirectStandardError "screenpipe_error.log" -NoNewWindow
+ Start-Sleep -Seconds 10
+
+ # Generate some screen activity
+ for ($i = 0; $i -lt 5; $i++) {
+ Start-Process "notepad.exe"
+ Start-Sleep -Seconds 2
+ Stop-Process -Name "notepad" -Force
+ Start-Sleep -Seconds 2
+ }
+
+ # Generate some audio using PowerShell
+ [console]::beep(2000,1000)
+
+ Start-Sleep -Seconds 30 # Allow more time for processing
+ Stop-Process -Id $process.Id -Force
+
+ - name: Check for crashes and captured data
+ shell: pwsh
+ run: |
+ if (Select-String -Path "screenpipe_output.log" -Pattern "panic" -Quiet) {
+ Write-Host "CLI crashed"
+ Get-Content "screenpipe_output.log"
+ exit 1
+ }
+ Write-Host "CLI ran successfully without crashing"
+
+ $capturedFiles = Get-ChildItem -Path "$env:USERPROFILE\.screenpipe\data" -Recurse
+ if ($capturedFiles.Count -eq 0) {
+ Write-Host "No data was captured"
+ exit 1
+ }
+ Write-Host "Data captured successfully. File count: $($capturedFiles.Count)"
+
+ if (Select-String -Path "screenpipe_error.log" -Pattern "no audio devices available" -Quiet) {
+ Write-Host "Audio device setup failed"
+ exit 1
+ }
+
+ Get-Content "screenpipe_output.log" -Tail 100
+ Get-Content "screenpipe_error.log"
+
+ - name: Upload logs and data
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: windows-logs-and-data
+ path: |
+ screenpipe_output.log
+ screenpipe_error.log
+ ${{ env.USERPROFILE }}\.screenpipe\data\