Files
DeepTutor/.github/workflows/tests.yml
2026-11-02 23:09:54 +01:00

436 lines
16 KiB
YAML

name: Tests
on:
workflow_dispatch:
schedule:
- cron: "17 3 * * *"
push:
branches:
- main
- dev
- preview
paths:
- "deeptutor/**"
- "deeptutor_cli/**"
- "tests/**"
- "requirements/**"
- "requirements.txt"
- "pyproject.toml"
- "web/**"
- "packages/chat-engine/**"
- "apps/desktop/**"
- ".github/workflows/tests.yml"
pull_request:
branches:
- main
- dev
- preview
paths:
- "deeptutor/**"
- "deeptutor_cli/**"
- "tests/**"
- "requirements/**"
- "requirements.txt"
- "pyproject.toml"
- "web/**"
- "packages/chat-engine/**"
- "apps/desktop/**"
- ".github/workflows/tests.yml"
# A new push supersedes every earlier run for the same PR/branch. Without this,
# each fix-up commit leaves the previous full matrix running to completion,
# delaying feedback for the author and every other PR in the queue.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Keep Linux runners on the LTS supported by the pinned browser toolchain.
jobs:
desktop:
name: Desktop Shell (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
# Windows exercises taskkill-based shutdown; the others process groups.
os: [ubuntu-24.04, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: apps/desktop/package-lock.json
- name: Check and test the shell
working-directory: apps/desktop
shell: bash
env:
ELECTRON_SKIP_BINARY_DOWNLOAD: "1"
run: npm ci && npm run check && npm test
chat-engine:
name: Experimental TypeScript Chat Engine
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: packages/chat-engine/package-lock.json
- name: Check scheduler contracts and dependency boundaries
working-directory: packages/chat-engine
run: npm ci && npm test
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install compatibility adapters
run: pip install -r requirements/full.txt -r requirements/partners.txt pytest pytest-asyncio
- name: Create synthetic model configuration
run: |
mkdir -p data/user/settings
cp tests/fixtures/ci_model_catalog.json data/user/settings/model_catalog.json
- name: Exercise chat and partner behavior through TypeScript
env:
DEEPTUTOR_CHAT_ENGINE: typescript
PYTHONPATH: ${{ github.workspace }}
run: |
pytest -q tests/agents/chat tests/runtime/test_ts_engine.py \
tests/services/partners/test_partner_runtime.py \
tests/capabilities/test_partner_group_capability.py \
tests/capabilities/test_mastery_loop_pipeline.py
- name: Exercise the Python reference and durable event subscriptions
env:
DEEPTUTOR_CHAT_ENGINE: python
PYTHONPATH: ${{ github.workspace }}
run: |
pytest -q tests/agents/chat/test_agent_loop.py \
tests/runtime/coordination/test_event_notifications.py \
tests/app/test_turn_application_service.py
- name: Exercise native model, history, tool boundaries and lazy API admission
env:
PYTHONPATH: ${{ github.workspace }}
run: |
pytest -q tests/runtime/test_native_engine.py \
tests/api/test_router_loader.py
lint:
name: Lint and Format
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install lint tools
run: |
python -m pip install --upgrade pip
pip install ruff==0.16.0 import-linter==2.11
- name: Run Ruff lint
run: ruff check .
- name: Run Ruff format check
run: ruff format --check .
- name: Enforce dependency boundaries
run: |
lint-imports
python scripts/check_architecture.py
web-tests:
name: Web Node Tests
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install frontend dependencies
working-directory: web
run: npm ci --legacy-peer-deps
- name: Run complete deterministic frontend gate
working-directory: web
run: npm run check
- name: Install Playwright Chromium
working-directory: web
run: npx playwright install --with-deps chromium
- name: Run interaction, accessibility, and visual matrix audits
working-directory: web
run: |
npm start -- --hostname 127.0.0.1 --port 3000 > /tmp/deeptutor-web-audit.log 2>&1 &
audit_server_pid=$!
trap 'kill "$audit_server_pid"' EXIT
for attempt in $(seq 1 100); do
if curl --fail --silent http://127.0.0.1:3000/ > /dev/null; then
break
fi
if ! kill -0 "$audit_server_pid" 2>/dev/null; then
cat /tmp/deeptutor-web-audit.log
exit 1
fi
sleep 0.1
done
WEB_BASE_URL=http://127.0.0.1:3000 npm run audit
multi-worker-web:
name: Four-worker browser acceptance
if: vars.DEEPTUTOR_MULTI_WORKER_E2E_URL != ''
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install frontend dependencies
working-directory: web
run: npm ci --legacy-peer-deps
- name: Install Playwright Chromium
working-directory: web
run: npx playwright install --with-deps chromium
- name: Run desktop and mobile four-worker scenarios
working-directory: web
run: >-
npx playwright test
--project=multi-worker-turns-desktop
--project=multi-worker-turns-mobile
env:
DEEPTUTOR_MULTI_WORKER_E2E: "1"
WEB_BASE_URL: ${{ vars.DEEPTUTOR_MULTI_WORKER_E2E_URL }}
NEXT_PUBLIC_API_BASE: ${{ vars.DEEPTUTOR_MULTI_WORKER_E2E_URL }}
DEEPTUTOR_MULTI_WORKER_CONTROL_URL: ${{ vars.DEEPTUTOR_MULTI_WORKER_CONTROL_URL || vars.DEEPTUTOR_MULTI_WORKER_E2E_URL }}
- name: Upload browser traces and videos
if: always()
uses: actions/upload-artifact@v4
with:
name: multi-worker-browser-evidence
path: |
web/playwright-report
web/test-results
if-no-files-found: ignore
import-check:
name: Import Check (Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.11"
os: ubuntu-24.04
- python-version: "3.12"
os: ubuntu-24.04
- python-version: "3.13"
os: ubuntu-24.04
- python-version: "3.14"
os: ubuntu-24.04
- python-version: "3.14"
os: macos-latest
- python-version: "3.14"
os: windows-latest
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/full.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/full.txt
# Exercise project metadata too, especially `requires-python`.
pip install -e . --no-deps
- 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.runtime_settings import RuntimeSettingsService; print('RuntimeSettingsService 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 configure_logging, bind_log_context, capture_process_logs, ProcessLogEvent; print('Logging imports OK')"
env:
PYTHONPATH: ${{ github.workspace }}
- name: Check lazy startup and isolated worker protocol
run: |
python -c "import sys; import deeptutor.runtime.registry.tool_registry; assert 'deeptutor.agents.chat.agentic_pipeline' not in sys.modules; print('Tool implementations stay cold')"
python -c "from deeptutor.runtime.isolated_worker import run_in_isolated_process_sync; assert run_in_isolated_process_sync('operator:add', 20, 22, timeout=15) == 42; print('Isolated worker protocol OK')"
env:
PYTHONPATH: ${{ github.workspace }}
- name: Verify MinerU process ownership on Windows
if: runner.os == 'Windows'
run: |
python -m pip install pytest pytest-asyncio pywin32
python -m pytest -q tests/services/parsing/test_mineru_process_lifecycle.py
env:
PYTHONPATH: ${{ github.workspace }}
DEEPTUTOR_HOME: ${{ runner.temp }}/mineru-process-tests
python-tests:
name: Python Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-24.04
needs: import-check
services:
redis:
image: redis:7.4-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 10
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
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/full.txt', 'requirements/cli.txt', 'requirements/partners.txt', 'pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
- name: Install smoke test dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/full.txt
pip install -r requirements/partners.txt
pip install pytest pytest-asyncio
- name: Install optional fastapi-guard
run: pip install -r requirements/guard.txt
- name: Install optional LightRAG SDK
if: matrix.python-version == '3.12'
run: pip install "lightrag-hku==1.5.7"
- name: Install optional GraphRAG SDK
if: matrix.python-version == '3.12'
run: pip install "graphrag>=3.0.1,<4.0.0"
- 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
cp tests/fixtures/ci_model_catalog.json data/user/settings/model_catalog.json
- name: Run Python tests
run: |
echo "🧪 Running Python tests on Python ${{ matrix.python-version }}"
pytest -q tests deeptutor/learning/tests
env:
PYTHONPATH: ${{ github.workspace }}
DEEPTUTOR_TEST_REDIS_URL: redis://127.0.0.1:6379/0
video-lesson-sandbox:
name: Video lesson isolation (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install test dependencies
run: pip install -r requirements/full.txt pytest pytest-asyncio
- name: Check real rendering, isolation, cancellation and timeout
env:
DEEPTUTOR_TEST_VIDEO_SANDBOX: "1"
DEEPTUTOR_REMOTION_RUNTIME: ${{ runner.temp }}/remotion
PYTHONPATH: ${{ github.workspace }}
run: |
pytest -q tests/agents/video_lesson tests/services/sandbox/test_process_cancellation.py
node --test tests/services/sandbox/javascript.test.mjs
test-summary:
name: Test Summary
runs-on: ubuntu-24.04
needs: [desktop, chat-engine, lint, web-tests, multi-worker-web, import-check, python-tests, video-lesson-sandbox]
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 "| macOS desktop shell | ${{ needs.desktop.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| TypeScript chat engine | ${{ needs.chat-engine.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Video lesson isolation | ${{ needs.video-lesson-sandbox.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Lint and format | ${{ needs.lint.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Web node tests | ${{ needs.web-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Four-worker browser acceptance | ${{ needs.multi-worker-web.result == 'success' && '✅ Passed' || needs.multi-worker-web.result == 'skipped' && '⏭️ Fixture not configured' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Import/lazy/worker check (3.11–3.14; 3.14 on Linux/macOS/Windows) | ${{ needs.import-check.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Python tests (3.11/3.12/3.13/3.14) | ${{ needs.python-tests.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
- name: Fail if tests failed
if: needs.video-lesson-sandbox.result != 'success' || needs.desktop.result == 'failure' || needs.chat-engine.result == 'failure' || needs.lint.result == 'failure' || needs.web-tests.result == 'failure' || needs.multi-worker-web.result == 'failure' || needs.import-check.result == 'failure' || needs.python-tests.result == 'failure'
run: exit 1