Regression Tests #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Regression Tests | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - 'Makefile' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'pyproject.toml' | |
| - 'Makefile' | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Upgrade pip | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install --upgrade setuptools wheel | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| pip install -e ".[dev,test]" | |
| - name: Install Docker | |
| run: | | |
| curl -fsSL https://get.docker.com -o get-docker.sh | |
| sudo sh get-docker.sh | |
| - name: Deploy SeekDB (OceanBase) | |
| run: | | |
| # Remove existing container if it exists | |
| sudo docker rm -f seekdb 2>/dev/null || true | |
| # Start SeekDB container | |
| sudo docker run -d -p 10001:2881 --name seekdb oceanbase/seekdb | |
| # Wait for database to be ready | |
| echo "Waiting for SeekDB to be ready..." | |
| timeout=60 | |
| elapsed=0 | |
| while [ $elapsed -lt $timeout ]; do | |
| if sudo docker exec seekdb mysql -uroot -e "SELECT 1" > /dev/null 2>&1; then | |
| echo "✓ SeekDB is ready!" | |
| break | |
| fi | |
| echo "Waiting for SeekDB... ($elapsed/$timeout seconds)" | |
| sleep 2 | |
| elapsed=$((elapsed + 2)) | |
| done | |
| if [ $elapsed -ge $timeout ]; then | |
| echo "⚠ Warning: SeekDB may not be fully ready, but continuing..." | |
| fi | |
| # Show container status | |
| echo "SeekDB container status:" | |
| sudo docker ps | grep seekdb || true | |
| echo "Recent logs:" | |
| sudo docker logs --tail 20 seekdb || true | |
| mysql -uroot -h127.0.0.1 -P10001 -e "CREATE DATABASE IF NOT EXISTS powermem;" || echo "⚠ Warning: Failed to create database, but continuing..." | |
| mysql -uroot -h127.0.0.1 -P10001 -e "SHOW DATABASES LIKE 'powermem';" || echo "⚠ Warning: Could not verify database, but continuing..." | |
| - name: Set env | |
| env: | |
| QWEN: ${{ secrets.QWEN }} | |
| SILICONFLOW_COM: ${{ secrets.SILICONFLOW_COM }} | |
| run: | | |
| cp .env.example .env | |
| # Use Python script to update .env file (more reliable than sed) | |
| python3 << 'PYTHON_SCRIPT' | |
| import os | |
| import re | |
| env_file = '.env' | |
| # Define all variables to update | |
| updates = { | |
| 'OCEANBASE_HOST': '127.0.0.1', | |
| 'OCEANBASE_PORT': '10001', | |
| 'OCEANBASE_USER': 'root', | |
| 'OCEANBASE_PASSWORD': '', | |
| 'OCEANBASE_DB': 'powermem', | |
| 'OCEANBASE_COLLECTION': 'memories', | |
| 'DATABASE_PROVIDER': 'oceanbase', | |
| 'LLM_PROVIDER': 'siliconflow', | |
| 'LLM_MODEL': 'nex-agi/DeepSeek-V3.1-Nex-N1', | |
| 'SILICONFLOW_LLM_BASE_URL': 'https://api.siliconflow.com/v1', | |
| 'GRAPH_STORE_PORT': '10001', | |
| 'GRAPH_STORE_PASSWORD': '', | |
| 'LLM_API_KEY': os.environ.get('SILICONFLOW_COM', ''), | |
| 'EMBEDDING_API_KEY': os.environ.get('QWEN', ''), | |
| } | |
| # Update or add each variable | |
| lines = content.split('\n') | |
| existing_keys = set() | |
| updated_lines = [] | |
| for line in lines: | |
| stripped = line.strip() | |
| # Preserve comments and empty lines | |
| if stripped.startswith('#') or not stripped: | |
| updated_lines.append(line) | |
| continue | |
| # Check if line contains a key=value pattern | |
| match = re.match(r'^([^#=]+?)=(.*)$', stripped) | |
| if match: | |
| key = match.group(1).strip() | |
| existing_keys.add(key) | |
| # Update if key is in our updates dict | |
| if key in updates: | |
| updated_lines.append(f"{key}={updates[key]}") | |
| else: | |
| # Keep original line if not in updates | |
| updated_lines.append(line) | |
| else: | |
| # Keep line as-is if it doesn't match pattern | |
| updated_lines.append(line) | |
| # Add missing variables at the end | |
| for key, value in updates.items(): | |
| if key not in existing_keys: | |
| updated_lines.append(f"{key}={value}") | |
| # Write back to file | |
| with open(env_file, 'w', encoding='utf-8') as f: | |
| f.write('\n'.join(updated_lines)) | |
| print("✓ .env file updated successfully") | |
| print(f" Updated/added {len(updates)} environment variables") | |
| PYTHON_SCRIPT | |
| - name: Run regression tests | |
| env: | |
| QWEN: ${{ secrets.QWEN }} | |
| SILICONFLOW_CN: ${{ secrets.SILICONFLOW_CN }} | |
| SILICONFLOW_COM: ${{ secrets.SILICONFLOW_COM }} | |
| run: | | |
| pytest tests/regression/test_scenario_1_basic_usage.py -vs | |