Repository navigation
Conversation
Adds the test side of TheRock's code coverage support, split out of the
code coverage PR (7783) so it can be reviewed on its own. It does not
depend on the build part (8598).
- install_rocm_code_coverage_build.py: --code-coverage-run-github-repo
and --code-coverage-release-type, so the instrumented replacement
artifacts can come from a different repository and release channel
than the baseline install. create_backend_from_env takes the matching
release_type.
- merge_coverage_report.py: merges the .profraw files from a test run
into .profdata and writes an lcov report, a per-file text summary and
an annotated HTML report, using the llvm-profdata and llvm-cov from the
installed ROCm tree. Unit tested.
- test_code_coverage_component.yml: baseline_repository input, falls
back to this run's own artifacts when generic_run_id is empty, sets up
Python 3.12, and skips additional requirements cleanly when there are
none.
- setup_test_environment: optional RUN_GITHUB_REPO input, forwarded to
install_rocm_from_artifacts.py as --run-github-repo.
- artifact_manager.py fetch: optional --artifact-names include list.
test_code_coverage_component.yml also moves three ${{ inputs.* }}
expansions out of its run: block into environment variables and marks
its container image expression as reviewed for zizmor. Those findings
are already on main and fail the security scan for any PR that touches
the file; every image the expression can resolve to is digest-pinned.
Co-authored-by: Cursor <cursoragent@cursor.com>
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
ScottTodd
left a comment
There was a problem hiding this comment.
I'll wait to review this until someone else makes a first pass review.
…mespace Fixes the failing Linux CodeCoverage jobs in the rocm-libraries nightly (run 36913152797): - Instrumented subprojects no longer compile through ccache. ccache drops every -Xarch_<arch> <arg> pair, which removed the device-side negation (kernels were instrumented, and their colon-named profiles broke the profraw upload) and rocRAND's and hipRAND's -Xarch_host coverage flags (those libraries were not instrumented at all). - The instrumented stack publishes under <run_id>-coverage. The nightly's regular build shares the workflow run, and the two overwrote each other's math-libs artifacts. WorkflowOutputRoot looks a suffixed run id up by its numeric part. - external_repo_config is forwarded to the coverage builds, which otherwise measured TheRock's pinned submodules rather than the commit under test. - rocWMMA's coverage option is ROCWMMA_CODE_COVERAGE. rocPRIM, hipCUB and rocThrust report on their own test binaries; a "!" glob excludes a sibling project's. - Coverage test timeouts are 4x the release ones, capped at 180 minutes. - Device-side profiles are dropped, with a warning, before upload. - merge_coverage_report.py fails a report whose profiles hold no counters, whose objects carry no coverage mapping, or in which no line ran, instead of publishing 0%. Ported from #7783 onto the split #8598/#8602/#8605 stack: the registry entries keep #8598's derived stage/test_component/coverage_config, the report's run id goes through env like the rest of the step, the external_repo_config input this PR had already added is merged with this one, and copy_compiler_runtime writes into the same <run_id>-coverage namespace. (cherry picked from commit 8523c5a) Co-authored-by: Cursor <cursoragent@cursor.com>
@endurthiabhilash , Done |
| python3 build_tools/install_rocm_code_coverage_build.py \ | ||
| --code-coverage-run-id="${CODE_COVERAGE_RUN_ID}" \ | ||
| --run-id="${GENERIC_RUN_ID}" \ | ||
| --artifact-group="${AMDGPU_FAMILIES}" \ |
There was a problem hiding this comment.
The baseline_repository input is never used. The step sets BASELINE_REPOSITORY in env, but the command line passes no --run-github-repo so, the baseline fetch therefore still queries generic_run_id against the current repo. This seems like a regression from mainline rebase. Please check.
There was a problem hiding this comment.
This regressed in the main merge: resolving the conflict with #8680's security changes kept main's install command, which dropped the --run-github-repo forwarding and also the fallback for an empty generic_run_id (that case was passing --run-id=). 3b6c4de restores both, using environment variables the way main now does, plus the additional_requirements_files[0] skip that was lost the same way. Through a stub installer, a cross-repo baseline now gets --run-github-repo=<repo>, a same-repo baseline gets no extra argument, and an empty generic_run_id falls back to this run's ID.
… merge Resolving the main-merge conflict with #8680's security changes kept main's install command. baseline_repository was then set in the step env but never passed as --run-github-repo, so a cross-repo baseline was looked up in the current repository, and an empty generic_run_id went through as --run-id= instead of falling back to this run's own artifacts. Restore both in the env-var form main now uses, along with the first-element check that skips Setup Additional Requirements when a component has none, and drop the step-level GENERIC_RUN_ID that the job env already sets. Co-authored-by: Cursor <cursoragent@cursor.com>
Motivation
GitHub issue: #6572
This is the test part of TheRock's code coverage support, split out of the code coverage PR (7783) so it can be reviewed on its own. It covers installing an instrumented build for a test job, running the tests with profile collection, and turning the collected profiles into coverage reports. It does not depend on the build part (#8598); the coverage CI workflows that call it follow in a separate PR.
Technical Details
build_tools/install_rocm_code_coverage_build.py: adds--code-coverage-run-github-repoand--code-coverage-release-type, so the instrumented replacement artifacts can come from a different repository and release channel than the baseline install (--run-id/--run-github-repo). The defaults are$GITHUB_REPOSITORYandci.create_backend_from_envin_therock_utils/artifact_backend.pytakes the matchingrelease_type.build_tools/github_actions/merge_coverage_report.py(new): merges the.profrawfiles from a test run into.profdata, then writes an lcov report, a per-file text summary and an optional annotated HTML report. It usesllvm-profdataandllvm-covfrom the installed ROCm tree, so the tools match the compiler that built the objects..github/workflows/test_code_coverage_component.yml:baseline_repositoryinput, forwarded as--run-github-repo;generic_run_idis empty;${{ inputs.* }}expansions out of itsrun:block into environment variables, and marks the container image expression as reviewed for zizmor. These six findings are already onmainand fail the security scan for any PR that touches this file. Every image the expression can resolve to is digest-pinned..github/actions/setup_test_environment/action.yml: optionalRUN_GITHUB_REPOinput, forwarded toinstall_rocm_from_artifacts.pyas--run-github-repo. Empty by default.build_tools/artifact_manager.py:fetch --artifact-namesnarrows a stage fetch to a named set of artifacts. Empty by default.Producing a report locally after running an instrumented project's tests:
Test Plan
build_toolsandtest_tools(Python 3.12), including the newinstall_rocm_code_coverage_build_test.pyandmerge_coverage_report_test.pyand the newartifact_manager_tool_test.pycases.pre-commit run --all-files, and zizmor 1.30.0 on the changed workflow and action with the repository's config.install_rocm_code_coverage_build.py, run hipRAND's tests withLLVM_PROFILE_FILEset, and generate the lcov, text and HTML reports withmerge_coverage_report.py.artifact_manager.pyin every build job andsetup_test_environmentin every test job.Test Result
build_tools: 2467 passed, 8 skipped.test_tools: 74 passed. Tests for the changed modules: 104 passed.install_rocm_code_coverage_build.pyinstalled the baseline from a ROCm/TheRock CI run (36550488477) and replaced hipDNN from the instrumented ROCm/rocm-libraries coverage run 36168158239, which--code-coverage-run-github-reporesolved totherock-ci-artifacts-external. Only hipDNN's paths were replaced:libhipdnn_backend.socarries the profile sections andlibamdhip64.sodoes not. Looking the same run up against ROCm/TheRock finds 0 artifacts.LLVM_PROFILE_FILEset, writing 39.profrawfiles.merge_coverage_report.py: lcov for 183 source files, the text summary, and a 181-page HTML report using--path-equivalence. Totals are 81.09% of lines, 75.42% of functions, 83.92% of regions and 80.07% of branches, identical to that run's own Coverage Report job.test_code_coverage_component.yml, run with a stub installer, assembles the right arguments both with and without a cross-repo baseline.Submission Checklist