chore: comment #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Coverage | ||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["**"] | ||
jobs: | ||
coverage: | ||
runs-on: | ||
- runs-on=${{ github.run_id }} | ||
- runner=16cpu-linux-arm64 | ||
- tag=coverage | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Rust toolchain (nightly) | ||
run: rustup toolchain install nightly --component llvm-tools-preview | ||
- name: Install cargo-llvm-cov | ||
run: cargo install cargo-llvm-cov | ||
- name: Run coverage | ||
run: cargo llvm-cov --json --output-path=coverage | ||
- name: Parse detailed coverage report | ||
id: parse | ||
run: | | ||
# Parse file-level coverage data into a markdown table format | ||
echo "| File | Coverage | Total Lines | Covered Lines |" > coverage_table.md | ||
echo "|--------------------|----------|-------------|---------------|" >> coverage_table.md | ||
jq -r '.files[] | "| \(.file) | \(.coverage.lines.percent)% | \(.coverage.lines.total) | \(.coverage.lines.covered) |"' coverage.json >> coverage_table.md | ||
# Read the markdown table as an output | ||
table=$(cat coverage_table.md) | ||
echo "table=$table" >> $GITHUB_ENV | ||
- name: Post detailed coverage results as PR comment | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const table = process.env.table; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `### Detailed Coverage Report\n\n${table}` | ||
}); |