Skip to content

Commit 396bb5d

Browse files
Add Codecov support for code coverage reporting (#24)
- Add coverage job to CI workflow using cargo-tarpaulin - Create codecov.yml configuration with: - Project and patch coverage thresholds - PR comment layout configuration - Unit test flags for crates/aptos-sdk/src/ - Exclusions for examples and test files - GitHub Checks annotations enabled Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent cd8f28d commit 396bb5d

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,37 @@ jobs:
217217
- name: Check MSRV
218218
run: cargo check -p aptos-sdk
219219

220+
coverage:
221+
name: Code Coverage
222+
runs-on: ubuntu-latest
223+
steps:
224+
- uses: actions/checkout@v6
225+
226+
- name: Install Rust
227+
uses: dtolnay/rust-toolchain@master
228+
with:
229+
toolchain: "1.90"
230+
231+
- name: Cache cargo
232+
uses: Swatinem/rust-cache@v2
233+
234+
- name: Install cargo-tarpaulin
235+
run: cargo install cargo-tarpaulin
236+
237+
- name: Run coverage
238+
run: |
239+
cargo tarpaulin -p aptos-sdk --features "full" --skip-clean --out Xml --out Html --output-dir target/coverage
240+
working-directory: crates/aptos-sdk
241+
242+
- name: Upload coverage to Codecov
243+
uses: codecov/codecov-action@v5
244+
with:
245+
files: crates/aptos-sdk/target/coverage/cobertura.xml
246+
flags: unittests
247+
name: aptos-sdk-coverage
248+
fail_ci_if_error: false
249+
verbose: true
250+
220251
security-audit:
221252
name: Security Audit
222253
runs-on: ubuntu-latest

codecov.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Codecov configuration for aptos-sdk
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
4+
coverage:
5+
# Coverage status checks
6+
status:
7+
project:
8+
default:
9+
# Require coverage to not drop by more than 1%
10+
threshold: 1%
11+
# Only fail if coverage drops significantly
12+
target: auto
13+
patch:
14+
default:
15+
# New code should have at least 50% coverage
16+
target: 50%
17+
# Allow some flexibility for patches
18+
threshold: 5%
19+
20+
# Precision of coverage percentage
21+
precision: 2
22+
23+
# Round coverage percentage
24+
round: down
25+
26+
# Comment configuration for PRs
27+
comment:
28+
# Post coverage report as a PR comment
29+
layout: "reach,diff,flags,files"
30+
behavior: default
31+
require_changes: true
32+
require_base: false
33+
require_head: true
34+
35+
# Flags for different test types
36+
flags:
37+
unittests:
38+
paths:
39+
- crates/aptos-sdk/src/
40+
carryforward: true
41+
42+
# Ignore certain paths from coverage
43+
ignore:
44+
- "crates/aptos-sdk/examples/**"
45+
- "crates/aptos-sdk/tests/**"
46+
- "**/tests/**"
47+
- "**/*_test.rs"
48+
49+
# GitHub Checks annotations
50+
github_checks:
51+
annotations: true

0 commit comments

Comments
 (0)