-
Notifications
You must be signed in to change notification settings - Fork 18
63 lines (51 loc) · 2.17 KB
/
coverage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Coverage
on:
push:
branches: ["main"]
pull_request:
branches: ["**"]
jobs:
coverage:
runs-on:
- runs-on=${{ github.run_id }}
- runner=64cpu-linux-arm64
- tag=coverage
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain (nightly)
uses: dtolnay/rust-toolchain@nightly
- name: Install llvm-tools-preview component
run: rustup component add llvm-tools-preview --toolchain nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Run coverage
run: RUST_MIN_STACK=8388608 AXIOM_FAST_TEST=1 cargo llvm-cov --json --output-path=coverage --jobs $(nproc) --profile=fast --features parallel --ignore-filename-regex 'tests|examples' --no-report
- name: Generate report
run: cargo llvm-cov --json --output-path coverage/
- name: Parse detailed coverage report
id: parse
run: |
# Initialize the markdown table header
echo "| File | Coverage | Total Lines | Covered Lines |" > coverage_table.md
echo "|--------------------|----------|-------------|---------------|" >> coverage_table.md
# Parse each file's data and append it to the table
jq -r '.files[] | "| \(.file) | \(.coverage.lines.percent)% | \(.coverage.lines.total) | \(.coverage.lines.covered) |"' coverage.json >> coverage_table.md
- name: Set markdown table as output
id: table_output
run: echo "table=$(< coverage_table.md)" >> $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.replace(/\|/g, '\\|')}`
});