77 branches : [ main ]
88
99jobs :
10- test :
10+ unit-tests :
1111 runs-on : ubuntu-latest
1212 strategy :
1313 matrix :
@@ -35,77 +35,82 @@ jobs:
3535 pip install -r requirements.txt
3636 pip install -r tests/requirements.txt
3737
38- - name : Run unit tests
38+ - name : Run unit tests (no server required)
3939 run : |
4040 # Set up local inference environment
4141 export OPTILLM_API_KEY=optillm
4242
43- # Run quick CI tests
43+ # Run tests that don't need server - fast feedback!
4444 python tests/test_ci_quick.py
45-
46- # Run plugin tests with pytest if available
4745 python -m pytest tests/test_plugins.py -v --tb=short || python tests/test_plugins.py
48-
49- # Run approach tests
5046 python tests/test_approaches.py
51-
52- # Run reasoning token tests (unit tests only - no MLX)
5347 python tests/test_reasoning_simple.py
54- python tests/test_reasoning_tokens.py
55- python tests/test_reasoning_integration.py
56-
57- # Run batching tests (MLX tests auto-skipped on Ubuntu)
5848 python tests/test_batching.py
59-
60- # Run JSON plugin tests
61- python tests/test_json_plugin.py
62-
63- # Run n-parameter tests
64- python tests/test_n_parameter.py
65-
66- # Run API compatibility tests with pytest if available
67- python -m pytest tests/test_api_compatibility.py -v --tb=short || echo "API compatibility tests require pytest"
68-
69- # Run main test framework with basic tests
70- python tests/test.py --approaches none --single-test "Simple Math Problem"
7149 env :
7250 OPTILLM_API_KEY : optillm
7351
74- integration-test :
52+ integration-tests :
7553 runs-on : ubuntu-latest
76- needs : test
77- if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
78- # Only run integration tests on PRs from the same repository (not forks)
79- # This ensures secrets are available
54+ needs : unit-tests # Only run if unit tests pass
55+ strategy :
56+ matrix :
57+ python-version : ['3.12']
8058
8159 steps :
8260 - uses : actions/checkout@v4
8361
84- - name : Set up Python
62+ - name : Set up Python ${{ matrix.python-version }}
8563 uses : actions/setup-python@v4
8664 with :
87- python-version : ' 3.12'
65+ python-version : ${{ matrix.python-version }}
66+
67+ - name : Cache pip packages
68+ uses : actions/cache@v3
69+ with :
70+ path : ~/.cache/pip
71+ key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
72+ restore-keys : |
73+ ${{ runner.os }}-pip-
8874
8975 - name : Install dependencies
9076 run : |
9177 python -m pip install --upgrade pip
9278 pip install -r requirements.txt
79+ pip install -r tests/requirements.txt
9380
94- - name : Run integration test with OpenAI
95- if : env.OPENAI_API_KEY != ''
81+ - name : Start optillm server
9682 run : |
97- # Start OptILLM server
98- python optillm.py &
99- SERVER_PID=$!
100-
101- # Wait for server
102- sleep 5
83+ echo "Starting optillm server for integration tests..."
84+ OPTILLM_API_KEY=optillm python optillm.py --model google/gemma-3-270m-it --port 8000 &
85+ echo $! > server.pid
10386
104- # Run simple integration test
105- python tests/test.py --approaches none --single-test "Simple Math Problem" --base-url http://localhost:8000/v1 --model gpt-4o-mini || true
87+ # Wait for server to be ready
88+ echo "Waiting for server to start..."
89+ sleep 15
10690
107- # Stop server
108- kill $SERVER_PID || true
91+ # Test server health
92+ curl -s http://localhost:8000/health || echo "Server health check failed"
10993 env :
110- OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
111- continue-on-error : true
94+ OPTILLM_API_KEY : optillm
95+
96+ - name : Run integration tests (server required)
97+ run : |
98+ # Run tests that need the server
99+ echo "Running tests that require optillm server..."
100+ OPTILLM_API_KEY=optillm python tests/test_reasoning_tokens.py
101+ OPTILLM_API_KEY=optillm python tests/test_reasoning_integration.py
102+ OPTILLM_API_KEY=optillm python tests/test_json_plugin.py
103+ OPTILLM_API_KEY=optillm python tests/test_n_parameter.py
104+ OPTILLM_API_KEY=optillm python -m pytest tests/test_api_compatibility.py -v --tb=short || echo "API compatibility tests require pytest"
105+ OPTILLM_API_KEY=optillm python tests/test.py --approaches none --single-test "Simple Math Problem"
106+ env :
107+ OPTILLM_API_KEY : optillm
108+
109+ - name : Stop optillm server
110+ if : always()
111+ run : |
112+ echo "Stopping optillm server..."
113+ if [ -f server.pid ]; then
114+ kill $(cat server.pid) || true
115+ fi
116+ sleep 2
0 commit comments