Merge branch 'mediar-ai:main' into test-cli-ci #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
test-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 | |
- name: Build CLI | |
run: cargo build --release --bin screenpipe | |
- name: Set up virtual display and audio (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 | |
Xvfb :99 -ac -screen 0 1024x768 & | |
export DISPLAY=:99 | |
echo "DISPLAY=:99" >> $GITHUB_ENV | |
sleep 2 | |
openbox & | |
sleep 2 | |
pulseaudio --start | |
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 2 | |
xwininfo -root -tree || true | |
chmod +x ./scripts/launch_test_window.sh | |
./scripts/launch_test_window.sh & | |
- name: Simulate screen and audio activity (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
chmod +x ./scripts/simulate_screen_activity.sh | |
chmod +x ./scripts/simulate_audio_activity.sh | |
DISPLAY=:99 ./scripts/simulate_screen_activity.sh & | |
./scripts/simulate_audio_activity.sh & | |
- name: Run CLI and check health (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
export DISPLAY=:99 | |
echo "DISPLAY=$DISPLAY" | |
xdpyinfo || true | |
DISPLAY=:99 RUST_LOG=debug ./target/release/screenpipe --data-dir ./test_data --fps 1 > screenpipe_output.log 2>&1 & | |
cat screenpipe_output.log | |
for i in {1..24}; do | |
sleep 10 | |
response=$(curl -s http://localhost:3030/health) | |
echo "$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 | |
# Debug information | |
echo "Iteration $i: Current window list" | |
DISPLAY=:99 xwininfo -root -children | |
echo "Current processes:" | |
ps aux | grep -E 'Xvfb|xterm|screenpipe|simulate|openbox' | |
echo "Screenshot exists:" | |
ls -l /tmp/screenshot.png | |
echo "Screenshot content:" | |
file /tmp/screenshot.png | |
echo "X11 environment variables:" | |
env | grep -E 'DISPLAY|XAUTHORITY' | |
echo "X11 server check:" | |
xdpyinfo | head -n 5 | |
echo "Audio devices:" | |
aplay -l | |
echo "PulseAudio status:" | |
pactl info | |
echo "Screenpipe log tail:" | |
tail -n 50 ./test_data/logs/screenpipe.log | |
done | |
echo "Health check failed after 4 minutes" | |
echo "Xvfb log:" | |
cat /var/log/Xvfb.0.log | |
echo "screenpipe log:" | |
cat ./test_data/logs/screenpipe.log | |
exit 1 | |
- name: Run CLI and check health (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
Start-Process -FilePath .\target\release\screenpipe.exe -ArgumentList "--data-dir", ".\test_data" -NoNewWindow | |
Start-Process -FilePath powershell -ArgumentList "-File", ".\scripts\simulate_screen_activity.ps1" -NoNewWindow | |
Start-Process -FilePath powershell -ArgumentList "-File", ".\scripts\simulate_audio_activity.ps1" -NoNewWindow | |
$attempts = 24 | |
$interval = 10 | |
for ($i = 0; $i -lt $attempts; $i++) { | |
Start-Sleep -Seconds $interval | |
try { | |
$response = Invoke-RestMethod -Uri http://localhost:3030/health | |
$response | ConvertTo-Json | |
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-Output "Current processes:" | |
Get-Process | Where-Object { $_.Name -match 'screenpipe|powershell' } | Format-Table -AutoSize | |
} | |
Write-Error "Health check failed after 4 minutes" | |
Get-Content .\test_data\logs\screenpipe.log | |
exit 1 |