name: PR Rust Code Coverage
on: [pull_request]
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install Tarpaulin
run: cargo install cargo-tarpaulin
- name: Run Tarpaulin
run: |
cargo tarpaulin --out Xml --out Html
echo "COVERAGE=$(grep -Po 'line-rate="\K[^"]*' cobertura.xml | awk '{print $1 * 100}')%" >> $GITHUB_ENV
continue-on-error: true
- name: Upload Coverage to Artifacts
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: tarpaulin-report.html
- name: Post Coverage Comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
## Code Coverage Report
Current coverage: ${{ env.COVERAGE }}
[View Full Report](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})