Files
computer/.github/workflows/python-tests.yml
Elshoubky M 451c9c2c01 Add test infrastructure with CI/CD
- Add separate test directories for all 7 packages (core, agent, computer, computer-server, mcp-server, pylume, som)
- Create 30+ unit tests with mocks for external dependencies (liteLLM, PostHog, Computer)
- Add conftest.py fixtures for each package to enable isolated testing
- Implement GitHub Actions CI workflow with matrix strategy to test each package independently
- Add TESTING.md with comprehensive testing guide and architecture documentation
- Follow SOLID principles: SRP, Vertical Slice Architecture, and Testability as Design Signal

Note:
- No API keys required for unit tests
2025-10-21 18:58:40 -04:00

94 lines
2.4 KiB
YAML

name: Python Unit Tests
on:
pull_request:
paths:
- 'libs/python/**'
- '.github/workflows/python-tests.yml'
push:
branches:
- main
paths:
- 'libs/python/**'
- '.github/workflows/python-tests.yml'
workflow_dispatch: # Allow manual trigger
jobs:
test:
name: Test ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
fail-fast: false # Test all packages even if one fails
matrix:
package:
- core
- agent
- computer
- computer-server
- mcp-server
- pylume
- som
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
run: |
pip install uv
- name: Install package and dependencies
run: |
cd libs/python/${{ matrix.package }}
# Install the package in editable mode with dev dependencies
if [ -f pyproject.toml ]; then
uv pip install --system -e .
# Install test dependencies
uv pip install --system pytest pytest-asyncio pytest-mock pytest-cov
fi
shell: bash
- name: Run tests
run: |
cd libs/python/${{ matrix.package }}
if [ -d tests ]; then
python -m pytest tests/ -v --tb=short --cov --cov-report=term --cov-report=xml
else
echo "No tests directory found, skipping tests"
fi
shell: bash
env:
CUA_TELEMETRY_DISABLED: "1" # Disable telemetry during tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: always()
with:
file: ./libs/python/${{ matrix.package }}/coverage.xml
flags: ${{ matrix.package }}
name: codecov-${{ matrix.package }}
fail_ci_if_error: false
continue-on-error: true
summary:
name: Test Summary
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test.result }}" == "failure" ]; then
echo "❌ Some tests failed. Please check the logs above."
exit 1
else
echo "✅ All tests passed!"
fi