Skip to content

Add SSH device support using paramiko #22

Add SSH device support using paramiko

Add SSH device support using paramiko #22

Workflow file for this run

name: OVMobileBench CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
device_serial:
description: 'Android device serial'
required: false
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run Black
run: black --check ovmobilebench tests
- name: Run Ruff
run: ruff check ovmobilebench tests
- name: Run MyPy
run: mypy ovmobilebench --ignore-missing-imports
- name: Run tests
run: pytest tests/ -v --cov=ovmobilebench --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false
build-package:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install build dependencies
run: |
pip install --upgrade pip
pip install build setuptools wheel
- name: Build package
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 7
dry-run:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Validate example config
run: |
python -c "from ovmobilebench.config.loader import load_experiment; load_experiment('experiments/android_example.yaml')"
- name: CLI help test
run: |
ovmobilebench --help
ovmobilebench build --help
ovmobilebench run --help
# Optional: Run on a self-hosted runner with a real device
device-test-adb:
if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[device-test-adb]')
needs: build-package
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Check ADB devices
run: adb devices
- name: Run minimal benchmark
env:
DEVICE_SERIAL: ${{ github.event.inputs.device_serial || 'emulator-5554' }}
run: |
ovmobilebench list-devices
# Uncomment when ready:
# ovmobilebench all -c experiments/android_example.yaml --dry-run
- name: Upload results
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results-adb
path: experiments/results/
retention-days: 30
# Test SSH connection to localhost
device-test-ssh:
if: github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[device-test-ssh]')
needs: build-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Set up SSH server
run: |
# Install SSH server if not present
sudo apt-get update
sudo apt-get install -y openssh-server
# Configure SSH for passwordless localhost access
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa || true
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# Configure SSH client
cat > ~/.ssh/config << EOF
Host localhost
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF
chmod 600 ~/.ssh/config
# Start SSH service
sudo service ssh start
# Test connection
ssh -o ConnectTimeout=5 localhost "echo 'SSH connection successful'"
- name: List SSH devices
run: |
ovmobilebench list-ssh-devices || echo "Command not yet implemented"
- name: Test SSH deployment
run: |
# Create test file
echo "test content" > /tmp/test_file.txt
# Test using Python
python << 'EOF'
from ovmobilebench.devices.linux_ssh import LinuxSSHDevice
import os
from pathlib import Path
# Connect to localhost
device = LinuxSSHDevice(
host="localhost",
username=os.environ["USER"],
key_filename="~/.ssh/id_rsa",
push_dir="/tmp/ovmobilebench_test"
)
# Test operations
print(f"Device available: {device.is_available()}")
print(f"Device info: {device.info()}")
# Test push
device.push(Path("/tmp/test_file.txt"), "/tmp/ovmobilebench_test/test.txt")
# Test shell command
ret, out, err = device.shell("cat /tmp/ovmobilebench_test/test.txt")
print(f"File content: {out.strip()}")
# Test exists
print(f"File exists: {device.exists('/tmp/ovmobilebench_test/test.txt')}")
# Cleanup
device.rm("/tmp/ovmobilebench_test", recursive=True)
EOF
- name: Run benchmark dry-run via SSH
run: |
# Create minimal config for SSH
cat > experiments/ssh_localhost.yaml << 'EOF'
project:
name: "ssh-test"
run_id: "ci-test"
device:
type: "linux_ssh"
host: "localhost"
username: "${USER}"
key_filename: "~/.ssh/id_rsa"
push_dir: "/tmp/ovmobilebench"
models:
- name: "dummy"
path: "/tmp/dummy_model.xml"
run:
repeats: 1
matrix:
niter: [10]
report:
sinks:
- type: "csv"
path: "experiments/results/ssh_test.csv"
EOF
# Run in dry-run mode
ovmobilebench all -c experiments/ssh_localhost.yaml --dry-run || true
- name: Upload SSH test results
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results-ssh
path: experiments/results/
retention-days: 30