mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:50:36 +08:00
The smoke test job fails because router modules load main.yaml at import time, but CI has no data/user/settings directory. Add a setup step that writes a minimal config so pytest collection succeeds. Made-with: Cursor
145 lines
4.8 KiB
YAML
145 lines
4.8 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- "deeptutor/**"
|
|
- "deeptutor_cli/**"
|
|
- "tests/**"
|
|
- "requirements/**"
|
|
- "requirements.txt"
|
|
- "pyproject.toml"
|
|
- ".github/workflows/tests.yml"
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- dev
|
|
paths:
|
|
- "deeptutor/**"
|
|
- "deeptutor_cli/**"
|
|
- "tests/**"
|
|
- "requirements/**"
|
|
- "requirements.txt"
|
|
- "pyproject.toml"
|
|
- ".github/workflows/tests.yml"
|
|
|
|
jobs:
|
|
import-check:
|
|
name: Import Check (Python ${{ matrix.python-version }})
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
python-version: ["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/server.txt', 'requirements/cli.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 -r requirements/server.txt
|
|
|
|
- name: Check module imports
|
|
run: |
|
|
echo "🐍 Testing with Python ${{ matrix.python-version }}"
|
|
python -c "from deeptutor.runtime.orchestrator import ChatOrchestrator; print('✅ Orchestrator imports OK')"
|
|
python -c "from deeptutor.runtime.registry.tool_registry import get_tool_registry; print('✅ Tool registry imports OK')"
|
|
python -c "from deeptutor.runtime.registry.capability_registry import get_capability_registry; print('✅ Capability registry imports OK')"
|
|
python -c "from deeptutor.services.config.env_store import EnvStore; print('✅ EnvStore imports OK')"
|
|
python -c "from deeptutor.api.routers.unified_ws import unified_websocket; print('✅ Unified WS imports OK')"
|
|
python -c "from deeptutor.services.prompt.manager import PromptManager; print('✅ Prompt manager imports OK')"
|
|
python -c "from deeptutor.logging import get_logger; print('✅ Logging imports OK')"
|
|
env:
|
|
PYTHONPATH: ${{ github.workspace }}
|
|
|
|
smoke-tests:
|
|
name: Smoke Tests (Python 3.11)
|
|
runs-on: ubuntu-latest
|
|
needs: import-check
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.11"
|
|
|
|
- name: Cache pip packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-3.11-${{ hashFiles('requirements/server.txt', 'requirements/cli.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-3.11-
|
|
|
|
- name: Install smoke test dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements/server.txt
|
|
pip install pytest pytest-asyncio
|
|
|
|
- name: Create minimal runtime config
|
|
run: |
|
|
mkdir -p data/user/settings
|
|
cat > data/user/settings/main.yaml <<'YAML'
|
|
system:
|
|
language: en
|
|
logging:
|
|
level: WARNING
|
|
YAML
|
|
|
|
- name: Run smoke tests
|
|
run: |
|
|
echo "🧪 Running smoke test subset"
|
|
pytest -q --import-mode=importlib \
|
|
tests/api \
|
|
tests/cli \
|
|
tests/services/test_app_facade.py \
|
|
tests/services/test_model_catalog.py \
|
|
tests/services/test_path_service.py \
|
|
tests/services/memory \
|
|
tests/services/session \
|
|
tests/tools
|
|
env:
|
|
PYTHONPATH: ${{ github.workspace }}
|
|
|
|
test-summary:
|
|
name: Test Summary
|
|
runs-on: ubuntu-latest
|
|
needs: [import-check, smoke-tests]
|
|
if: always()
|
|
|
|
steps:
|
|
- name: Check test results
|
|
run: |
|
|
echo "## 🧪 Test Results Summary" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Import check (3.11/3.12) | ${{ needs.import-check.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Smoke tests (3.11) | ${{ needs.smoke-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Fail if tests failed
|
|
if: needs.import-check.result == 'failure' || needs.smoke-tests.result == 'failure'
|
|
run: exit 1
|