name: Coverage
on:
push:
branches: [integration, main]
schedule:
- cron: "0 7 * * 1"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
coverage:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
- uses: ./.github/actions/rust-setup
with:
cache-key: coverage
- uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65
- run: cargo binstall --no-confirm --force cargo-tarpaulin
- name: Run tarpaulin
run: cargo tarpaulin --exclude swink-agent-local-llm
- name: Coverage summary
run: |
report=$(find . -name 'tarpaulin-report.json' -not -path './.git/*' | head -1)
if [ -z "$report" ]; then
echo "## Coverage: report JSON not found (see tarpaulin step log for the percentage)" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
python3 - "$report" <<'PY' >> "$GITHUB_STEP_SUMMARY"
import json, sys
with open(sys.argv[1]) as f:
data = json.load(f)
files = data.get("files", [])
covered = sum(len([t for t in f["traces"] if t["stats"]["Line"] > 0]) for f in files)
total = sum(len(f["traces"]) for f in files)
pct = 100 * covered / total if total else 0.0
print(f"## Coverage: {pct:.1f}% ({covered}/{total} lines)")
PY
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: coverage-report
path: target/tarpaulin/
retention-days: 30