-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 3.56 KB
/
code-coverage.yml
File metadata and controls
101 lines (85 loc) · 3.56 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Code Coverage
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'assets/**/*.png'
- 'assets/**/*.jpg'
- 'assets/**/*.svg'
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
- 'assets/**/*.png'
- 'assets/**/*.jpg'
- 'assets/**/*.svg'
workflow_dispatch: # Allow manual triggering
env:
CARGO_TERM_COLOR: always
jobs:
coverage:
name: Test Coverage
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-tarpaulin
uses: taiki-e/install-action@v2
with:
tool: cargo-tarpaulin
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Generate coverage report
run: |
cargo tarpaulin --verbose --workspace --timeout 300 --out Xml --output-dir ./coverage --skip-clean --exclude-files="target/*" --exclude-files="examples/*"
- name: Generate HTML coverage report
run: |
cargo tarpaulin --verbose --workspace --timeout 300 --out Html --output-dir ./coverage/html --skip-clean --exclude-files="target/*" --exclude-files="examples/*"
- name: Generate component-specific coverage reports
run: |
# UI components coverage
cargo tarpaulin --verbose --workspace --timeout 300 --out Json --output-dir ./coverage/components --skip-clean --exclude-files="target/*" --exclude-files="examples/*" --packages rustpods --lib --tests -- tests::ui::components
# Bluetooth module coverage
cargo tarpaulin --verbose --workspace --timeout 300 --out Json --output-dir ./coverage/bluetooth --skip-clean --exclude-files="target/*" --exclude-files="examples/*" --packages rustpods --lib --tests -- tests::bluetooth
- name: List coverage directory contents
run: |
Get-ChildItem ./coverage -Recurse | Where-Object { !$_.PSIsContainer } | Select-Object FullName, Length
Write-Output "Cobertura.xml size:"
(Get-Content ./coverage/cobertura.xml | Measure-Object -Line).Lines
Write-Output "First 10 lines of cobertura.xml:"
Get-Content ./coverage/cobertura.xml | Select-Object -First 10
- name: Set up Python (required for Codecov)
uses: actions/setup-python@v5
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
with:
files: ./coverage/cobertura.xml
fail_ci_if_error: false
verbose: true
name: rustpods-coverage
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: ./coverage
retention-days: 30
continue-on-error: true
- name: Check coverage thresholds
run: |
# Extract total coverage percentage from the JSON report
$jsonReport = Get-Content -Path ./coverage/components/tarpaulin-report.json | ConvertFrom-Json
$uiCoverage = $jsonReport.percentage
# Check UI components coverage
if ($uiCoverage -lt 75) {
Write-Error "UI components test coverage ($uiCoverage%) is below the required threshold (75%)"
exit 1
} else {
Write-Output "UI components test coverage: $uiCoverage% (threshold: 75%)"
}
continue-on-error: true