name: Codecov
concurrency:
group: codecov-${{ github.ref_name }}
cancel-in-progress: true
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
checks: write
pull-requests: write
jobs:
coverage:
name: Code Coverage
runs-on: ubuntu-latest
env:
CARGO_LLVM_COV_VERSION: "0.8.7"
JUST_VERSION: "1.51.0"
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
fetch-depth: 0 persist-credentials: false
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 with:
cache: true
- name: Install LLVM coverage tools
run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 with:
tool: cargo-llvm-cov@${{ env.CARGO_LLVM_COV_VERSION }}
- name: Install just
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 with:
tool: just@${{ env.JUST_VERSION }}
- name: Run coverage
run: |
mkdir -p coverage
chmod 755 coverage
echo "::group::Running coverage"
# Single source of truth: coverage configuration lives in justfile
just coverage-ci
echo "::endgroup::"
echo "::group::Coverage verification"
ls -la coverage/ || true
if [ ! -f coverage/cobertura.xml ]; then
echo "::error::coverage/cobertura.xml not found. cargo-llvm-cov failed to generate XML output."
exit 2
fi
echo "::notice::Coverage report generated successfully: $(wc -l < coverage/cobertura.xml) lines"
echo "::endgroup::"
env:
RUST_BACKTRACE: 1
- name: Upload coverage to Codecov
if: ${{ success() && hashFiles('coverage/cobertura.xml') != '' }}
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 with:
files: coverage/cobertura.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Archive coverage results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a if: always()
with:
name: coverage-report
path: coverage/