Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add code coverage reporting to CI (#1239)

LearningCircuitfbb1928edc8d
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e5fe722741..a82e09773d 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -370,5 +370,115 @@ jobs:
path: |
tests/screenshots/
tests/ui_tests/screenshots/
-# Force CI rebuild
-# Force CI rebuild - network issue
+ # Code coverage report
+ coverage-report:
+ runs-on: ubuntu-latest
+ name: Coverage Report
+ needs: [unit-tests]
+ if: |
+ github.event_name == 'pull_request' ||
+ github.ref == 'refs/heads/main' ||
+ github.ref == 'refs/heads/dev'
+
+ env:
+ TEST_IMAGE: ldr-test
+
+ steps:
+ - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
+
+ - name: Build Docker image with cache
+ uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
+ with:
+ context: .
+ target: ldr-test
+ load: true
+ tags: ${{ env.TEST_IMAGE }}
+ cache-from: type=gha,scope=ldr-test
+ cache-to: type=gha,mode=max,scope=ldr-test
+
+ - name: Run tests with coverage
+ # Continue even if some tests fail - we still want the coverage report
+ continue-on-error: true
+ run: |
+ mkdir -p coverage
+ docker run --rm \
+ -v "$PWD":/app \
+ -e LDR_USE_FALLBACK_LLM=true \
+ -e LDR_TESTING_WITH_MOCKS=true \
+ -w /app \
+ ${{ env.TEST_IMAGE }} \
+ sh -c "python -m pytest tests/ \
+ --cov=src \
+ --cov-report=term-missing \
+ --cov-report=xml:coverage/coverage.xml \
+ --cov-report=html:coverage/htmlcov \
+ -v --tb=short \
+ --ignore=tests/ui_tests \
+ --ignore=tests/infrastructure_tests \
+ --ignore=tests/fuzz"
+
+ - name: Generate coverage summary
+ if: always()
+ run: |
+ {
+ echo "## Coverage Report"
+ echo ""
+ if [ -f coverage/coverage.xml ]; then
+ # Extract total coverage from XML
+ COVERAGE=$(python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage/coverage.xml'); print(f\"{float(tree.getroot().get('line-rate', 0)) * 100:.1f}%\")" 2>/dev/null || echo "N/A")
+ echo "**Total Line Coverage: ${COVERAGE}**"
+ echo ""
+ echo "📊 [Download full HTML report](../artifacts) for detailed line-by-line coverage."
+ else
+ echo "⚠️ Coverage report not generated"
+ fi
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ - name: Upload coverage reports
+ if: always()
+ uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
+ with:
+ name: coverage-report
+ path: coverage/
+
+ # Coverage badge via GitHub Gist + shields.io (no third-party service needed)
+ # How it works:
+ # 1. We store a JSON file in a GitHub Gist (gist.github.com - GitHub's snippet/paste service)
+ # 2. shields.io reads that JSON to generate a badge image
+ # 3. README references the shields.io URL to display the badge
+ # Setup: Create a gist, add GIST_TOKEN (PAT with gist scope) and COVERAGE_GIST_ID secrets
+ - name: Update coverage badge
+ if: github.ref == 'refs/heads/dev' && github.event_name == 'push'
+ env:
+ GIST_TOKEN: ${{ secrets.GIST_TOKEN }}
+ run: |
+ if [ -z "$GIST_TOKEN" ]; then
+ echo "GIST_TOKEN not set, skipping badge update"
+ exit 0
+ fi
+ if [ -f coverage/coverage.xml ]; then
+ COVERAGE=$(python3 -c "import xml.etree.ElementTree as ET; tree = ET.parse('coverage/coverage.xml'); print(f\"{float(tree.getroot().get('line-rate', 0)) * 100:.0f}\")" 2>/dev/null || echo "0")
+ # Determine color based on coverage
+ if [ "$COVERAGE" -ge 80 ]; then
+ COLOR="brightgreen"
+ elif [ "$COVERAGE" -ge 60 ]; then
+ COLOR="green"
+ elif [ "$COVERAGE" -ge 40 ]; then
+ COLOR="yellow"
+ else
+ COLOR="red"
+ fi
+ # Create badge JSON
+ echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${COVERAGE}%\",\"color\":\"${COLOR}\"}" > coverage-badge.json
+ # Update gist (requires GIST_TOKEN secret and GIST_ID)
+ if [ -n "${{ secrets.COVERAGE_GIST_ID }}" ]; then
+ curl -s -X PATCH \
+ -H "Authorization: token ${GIST_TOKEN}" \
+ -H "Accept: application/vnd.github.v3+json" \
+ "https://api.github.com/gists/${{ secrets.COVERAGE_GIST_ID }}" \
+ -d "{\"files\":{\"coverage-badge.json\":{\"content\":$(jq -Rs . < coverage-badge.json)}}}"
+ fi
+ fi
diff --git a/README.md b/README.md
index f203453da8..446aadeffb 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,7 @@
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/LearningCircuit/local-deep-research/badge)](https://securityscorecards.dev/viewer/?uri=github.com/LearningCircuit/local-deep-research)
[![✅ All Tests](https://github.com/LearningCircuit/local-deep-research/actions/workflows/tests.yml/badge.svg?branch=main&style=for-the-badge)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/tests.yml)
+[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/LearningCircuit/0b35bc02a53a0cba6a2f5b95fea3f158/raw/coverage-badge.json)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/tests.yml)
[![🔧 Pre-commit](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pre-commit.yml/badge.svg?branch=main&style=for-the-badge)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/pre-commit.yml)
[![🐳 Container Security](https://github.com/LearningCircuit/local-deep-research/actions/workflows/container-security.yml/badge.svg?branch=main&style=for-the-badge)](https://github.com/LearningCircuit/local-deep-research/actions/workflows/container-security.yml)
diff --git a/pyproject.toml b/pyproject.toml
index e63f4b28cc..db57910f33 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -157,6 +157,36 @@ markers = [
"asyncio: marks async tests that use asyncio",
]
+[tool.coverage.run]
+source = ["src"]
+branch = true
+omit = [
+ "*/tests/*",
+ "*/__pycache__/*",
+ "*/migrations/*",
+ # Experimental strategies (will be cleaned up)
+ "*/strategies/*",
+ # CLI entry points (hard to unit test)
+ "*/cli.py",
+ "*/cli/*",
+ # Visualization code
+ "*/visualization.py",
+ # Experimental browsecomp decoding
+ "*/answer_decoding/*",
+]
+
+[tool.coverage.report]
+exclude_lines = [
+ "pragma: no cover",
+ "if TYPE_CHECKING:",
+ "raise NotImplementedError",
+]
+fail_under = 0
+show_missing = true
+
+[tool.coverage.html]
+directory = "coverage/htmlcov"
+
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
diff --git a/src/local_deep_research/__version__.py b/src/local_deep_research/__version__.py
index 86204ba57e..ed6cd8af67 100644
--- a/src/local_deep_research/__version__.py
+++ b/src/local_deep_research/__version__.py
@@ -1 +1 @@
-__version__ = "1.3.14"
+__version__ = "1.3.15"