Skip to content

Commit 17a1940

Browse files
committed
feat: reinstall and configure codecov from scratch
- Remove old coverage files and configuration - Add comprehensive .codecov.yml with 80% target coverage - Create coverage.sh script for local testing with HTML/LCOV output - Update CI workflow with proper grcov configuration - Add coverage documentation and update .gitignore - Exclude main.rs, lib.rs, openapi.rs from coverage analysis
1 parent 45f8f09 commit 17a1940

6 files changed

Lines changed: 137 additions & 67 deletions

File tree

.codecov.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 80%
6+
threshold: 1%
7+
patch:
8+
default:
9+
target: 80%
10+
111
ignore:
2-
- "src/lib.rs"
312
- "src/main.rs"
4-
- "src/openapi.rs"
13+
- "src/lib.rs"
14+
- "src/openapi.rs"
15+
- "target/"
16+
- "tests/"
17+
18+
comment:
19+
layout: "reach,diff,flags,tree"
20+
behavior: default
21+
require_changes: false

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ jobs:
3535
run: |
3636
cargo test --verbose
3737
# Generate coverage report
38-
grcov . --binary-path ./target/debug/ -s . -t lcov -o ./coverage.lcov
38+
grcov . \
39+
--binary-path ./target/debug/deps/ \
40+
-s . \
41+
-t lcov \
42+
--branch \
43+
--ignore-not-existing \
44+
--ignore '../*' \
45+
--ignore "/*" \
46+
--ignore 'target/*' \
47+
--ignore 'src/main.rs' \
48+
--ignore 'src/lib.rs' \
49+
--ignore 'src/openapi.rs' \
50+
-o coverage.lcov
3951
4052
- name: Upload coverage reports to Codecov
4153
uses: codecov/codecov-action@v5

.gitignore

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Rust
22
/target/
3-
**/*.rs.bk
3+
Cargo.lock
44

5-
# Env variables
5+
# Coverage
6+
coverage/
7+
*.profraw
8+
coverage.lcov
9+
10+
# Environment
611
.env
712

8-
# Coverage Reports
9-
/coverage-report/
13+
# IDE
14+
.vscode/
15+
.idea/
1016

11-
# Others
17+
# OS
1218
.DS_Store
13-
.idea/
14-
.vscode/
15-
notes
19+
Thumbs.db

COVERAGE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Code Coverage Setup
2+
3+
## Local Coverage Testing
4+
5+
Run coverage locally:
6+
```bash
7+
./coverage.sh
8+
```
9+
10+
This will:
11+
- Clean previous coverage data
12+
- Run tests with coverage instrumentation
13+
- Generate HTML report at `coverage/index.html`
14+
- Generate LCOV report at `coverage.lcov`
15+
- Open the HTML report in your browser
16+
17+
## CI/CD Integration
18+
19+
Coverage is automatically generated and uploaded to Codecov on every push/PR via GitHub Actions.
20+
21+
## Configuration Files
22+
23+
- `.codecov.yml` - Codecov configuration with 80% target coverage
24+
- `coverage.sh` - Local coverage generation script
25+
- `.github/workflows/ci.yml` - CI pipeline with coverage upload
26+
27+
## Ignored Files
28+
29+
The following files are excluded from coverage:
30+
- `src/main.rs` - Application entry point
31+
- `src/lib.rs` - Library root
32+
- `src/openapi.rs` - OpenAPI documentation
33+
- `target/` - Build artifacts
34+
- `tests/` - Test files
35+
36+
## Requirements
37+
38+
- `grcov` - Install with `cargo install grcov`
39+
- Rust nightly toolchain (for coverage instrumentation)

coverage.ps1

Lines changed: 0 additions & 52 deletions
This file was deleted.

coverage.sh

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
#!/bin/bash
2-
# For grcov:
2+
3+
# Clean previous coverage data
34
cargo clean
4-
CARGO_INCREMENTAL=0 RUSTFLAGS="-C instrument-coverage" LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw" cargo test
5-
grcov . --binary-path ./target/debug/ -s . -t html -o ./coverage-report
6-
open ./coverage-report/index.html
5+
rm -rf coverage/
6+
rm -f *.profraw
7+
8+
# Set environment variables for coverage
9+
export CARGO_INCREMENTAL=0
10+
export RUSTFLAGS="-C instrument-coverage"
11+
export LLVM_PROFILE_FILE="cargo-test-%p-%m.profraw"
12+
13+
# Run tests with coverage
14+
echo "Running tests with coverage..."
15+
cargo test
16+
17+
# Generate coverage report
18+
echo "Generating coverage report..."
19+
grcov . \
20+
--binary-path ./target/debug/deps/ \
21+
-s . \
22+
-t html \
23+
--branch \
24+
--ignore-not-existing \
25+
--ignore '../*' \
26+
--ignore "/*" \
27+
--ignore 'target/*' \
28+
--ignore 'src/main.rs' \
29+
--ignore 'src/lib.rs' \
30+
--ignore 'src/openapi.rs' \
31+
-o coverage/
32+
33+
# Generate lcov for Codecov
34+
grcov . \
35+
--binary-path ./target/debug/deps/ \
36+
-s . \
37+
-t lcov \
38+
--branch \
39+
--ignore-not-existing \
40+
--ignore '../*' \
41+
--ignore "/*" \
42+
--ignore 'target/*' \
43+
--ignore 'src/main.rs' \
44+
--ignore 'src/lib.rs' \
45+
--ignore 'src/openapi.rs' \
46+
-o coverage.lcov
47+
48+
echo "Coverage report generated at coverage/index.html"
49+
echo "LCOV report generated at coverage.lcov"
50+
51+
# Open coverage report if on macOS/Linux with GUI
52+
if command -v xdg-open > /dev/null; then
53+
xdg-open coverage/index.html
54+
elif command -v open > /dev/null; then
55+
open coverage/index.html
56+
fi

0 commit comments

Comments
 (0)