-
Notifications
You must be signed in to change notification settings - Fork 0
CI Integration
gradle-sanity has flags to fail the build if architectural problems are detected, and --json on all CLIs to parse results in the pipeline.
# Fail (exit 1) if there are cycles
gradle-sanity /path/to/project --fail-on-cycle --quiet
# Fail (exit 1) if the score drops below 70
gradle-sanity /path/to/project --fail-on-score-below 70 --quiet
# Combined
gradle-sanity /path/to/project --fail-on-cycle --fail-on-score-below 70 --quietgradle-sanity /path/to/project --json > sanity-report.jsonStructure (truncated — see the full real output in Commands):
{
"schema_version": 1,
"tool": "sanity",
"path": "...",
"score": 100,
"modules": { "core": { "ca": 6, "ce": 0, "I": 0.0 }, "...": {} },
"cycles": [],
"sdp_violations": [],
"coupling_issues": [ { "module": "app", "kind": "app", "I": 0.75, "ca": 1, "max_ca": 0 } ]
}Key fields for parsing in the pipeline: score (int 0–100) and the arrays cycles, sdp_violations, api_issues, fan_out_issues, version_issues, orphan_modules, coupling_issues (empty = no issues of that type).
sanity-report.jsonis also written automatically to thesanity/output directory alongside the text report — no redirection needed.
The repo includes a complete workflow in examples/github-actions-dependency-health.yml. Summary of what it does:
name: Android Dependency Health
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
dependency-health:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install android-gradle-analyzer
run: pipx install android-gradle-analyzer
- name: Check for dependency cycles
run: |
gradle-sanity ${{ github.workspace }} \
--fail-on-cycle --quiet --json > sanity-report.json
- name: Enforce minimum architecture score
run: |
gradle-sanity ${{ github.workspace }} \
--fail-on-score-below 70 --quiet
- name: Generate dependency diagram
if: always()
run: |
gradle-analyzer ${{ github.workspace }} \
--format mermaid --output-dir diagrams --quiet
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: dependency-reports
path: |
diagrams/
sanity/
sanity-report.json
retention-days: 30The workflow also includes an optional impact-check job that runs gradle-impact when a specific module changes (uncomment the paths filter and adjust the module name).