-
-
Notifications
You must be signed in to change notification settings - Fork 4
81 lines (66 loc) · 2.31 KB
/
Copy pathcoverage.yml
File metadata and controls
81 lines (66 loc) · 2.31 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This workflow runs code coverage using cargo-llvm-cov + cargo-nextest and uploads as GitHub artifact
# No external services required
name: Coverage
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
coverage:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Add llvm-tools component
run: rustup component add llvm-tools-preview
- name: Install cargo-llvm-cov and cargo-nextest
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov,nextest
- name: Collect coverage data
run: |
cargo llvm-cov nextest \
--workspace \
--exclude loadtest \
--exclude migration \
--profile ci \
--no-report
- name: Generate coverage reports
run: |
cargo llvm-cov report --lcov --output-path lcov.info
cargo llvm-cov report --html --output-dir target/coverage/html
- name: Extract coverage percentage
id: coverage
run: |
COVERAGE=$(cargo llvm-cov report --summary-only | grep -oP '\d+\.\d+(?=%)' | tail -1)
echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT
echo "Coverage: $COVERAGE%"
- name: Upload HTML coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-html-${{ github.sha }}
path: target/coverage/html/
- name: Upload LCOV coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-lcov-${{ github.sha }}
path: lcov.info
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const coverage = '${{ steps.coverage.outputs.percentage }}';
const comment = `## Coverage Report
**Current Coverage: ${coverage}%**
📊 [View detailed HTML report](../../actions/runs/${{ github.run_id }})
Target: 60-80% coverage`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});