Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/actions/setup-python-cached/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: 'Setup Python with Cached Dependencies'
description: 'Setup Python and cache entire site-packages directory'

inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.11'

runs:
using: 'composite'
steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Get Python paths
id: python-paths
shell: bash
run: |
# Get Python paths using Python
python << 'EOF'
import os
import sys
import site
import subprocess

# Get site-packages path
site_packages = site.getsitepackages()[0]

# Get pip cache dir
pip_cache = subprocess.check_output([sys.executable, "-m", "pip", "cache", "dir"]).decode().strip()

# Output for GitHub Actions
output_file = os.environ.get('GITHUB_OUTPUT', '')
if output_file:
with open(output_file, 'a') as f:
f.write(f"site-packages={site_packages}\n")
f.write(f"pip-cache={pip_cache}\n")
f.write(f"python-version={sys.version}\n")
EOF

- name: Cache Python environment
uses: actions/cache@v3
id: python-cache
with:
path: |
${{ steps.python-paths.outputs.site-packages }}
${{ steps.python-paths.outputs.pip-cache }}
~/.local/bin
~/.local/lib
~/Library/Python
/opt/hostedtoolcache/Python/*/x64/bin
/opt/hostedtoolcache/Python/*/x64/lib/python*/site-packages
key: ${{ runner.os }}-py${{ inputs.python-version }}-${{ hashFiles('requirements.txt', 'pyproject.toml') }}-v2
restore-keys: |
${{ runner.os }}-py${{ inputs.python-version }}-

- name: Install dependencies
shell: bash
run: |
echo "Cache hit: ${{ steps.python-cache.outputs.cache-hit }}"
echo "Python version: ${{ steps.python-paths.outputs.python-version }}"
echo "Site packages: ${{ steps.python-paths.outputs.site-packages }}"

# Always ensure pip is up to date
pip install --upgrade pip

if [[ "${{ steps.python-cache.outputs.cache-hit }}" != "true" ]]; then
echo "Cache miss - installing all dependencies"
pip install -r requirements.txt
pip install -e .
else
echo "Cache hit - verifying and reinstalling if needed"
# Check if black is available
if ! command -v black &> /dev/null; then
echo "Tools not in PATH, reinstalling..."
pip install -r requirements.txt
fi
# Always reinstall the local package in case code changed
pip install -e . --no-deps --force-reinstall
fi

# Ensure tools are in PATH
export PATH="$HOME/.local/bin:$PATH"
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV

- name: Verify installation
shell: bash
run: |
echo "=== Installed packages ==="
pip list 2>/dev/null | head -20 || true
echo "..."
echo "=== Package location ==="
python -c "import ovmobilebench; print(f'Package installed at: {ovmobilebench.__file__}')" || echo "Package not found"
echo "=== CLI availability ==="
which ovmobilebench || echo "CLI not in PATH"
3 changes: 2 additions & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # , windows-latest]
uses: ./.github/workflows/reusable-ci.yml
uses: ./.github/workflows/ci-orchestrator.yml
with:
os: ${{ matrix.os }}
device_serial: ${{ github.event.inputs.device_serial || 'emulator-5554' }}
secrets: inherit
45 changes: 45 additions & 0 deletions .github/workflows/ci-orchestrator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI Orchestrator

on:
workflow_call:
inputs:
os:
required: true
type: string
device_serial:
required: false
type: string
default: 'emulator-5554'

jobs:
# Stage 1: Lint and Test
lint-test:
uses: ./.github/workflows/stage-lint-test.yml
with:
os: ${{ inputs.os }}
secrets: inherit

# Stage 2: Build Package (runs in parallel with validation)
build:
needs: lint-test
uses: ./.github/workflows/stage-build.yml
with:
os: ${{ inputs.os }}
secrets: inherit

# Stage 3: Validation (runs in parallel with build)
validation:
needs: lint-test
uses: ./.github/workflows/stage-validation.yml
with:
os: ${{ inputs.os }}
secrets: inherit

# Stage 4: Device Tests (runs after build and validation)
device-tests:
needs: [build, validation]
uses: ./.github/workflows/stage-device-tests.yml
with:
os: ${{ inputs.os }}
device_serial: ${{ inputs.device_serial }}
secrets: inherit
204 changes: 0 additions & 204 deletions .github/workflows/reusable-ci.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Package

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

jobs:
build-package:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4

- name: Setup Python with cached dependencies
uses: ./.github/actions/setup-python-cached

- 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
Loading
Loading