name: Tests on: push: branches: - main - develop paths: - "src/**" - "tests/**" - "requirements.txt" - "pyproject.toml" - ".github/workflows/tests.yml" pull_request: branches: - main - develop paths: - "src/**" - "tests/**" - "requirements.txt" - "pyproject.toml" jobs: # ============================================ # Import Check - Quick validation across Python versions # ============================================ import-check: name: Import Check (Python ${{ matrix.python-version }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Cache pip packages uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.python-version }}- - name: Install minimal dependencies for import check run: | python -m pip install --upgrade pip pip install \ python-dotenv>=1.0.0 \ PyYAML>=6.0 \ tiktoken>=0.5.0 \ jinja2>=3.1.0 \ requests>=2.32.2 \ openai>=1.30.0 \ aiohttp>=3.9.4 \ httpx>=0.27.0 \ nest_asyncio>=1.5.8 \ tenacity>=8.0.0 \ pydantic>=2.0.0 \ numpy>=1.24.0,\<2.0.0 - name: Check module imports run: | echo "๐Ÿ Testing with Python ${{ matrix.python-version }}" # Core service imports (no heavy RAG dependencies) python -c "from src.services.llm.config import get_llm_config; print('โœ… LLM config imports OK')" python -c "from src.services.llm.factory import complete, stream; print('โœ… LLM factory imports OK')" python -c "from src.services.llm.utils import sanitize_url; print('โœ… LLM utils imports OK')" python -c "from src.services.config.loader import load_config_with_main; print('โœ… Config loader imports OK')" python -c "from src.services.config.unified_config import UnifiedConfigManager; print('โœ… Unified config imports OK')" python -c "from src.logging import get_logger; print('โœ… Logging imports OK')" python -c "from src.services.prompt.manager import PromptManager; print('โœ… Prompt manager imports OK')" env: PYTHONPATH: ${{ github.workspace }} # ============================================ # Unit Tests - Run pytest across Python versions # ============================================ unit-tests: name: Unit Tests (Python ${{ matrix.python-version }}) runs-on: ubuntu-latest needs: import-check strategy: fail-fast: false matrix: python-version: ["3.10", "3.11", "3.12"] steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Cache pip packages uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} restore-keys: | ${{ runner.os }}-pip-${{ matrix.python-version }}- - name: Install test dependencies run: | python -m pip install --upgrade pip pip install pytest pytest-asyncio pytest-cov pip install \ python-dotenv>=1.0.0 \ PyYAML>=6.0 \ tiktoken>=0.5.0 \ jinja2>=3.1.0 \ requests>=2.32.2 \ openai>=1.30.0 \ aiohttp>=3.9.4 \ httpx>=0.27.0 \ nest_asyncio>=1.5.8 \ tenacity>=8.0.0 \ pydantic>=2.0.0 \ numpy>=1.24.0,\<2.0.0 - name: Run unit tests run: | echo "๐Ÿงช Running tests with Python ${{ matrix.python-version }}" pytest tests/ -v --tb=short env: PYTHONPATH: ${{ github.workspace }} # ============================================ # Test Summary # ============================================ test-summary: name: Test Summary runs-on: ubuntu-latest needs: [import-check, unit-tests] if: always() steps: - name: Check test results run: | echo "## ๐Ÿงช Test Results Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "| Python Version | Import Check | Unit Tests |" >> $GITHUB_STEP_SUMMARY echo "|----------------|--------------|------------|" >> $GITHUB_STEP_SUMMARY echo "| 3.10 | ${{ needs.import-check.result == 'success' && 'โœ…' || 'โŒ' }} | ${{ needs.unit-tests.result == 'success' && 'โœ…' || 'โŒ' }} |" >> $GITHUB_STEP_SUMMARY echo "| 3.11 | ${{ needs.import-check.result == 'success' && 'โœ…' || 'โŒ' }} | ${{ needs.unit-tests.result == 'success' && 'โœ…' || 'โŒ' }} |" >> $GITHUB_STEP_SUMMARY echo "| 3.12 | ${{ needs.import-check.result == 'success' && 'โœ…' || 'โŒ' }} | ${{ needs.unit-tests.result == 'success' && 'โœ…' || 'โŒ' }} |" >> $GITHUB_STEP_SUMMARY - name: Fail if tests failed if: needs.import-check.result == 'failure' || needs.unit-tests.result == 'failure' run: exit 1