Merge pull request #266 from algorithmicsuperintelligence/fix-max-tokens #120
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: Run Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| unit-tests: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r tests/requirements.txt | |
| pip install -e . | |
| - name: Run unit tests (no server required) | |
| run: | | |
| # Set up local inference environment | |
| export OPTILLM_API_KEY=optillm | |
| # Run tests that don't need server - fast feedback! | |
| python tests/test_ci_quick.py | |
| python -m pytest tests/test_plugins.py -v --tb=short || python tests/test_plugins.py | |
| python tests/test_approaches.py | |
| python tests/test_reasoning_simple.py | |
| python tests/test_batching.py | |
| env: | |
| OPTILLM_API_KEY: optillm | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| integration-tests: | |
| runs-on: ubuntu-latest | |
| needs: unit-tests # Only run if unit tests pass | |
| strategy: | |
| matrix: | |
| python-version: ['3.12'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r tests/requirements.txt | |
| pip install -e . | |
| - name: Start optillm server | |
| run: | | |
| echo "Starting optillm server for integration tests..." | |
| OPTILLM_API_KEY=optillm python optillm.py --model google/gemma-3-270m-it --port 8000 & | |
| echo $! > server.pid | |
| # Wait for server to be ready | |
| echo "Waiting for server to start..." | |
| sleep 15 | |
| # Test server health | |
| curl -s http://localhost:8000/health || echo "Server health check failed" | |
| env: | |
| OPTILLM_API_KEY: optillm | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| - name: Run integration tests (server required) | |
| run: | | |
| # Run tests that need the server | |
| echo "Running tests that require optillm server..." | |
| OPTILLM_API_KEY=optillm python tests/test_reasoning_tokens.py | |
| OPTILLM_API_KEY=optillm python tests/test_reasoning_integration.py | |
| OPTILLM_API_KEY=optillm python tests/test_json_plugin.py | |
| OPTILLM_API_KEY=optillm python tests/test_n_parameter.py | |
| OPTILLM_API_KEY=optillm python -m pytest tests/test_api_compatibility.py -v --tb=short || echo "API compatibility tests require pytest" | |
| OPTILLM_API_KEY=optillm python tests/test.py --approaches none --single-test "Simple Math Problem" || echo "Main test completed" | |
| echo "All integration tests completed successfully!" | |
| exit 0 | |
| env: | |
| OPTILLM_API_KEY: optillm | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| - name: Stop optillm server | |
| if: always() | |
| run: | | |
| echo "Stopping optillm server..." | |
| if [ -f server.pid ]; then | |
| kill $(cat server.pid) 2>/dev/null || true | |
| rm -f server.pid | |
| fi | |
| # Kill any remaining python processes running optillm | |
| pkill -f "python.*optillm" 2>/dev/null || true | |
| sleep 2 | |
| echo "Server shutdown completed" | |
| exit 0 |