Commit 57bd0fc
Add coverage reporting to unit tests workflow (#3359)
## Motivation
Fixes #3356 (though we could keep
that issue open to track improvements)
This collects some simple coverage metrics for our Python unit tests
using [pytest-cov](https://pypi.org/project/pytest-cov/).
## Technical Details
* Coverage files are written into the `build/` directory, which is
already covered by `.gitignore`
* I experimented with using
[diff-cover](https://pypi.org/project/diff-cover/) to surface the
coverage diff from a PR in the github step summary but the output wasn't
very useful (see
https://github.com/ScottTodd/TheRock/actions/runs/21885368772#summary-63178759561
for example)
* The workflow uploads test reports to github artifacts for now. That
goes against conventions in this project to upload to AWS S3, but the
files are small and I consider this a trial. If we do upload to S3 then
the HTML reports would be easier to view (no local download needed)
* We can also set up something more production-grade like
https://about.codecov.io/
## Test Plan
* Tested in my fork at ScottTodd#6
* Tests ran on this PR:
https://github.com/ROCm/TheRock/actions/runs/21885999701?pr=3359
## Test Result
Coverage reports on e.g.
https://github.com/ScottTodd/TheRock/actions/runs/21885474484
* Sample text output:
```
---------- coverage: platform linux, python 3.12.12-final-0 ----------
Name Stmts Miss Cover Missing
-----------------------------------------------------------------------------------
analyze_build_times.py 219 219 0.00% 27-490
build_python_packages.py 46 46 0.00% 20-185
buildctl.py 206 206 0.00% 77-426
bump_submodules.py 83 83 0.00% 24-213
configure_stage.py 85 85 0.00% 29-242
export_source_archive.py 93 93 0.00% 43-206
fetch_repo.py 53 53 0.00% 7-135
fetch_sources.py 226 226 0.00% 14-600
generate_therock_manifest.py 81 81 0.00% 2-182
health_status.py 32 32 0.00% 12-88
index_generation_s3_tar.py 81 81 0.00% 23-230
install_rocm_from_artifacts.py 257 257 0.00% 107-745
linux_portable_build.py 65 65 0.00% 25-186
merge_compile_commands.py 18 18 0.00% 9-30
patch_linux_so.py 58 58 0.00% 4-109
patch_rocm_libraries.py 53 53 0.00% 23-155
patch_third_party_source.py 36 36 0.00% 12-58
posix_ccache_compiler_check.py 52 52 0.00% 31-116
print_driver_gpu_info.py 53 53 0.00% 15-137
resource_info.py 334 334 0.00% 31-774
setup_ccache.py 72 72 0.00% 24-200
teatime.py 121 121 0.00% 35-214
topology_to_cmake.py 189 189 0.00% 37-367
validate_shared_library.py 13 13 0.00% 4-20
setup_venv.py 136 93 31.62% 61-63, 68-72, 80-102, 106-113, 123-145, 183,
203, 212-217, 221-247, 255-275, 279-359
fetch_artifacts.py 122 78 36.07% 76, 113-117, 136-157, 161-249, 253-345
find_latest_artifacts.py 41 23 43.90% 76, 83, 98, 102, 113-186
find_artifacts_for_commit.py 88 45 48.86% 63, 71, 75, 79-95, 143-150,
190, 211-271
github_actions/configure_target_run.py 46 23 50.00% 52-82, 86-91
_therock_utils/hash_util.py 19 9 52.63% 8-16
github_actions/python_to_cp_version.py 21 8 61.90% 39-58
artifact_manager.py 394 149 62.18% 62, 67-72, 80-87, 92-94, 104, 106,
151, 162, 180-183, 188-205, 210-246, 256-257, 261-263, 268-269, 278,
280, 318-319, 337-340, 388, 442-480, 513, 522-524, 529-530, 547-548,
566, 568, 586, 588, 600-601, 633-634, 672-709, 714-724
github_actions/configure_ci_path_filters.py 56 20 64.29% 38-52, 66-88,
110-111, 205, 223
github_actions/configure_ci.py 275 86 68.73% 92, 120-121, 178, 213, 301,
338-340, 345, 380-383, 385-388, 491, 499, 542-676
github_actions/determine_version.py 30 9 70.00% 81-106
_therock_utils/artifacts.py 163 45 72.39% 35-40, 49-51, 55, 71, 85, 89,
114-136, 140, 144, 196, 201, 217, 231, 239, 273, 281-285, 288
_therock_utils/build_topology.py 293 76 74.06% 27, 30-32, 116-118,
126-128, 158, 189-192, 196-199, 230, 266, 287, 330, 334, 342, 346, 354,
358, 365, 372, 377, 382-383, 390-392, 483-488, 576, 588-590, 610-632,
641-646, 661-676
_therock_utils/pattern_match.py 124 30 75.81% 120-140, 149, 154, 157,
178-184, 188, 196, 203-205, 210-216, 219
fileset_tool.py 135 31 77.04% 30-31, 35-37, 58, 68, 73-74, 81, 94, 97,
111-116, 126-130, 133-134, 141-142, 147, 173-179
compute_rocm_package_version.py 92 21 77.17% 86, 151, 194, 206-266
github_actions/github_actions_utils.py 221 47 78.73% 109-110, 209-210,
268, 289-290, 301-309, 320-328, 340-350, 362-371, 496, 600, 615, 617,
650, 654-668
github_actions/fetch_package_targets.py 34 4 88.24% 91, 110, 128-129
_therock_utils/artifact_builder.py 231 16 93.07% 25, 30, 129, 135-137,
140, 159-161, 168-169, 214, 220, 325-328, 385, 470
github_actions/amdgpu_family_matrix.py 29 2 93.10% 250, 258
_therock_utils/artifact_backend.py 142 9 93.66% 49, 59, 69, 74, 80, 107,
212, 219, 287
github_actions/benchmarks/__init__.py 0 0 100.00%
github_actions/benchmarks/benchmark_test_matrix.py 7 0 100.00%
github_actions/fetch_test_configurations.py 56 0 100.00%
-----------------------------------------------------------------------------------
TOTAL 5281 3350 36.57%
Coverage HTML written to dir ../build/coverage-html
============================= 217 passed in 17.64s
=============================
```
* Sample HTML output (with interactive sorting): <img width="729"
height="741" alt="image"
src="https://github.com/user-attachments/assets/ee0b821e-e4c9-4b38-81e0-cf0ca442564c"
/>
## Submission Checklist
- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
---------
Co-authored-by: Claude <[email protected]>1 parent a658818 commit 57bd0fc
3 files changed
Lines changed: 42 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
48 | 57 | | |
49 | 58 | | |
50 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
0 commit comments