Merge pull request #80 from multimindlab/medium_issues_solved #236
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: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: # This allows manual triggering of the workflow | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: [3.11] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| # Install PyTorch >= 2.1 first (required by transformers and sentence-transformers) | |
| # Use CPU version for CI to avoid GPU dependencies | |
| pip install "torch>=2.1.0" --index-url https://download.pytorch.org/whl/cpu | |
| # Install remaining dependencies (torch>=2.1.0 in requirements.txt will be satisfied) | |
| pip install -r requirements.txt | |
| pip install onnx | |
| pip install -e .[dev] | |
| pip install transformers pyyaml | |
| pip install aiohttp | |
| pip install pydantic_settings | |
| pip install peft | |
| pip install datasets | |
| # Ensure torch version is correct after all installs | |
| pip install --upgrade "torch>=2.1.0" --index-url https://download.pytorch.org/whl/cpu | |
| - name: Set PYTHONPATH | |
| run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV | |
| - name: Install multimind in editable mode | |
| run: pip install -e . | |
| - name: Install test dependencies | |
| run: | | |
| pip install pytest pytest-cov pytest-asyncio pytest-mock | |
| - name: Run tests with coverage | |
| run: | | |
| pytest tests/ --cov=multimind --cov-report=term-missing --cov-report=xml -v | |
| - name: Check test pass rate (95% threshold) | |
| run: | | |
| python -c " | |
| import subprocess | |
| import re | |
| result = subprocess.run(['pytest', 'tests/', '-v', '--tb=no', '-q'], | |
| capture_output=True, text=True) | |
| output = result.stdout + result.stderr | |
| # Extract test counts | |
| match = re.search(r'(\d+) passed', output) | |
| passed = int(match.group(1)) if match else 0 | |
| match = re.search(r'(\d+) failed', output) | |
| failed = int(match.group(1)) if match else 0 | |
| match = re.search(r'(\d+) skipped', output) | |
| skipped = int(match.group(1)) if match else 0 | |
| total = passed + failed + skipped | |
| pass_rate = (passed / total * 100) if total > 0 else 0 | |
| print(f'Test Results: {passed} passed, {failed} failed, {skipped} skipped') | |
| print(f'Pass Rate: {pass_rate:.1f}%') | |
| if pass_rate < 95.0: | |
| print(f'ERROR: Test pass rate {pass_rate:.1f}% is below 95% threshold!') | |
| exit(1) | |
| print('SUCCESS: Test pass rate meets 95% threshold!') | |
| " | |
| - name: Set OpenAI API Key | |
| run: echo "OPENAI_API_KEY=your_openai_api_key" >> $GITHUB_ENV |