name: Integration Tests on: push: pull_request: workflow_dispatch: jobs: integration-test: name: Full Integration Test runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout repository 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-integration-${{ hashFiles('**/pyproject.toml') }} restore-keys: | ${{ runner.os }}-pip-integration- ${{ runner.os }}-pip- - name: Install Python dependencies run: | python -m pip install --upgrade pip pip install -e .[api,offline-storage] pip install pytest pytest-asyncio httpx - name: Create minimal frontend stub for testing run: | mkdir -p lightrag/api/webui echo 'LightRAG Test

Integration Test Mode

' > lightrag/api/webui/index.html echo "Created minimal frontend stub for integration testing" - name: Start Docker services (Redis, Neo4j, Milvus) run: | cd tests docker compose -f docker-compose.integration.yml up -d echo "Waiting for services to be ready..." - name: Wait for Redis run: | echo "Waiting for Redis to be ready..." timeout 60 bash -c 'until docker exec lightrag-test-redis redis-cli ping | grep -q PONG; do sleep 2; done' echo "✅ Redis is ready" - name: Wait for Neo4j run: | echo "Waiting for Neo4j to be ready..." timeout 120 bash -c 'until docker exec lightrag-test-neo4j cypher-shell -u neo4j -p testpassword123 "RETURN 1" 2>/dev/null | grep -q "1"; do sleep 5; done' echo "✅ Neo4j is ready" - name: Wait for Milvus run: | echo "Waiting for Milvus to be ready..." timeout 180 bash -c 'until curl -s http://localhost:9091/healthz | grep -q "OK"; do sleep 5; done' echo "✅ Milvus is ready" - name: Verify services are running run: | docker ps echo "Testing service connectivity..." docker exec lightrag-test-redis redis-cli ping docker exec lightrag-test-neo4j cypher-shell -u neo4j -p testpassword123 "RETURN 1" curl -s http://localhost:9091/healthz - name: Start Mock OpenAI Server run: | echo "Starting Mock OpenAI Server..." cd tests python mock_openai_server.py --host 127.0.0.1 --port 8000 & MOCK_PID=$! echo "MOCK_SERVER_PID=${MOCK_PID}" >> $GITHUB_ENV # Wait for mock server to be ready echo "Waiting for mock server to be ready..." timeout 30 bash -c 'until curl -s http://127.0.0.1:8000/health | grep -q "healthy"; do sleep 1; done' echo "✅ Mock OpenAI Server is ready (PID: ${MOCK_PID})" - name: Prepare test environment run: | cd tests cp .env.integration .env mkdir -p test_inputs test_rag_storage echo "Environment prepared for testing" - name: Start LightRAG Server run: | cd tests echo "Starting LightRAG Server..." lightrag-server & LIGHTRAG_PID=$! echo "LIGHTRAG_SERVER_PID=${LIGHTRAG_PID}" >> $GITHUB_ENV # Wait for LightRAG server to be ready echo "Waiting for LightRAG server to be ready..." timeout 60 bash -c 'until curl -s http://localhost:9621/health | grep -q "status"; do sleep 2; done' echo "✅ LightRAG Server is ready (PID: ${LIGHTRAG_PID})" - name: Run Integration Tests run: | cd tests python integration_test.py env: LIGHTRAG_API_URL: http://localhost:9621 - name: Collect logs on failure if: failure() run: | echo "=== LightRAG Server Logs ===" cat tests/lightrag.log* 2>/dev/null || echo "No LightRAG logs found" echo "=== Docker Service Logs ===" docker compose -f tests/docker-compose.integration.yml logs - name: Stop LightRAG Server if: always() run: | if [ ! -z "$LIGHTRAG_SERVER_PID" ]; then echo "Stopping LightRAG Server (PID: $LIGHTRAG_SERVER_PID)..." kill $LIGHTRAG_SERVER_PID 2>/dev/null || true sleep 2 fi - name: Stop Mock OpenAI Server if: always() run: | if [ ! -z "$MOCK_SERVER_PID" ]; then echo "Stopping Mock OpenAI Server (PID: $MOCK_SERVER_PID)..." kill $MOCK_SERVER_PID 2>/dev/null || true fi - name: Stop Docker services if: always() run: | cd tests docker compose -f docker-compose.integration.yml down -v echo "Docker services stopped and volumes removed" - name: Cleanup test artifacts if: always() run: | cd tests rm -rf test_inputs test_rag_storage .env echo "Test artifacts cleaned up" - name: Upload test artifacts if: always() uses: actions/upload-artifact@v4 with: name: integration-test-artifacts path: | tests/lightrag.log* tests/test_rag_storage/ retention-days: 7