docs: tidy README — remove duplicates and reorganize #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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| PYTHON_VERSION: "3.11" | |
| jobs: | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache pip dependencies | |
| 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 requirements-dev.txt | |
| - name: Code formatting with Black | |
| run: black --check --line-length 120 app/ tests/ | |
| - name: Import sorting with isort | |
| run: isort --check-only --profile black app/ tests/ | |
| - name: Linting with flake8 | |
| run: flake8 app/ tests/ --max-line-length=120 --extend-ignore=E203,W503 | |
| - name: Type checking with mypy | |
| run: mypy app/ --ignore-missing-imports | |
| test-ubuntu: | |
| name: Tests (Ubuntu - PyTorch Backend) | |
| runs-on: ubuntu-latest | |
| needs: code-quality | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11"] | |
| 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 dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements*.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.python-version }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-dev.txt | |
| - name: Run unit tests | |
| env: | |
| BACKEND: torch | |
| LOG_LEVEL: DEBUG | |
| run: | | |
| pytest tests/ -v --cov=app --cov-report=xml --cov-report=html | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| test-macos: | |
| name: Tests (macOS - MLX + PyTorch) | |
| runs-on: macos-latest | |
| needs: code-quality | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/Library/Caches/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 requirements-dev.txt | |
| - name: Install MLX (macOS only) | |
| run: | | |
| pip install mlx>=0.4.0 mlx-lm>=0.2.0 | |
| - name: Run tests with auto backend selection | |
| env: | |
| BACKEND: auto | |
| LOG_LEVEL: DEBUG | |
| run: | | |
| pytest tests/ -v --cov=app --cov-report=xml | |
| - name: Run MLX-specific tests | |
| env: | |
| BACKEND: mlx | |
| LOG_LEVEL: DEBUG | |
| run: | | |
| pytest tests/test_backends.py::test_mlx_backend -v | |
| - name: Run PyTorch MPS tests | |
| env: | |
| BACKEND: torch | |
| LOG_LEVEL: DEBUG | |
| run: | | |
| pytest tests/test_torch_backend.py -v | |
| integration-tests: | |
| name: API Integration Tests | |
| runs-on: ubuntu-latest | |
| needs: [test-ubuntu, test-macos] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install -r requirements-dev.txt | |
| - name: Run API integration tests | |
| env: | |
| BACKEND: torch | |
| run: | | |
| pytest tests/test_api_integration.py -v | |
| - name: Run performance benchmarks | |
| env: | |
| BACKEND: torch | |
| run: | | |
| python -m app.utils.benchmark --quick | |
| security-scan: | |
| name: Security Scanning | |
| runs-on: ubuntu-latest | |
| needs: code-quality | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run Bandit security scanner | |
| run: | | |
| pip install bandit[toml] | |
| bandit -r app/ -f json -o bandit-report.json | |
| - name: Run Safety dependency scanner | |
| run: | | |
| pip install safety | |
| safety check --json --output safety-report.json | |
| - name: Upload security reports | |
| uses: actions/upload-artifact@v3 | |
| if: always() | |
| with: | |
| name: security-reports | |
| path: | | |
| bandit-report.json | |
| safety-report.json | |
| build-test: | |
| name: Build Test | |
| runs-on: ubuntu-latest | |
| needs: [integration-tests, security-scan] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Test application startup | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # Test that the application can start | |
| timeout 30s python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 & | |
| sleep 10 | |
| curl -f http://localhost:8000/health/ || exit 1 | |
| - name: Build wheel | |
| run: | | |
| pip install build | |
| python -m build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: dist | |
| path: dist/ |