Skip to content
Merged
158 changes: 9 additions & 149 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,107 +12,19 @@ on:
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
ci-matrix:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # , windows-latest]
uses: ./.github/workflows/reusable-ci.yml
with:
os: ${{ matrix.os }}
device_serial: ${{ github.event.inputs.device_serial || 'emulator-5554' }}

# 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
- dry-run
needs: ci-matrix
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -146,55 +58,3 @@ jobs:
name: benchmark-results-adb
path: experiments/results/
retention-days: 30

# Test SSH connection to localhost
device-test-ssh:
needs:
- build-package
- dry-run
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: |
# Generate and run SSH setup script
python scripts/generate_ssh_config.py --type setup
bash scripts/setup_ssh_ci.sh

- name: List SSH devices
run: |
ovmobilebench list-ssh-devices || echo "Command not yet implemented"

- name: Test SSH deployment
run: |
# Generate and run SSH test script
python scripts/generate_ssh_config.py --type test
python scripts/test_ssh_device_ci.py

- name: Run benchmark dry-run via SSH
run: |
# Generate SSH config using Python script
python scripts/generate_ssh_config.py --type config

# Run in dry-run mode
ovmobilebench all -c experiments/ssh_localhost_ci.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
159 changes: 159 additions & 0 deletions .github/workflows/reusable-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Reusable CI Workflow

on:
workflow_call:
inputs:
os:
required: true
type: string
device_serial:
required: false
type: string

jobs:
lint-and-test:
runs-on: ${{ inputs.os }}
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: ${{ inputs.os }}
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-${{ inputs.os }}
path: dist/
retention-days: 7

dry-run:
needs: lint-and-test
runs-on: ${{ inputs.os }}
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

device-test-ssh:
if: inputs.os == 'ubuntu-latest' # SSH tests only on Ubuntu for now
needs:
- build-package
- dry-run
runs-on: ${{ inputs.os }}
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: |
# Generate and run SSH setup script
python scripts/generate_ssh_config.py --type setup
bash scripts/setup_ssh_ci.sh || echo "SSH setup had warnings, continuing..."

- name: List SSH devices
run: |
ovmobilebench list-ssh-devices || echo "Command not yet implemented"

- name: Test SSH deployment
run: |
# Generate and run SSH test script
python scripts/generate_ssh_config.py --type test
python scripts/test_ssh_device_ci.py

- name: Run benchmark dry-run via SSH
run: |
# Generate SSH config using Python script
python scripts/generate_ssh_config.py --type config

# Run in dry-run mode
ovmobilebench all -c experiments/ssh_localhost_ci.yaml --dry-run || true

- name: Upload SSH test results
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-results-ssh-${{ inputs.os }}
path: experiments/results/
retention-days: 30
Loading
Loading