name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
exclude:
# Exclude some combinations to save CI time
- os: windows-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.8'
steps:
- uses: actions/checkout@v3
- 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 pytest pytest-cov pytest-asyncio flake8 black mypy
- name: Download embedding model
run: |
python scripts/download_model.py
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 src/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Check code formatting with black
run: |
black --check src/ || echo "Code formatting issues found. Run 'black src/' to fix."
- name: Type check with mypy
run: |
mypy src/ --ignore-missing-imports || echo "Type checking completed with warnings"
- name: Test with pytest
run: |
pytest tests/ -v --cov=src --cov-report=xml --cov-report=term
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
test-voice-assistant:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: voice-assistant/package-lock.json
- name: Install voice assistant dependencies
working-directory: ./voice-assistant
run: |
npm ci || npm install
- name: Run voice assistant tests
working-directory: ./voice-assistant
run: |
npm test || echo "No tests configured yet"
build-docker:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: |
if [ -f Dockerfile ]; then
docker build . --tag scs-mcp:latest
else
echo "No Dockerfile found, skipping Docker build"
fi
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy results to GitHub Security
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'