name: PR Validation
on:
pull_request:
branches: ["main", "master"]
workflow_dispatch:
jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Run tests with pytest
run: |
pytest tests/ \
--verbose \
--tb=short \
--cov=docs_mcp \
--cov-report=term-missing \
--cov-report=xml \
--cov-fail-under=80
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
if: matrix.python-version == '3.11'
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
lint:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff mypy types-PyYAML
- name: Run Ruff linter
run: |
ruff check docs_mcp/ tests/
- name: Run Ruff formatter check
run: |
ruff format --check docs_mcp/ tests/
- name: Run MyPy type checker
run: |
mypy docs_mcp/ --ignore-missing-imports
continue-on-error: true # Don't fail on type errors yet
security:
name: Security Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bandit safety
- name: Run Bandit security scanner
run: |
bandit -r docs_mcp/ -ll -f json -o bandit-report.json || true
bandit -r docs_mcp/ -ll
continue-on-error: true
- name: Check for known vulnerabilities
run: |
pip freeze | safety check --stdin || true
continue-on-error: true
documentation:
name: Documentation Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Validate documentation
uses: ./.github/actions/validate-docs
with:
paths: 'docs/'
python-version: '3.11'
fail-on-warnings: 'false'
generate-report: 'true'
upload-report: 'true'
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [test, lint, security, documentation]
if: always()
steps:
- name: Check test results
run: |
echo "Test job status: ${{ needs.test.result }}"
echo "Lint job status: ${{ needs.lint.result }}"
echo "Security job status: ${{ needs.security.result }}"
echo "Documentation job status: ${{ needs.documentation.result }}"
if [ "${{ needs.test.result }}" != "success" ]; then
echo "❌ Tests failed"
exit 1
fi
if [ "${{ needs.lint.result }}" != "success" ]; then
echo "❌ Linting failed"
exit 1
fi
if [ "${{ needs.documentation.result }}" != "success" ]; then
echo "❌ Documentation validation failed"
exit 1
fi
echo "✅ All required checks passed"