Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
89789e6
Enable coverage options for project in superbuild
reboss Feb 5, 2026
b7559cc
Add an example code coverage work flow
reboss Feb 9, 2026
bb78631
Add coverage step in CI
reboss Feb 9, 2026
905ff4d
remove whitespace
reboss Feb 9, 2026
ebec3d2
Rename back to projects_to_test (plural)
reboss Mar 6, 2026
5c0ece0
fix coverage-test syntax
reboss Mar 6, 2026
4ade6c6
Fix keyname
reboss Mar 6, 2026
5b538ad
[codecov] fix codecov flow
reboss Apr 2, 2026
ba9a805
[hipdnn] remove redundant -fcoverage-mapping from link options
reboss Apr 2, 2026
e0333a7
add a script to configure coverage jobs
reboss Apr 2, 2026
c85cf3b
integrate therock_configure_coverage.py with coverage workflow
reboss Apr 2, 2026
5d8ce94
produce the project name for coverage
reboss Apr 2, 2026
9de4309
configure project separately for code coverage
reboss Apr 2, 2026
499a3ee
consume project_name in test step as well
reboss Apr 2, 2026
58cf9ea
handle linting
reboss Apr 2, 2026
9f02fb0
fix linting
reboss Apr 2, 2026
b096f30
fix lint
reboss Apr 2, 2026
2921e9e
fix lint
reboss Apr 2, 2026
9bbe49c
set enable_coverage to ON
reboss Apr 2, 2026
8c0af6d
Have coverage as a standalone test matrix
reboss Apr 9, 2026
50a0e7a
WIP: Temporarily disable other test matices
reboss Apr 9, 2026
e75eee3
rename to coverage_projects for coverage
reboss Apr 14, 2026
62ba9e7
bump hashes
reboss Apr 14, 2026
e09d764
Only deploy code cov on gfx942
reboss Apr 14, 2026
74ae1ba
WIP: just hardcode coverage directory to see if it works
reboss Apr 14, 2026
b14386f
Add a mapping to project directories
reboss Apr 14, 2026
c658ed6
Build any defined project's code coverage flow
reboss Apr 14, 2026
77aef50
make sure llvm-cov and llvm-profdata are accessible
reboss Apr 14, 2026
459f3e7
bump hashes
reboss Apr 14, 2026
c966a07
use commit in TheRock that exports llvm-cov and llvm-profdata
reboss Apr 15, 2026
87dfc68
use llvm version 22
reboss Apr 15, 2026
b89ea2a
expose variables needed for code cov
reboss Apr 15, 2026
30da390
actually run on a GPU node :/
reboss Apr 16, 2026
4b36722
split build and test for coverage
reboss Apr 17, 2026
35ccdbf
bump hashes
reboss Apr 20, 2026
c7a3910
change dir name
reboss Apr 20, 2026
1dd599c
bump container images
reboss Apr 20, 2026
c20a5ef
use proper container for testing
reboss Apr 21, 2026
f6ec900
remove redundant pip install
reboss Apr 21, 2026
44505a3
align with therock-ci-linux test flow
reboss Apr 21, 2026
c8a6856
bump container image
reboss Apr 21, 2026
34a6729
Add gpu sanity check and bump hashes
reboss Apr 21, 2026
790777c
use correct build dir for coverage
reboss Apr 22, 2026
b96b7d3
try rebuilding cmake build tree
reboss Apr 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/scripts/therock_configure_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
import json
import logging
import os
from pathlib import Path

from therock_matrix import collect_projects_to_run, subtree_to_project_map
from pr_detect_changed_subtrees import get_valid_prefixes, find_matched_subtrees
from config_loader import load_repo_config
from therock_configure_ci import get_modified_paths # reuse existing helper

logging.basicConfig(level=logging.INFO)
SCRIPT_DIR = Path(__file__).resolve().parent

# Coverage-enabled projects: project key -> (cmake_target, build_subdir)
# Only projects listed here will get coverage jobs
COVERAGE_PROJECT_METADATA = {
"hipdnn": ("hipDNN", "ml-libs/hipDNN"),
"prim": ("rocPRIM", "math-libs/PRIM"),
}


def get_build_metadata(project_key: str, base_dir: str = "TheRock/build-coverage"):
"""Get CMake target and build directory for a coverage-enabled project.

Returns:
Tuple of (uppercase_name, cmake_target, build_dir) or None if not coverage-enabled
"""
if project_key not in COVERAGE_PROJECT_METADATA:
return None

cmake_target, build_subdir = COVERAGE_PROJECT_METADATA[project_key]
build_dir = f"{base_dir}/{build_subdir}/build"
return project_key.upper(), cmake_target, build_dir


def get_changed_subtrees_only():
repo_config_path = SCRIPT_DIR / ".." / "repos-config.json"
config = load_repo_config(str(repo_config_path))
valid_prefixes = get_valid_prefixes(config)

base_ref = os.environ.get("BASE_REF", "HEAD^")
modified_paths = get_modified_paths(base_ref)

matched_subtrees = find_matched_subtrees(modified_paths, valid_prefixes)
return matched_subtrees


def main():
subtrees = get_changed_subtrees_only()

changed_project_keys = set()
for subtree in subtrees:
if subtree in subtree_to_project_map:
changed_project_keys.add(subtree_to_project_map[subtree])

projects = collect_projects_to_run(subtrees)

# Filter: only keep projects that have coverage-enabled tests
coverage_projects = []
for proj in projects:
pts_list = [p for p in proj.get("projects_to_test", "").split(",") if p]

# Find primary project (prefer changed projects)
primary = pts_list[0] if pts_list else ""
for p in pts_list:
if p in changed_project_keys:
primary = p
break

# FILTER: Skip if not coverage-enabled
metadata = get_build_metadata(primary)
if metadata is None:
logging.info(f"Skipping {primary} - not coverage-enabled")
continue

# Add coverage metadata
uppercase_name, cmake_target, build_dir = metadata
proj["project_name"] = uppercase_name
proj["cmake_target"] = cmake_target
proj["build_dir"] = build_dir

coverage_projects.append(proj)

# Output for GitHub Actions
output = {
"coverage_projects": json.dumps(coverage_projects),
}
github_output = os.environ.get("GITHUB_OUTPUT")
if github_output:
with open(github_output, "a") as f:
for k, v in output.items():
f.write(f"{k}={v}\n")
else:
logging.warning("GITHUB_OUTPUT not set; printing to stdout instead")
print(json.dumps(output))


if __name__ == "__main__":
main()
229 changes: 229 additions & 0 deletions .github/workflows/therock-ci-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
name: TheRock CI Linux Coverage

on:
workflow_call:
inputs:
cmake_options:
type: string
project_name:
type: string
cmake_target:
type: string
build_dir:
type: string
amdgpu_families:
type: string
test_runs_on:
type: string

permissions:
contents: read

jobs:
therock-coverage-build:
name: Build Coverage (${{ inputs.project_name }} | ${{ inputs.amdgpu_families }})
runs-on: azure-linux-scale-rocm
permissions:
id-token: write
container:
image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:48492540591673fdc8d51beb89bde41e7ba13cbb528f643c0a481ba42c4058f2
options: -v /runner/config:/home/awsconfig/
env:
AMDGPU_FAMILIES: ${{ inputs.amdgpu_families }}
CACHE_DIR: ${{ github.workspace }}/.container-cache
CCACHE_CONFIGPATH: ${{ github.workspace }}/.ccache/ccache.conf
TEATIME_FORCE_INTERACTIVE: 0
AWS_SHARED_CREDENTIALS_FILE: /home/awsconfig/credentials.ini
steps:
- name: "Checking out repository for rocm-libraries"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Checkout TheRock repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: "ROCm/TheRock"
path: TheRock
ref: 6afcd5ac5298e9a5cdb3d2c45ae7605739ad2b94

- name: Install python deps
run: |
pip install -r TheRock/requirements.txt

- name: Adjust git config
run: |
git config --global --add safe.directory $PWD
git config fetch.parallel 10

- name: Setup ccache
run: |
./TheRock/build_tools/setup_ccache.py \
--config-preset "github-oss-dev" \
--dir "$(dirname $CCACHE_CONFIGPATH)" \
--local-path "$CACHE_DIR/ccache"

- name: Runner health status
run: |
./TheRock/build_tools/health_status.py

- name: Pull DVC files for rocm-libraries # LOGNAME details here https://github.com/ROCm/rocm-libraries/pull/1617
run: |
if command -v dvc &> /dev/null; then
echo "dvc detected"
else
echo "Warning, dvc not detected!"
fi
LOGNAME=github-runner dvc pull -v

- name: Fetch sources
timeout-minutes: 30
run: |
./TheRock/build_tools/fetch_sources.py --jobs 12 --no-include-rocm-libraries --no-include-ml-frameworks

- name: Configure coverage build
env:
amdgpu_families: ${{ env.AMDGPU_FAMILIES }}
package_version: ADHOCBUILD
extra_cmake_options: >-
-DTHEROCK_ROCM_LIBRARIES_SOURCE_DIR=../
-D${{ inputs.project_name }}_ENABLE_COVERAGE=ON
-DLLVM_TOOLS_SEARCH_PREFIX=${{ github.workspace }}/TheRock/build-coverage/dist/rocm/lib/llvm
${{ inputs.cmake_options }}
BUILD_DIR: build-coverage
run: |
python3 TheRock/build_tools/github_actions/build_configure.py

- name: Build therock-archives and therock-dist
run: cmake --build TheRock/build-coverage --target therock-archives therock-dist -- -k 0

- name: Report
if: ${{ !cancelled() }}
run: |
echo "Full SDK du:"
echo "------------"
du -h -d 1 TheRock/build-coverage/dist/rocm
echo "Artifact Archives:"
echo "------------------"
ls -lh TheRock/build-coverage/artifacts/*.tar.xz
echo "Artifacts:"
echo "----------"
du -h -d 1 TheRock/build-coverage/artifacts
echo "CCache Stats:"
echo "-------------"
ccache -s -v

- name: Configure AWS Credentials for non-forked repos
if: ${{ always() && !github.event.pull_request.head.repo.fork }}
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::692859939525:role/therock-ci-external

- name: Post Build Upload
if: always()
run: |
python3 TheRock/build_tools/github_actions/post_build_upload.py \
--run-id ${{ github.run_id }} \
--artifact-group ${{ env.AMDGPU_FAMILIES }} \
--build-dir TheRock/build-coverage \
--upload

therock-coverage-test:
name: Test Coverage (${{ inputs.project_name }} | ${{ inputs.amdgpu_families }})
needs: [therock-coverage-build]
runs-on: ${{ inputs.test_runs_on }}
if: ${{ inputs.test_runs_on != '' }}
timeout-minutes: 210
container:
image: ghcr.io/rocm/no_rocm_image_ubuntu24_04@sha256:4150afe4759d14822f0e3f8930e1124f26e11f68b5c7b91ec9a02b20b1ebbb98
options: --ipc host
--group-add video
--device /dev/kfd
--device /dev/dri
--group-add 993
--group-add 992
--group-add 110
--env-file /etc/podinfo/gha-gpu-isolation-settings
defaults:
run:
shell: bash
steps:
- name: "Checking out repository for rocm-libraries"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Checkout TheRock repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: "ROCm/TheRock"
path: TheRock
ref: 6afcd5ac5298e9a5cdb3d2c45ae7605739ad2b94

- name: Checkout rocm-libraries repository for scripts
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
path: rocm-libraries

- name: Setting up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12

- name: Install UV
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Create Python venv
env:
VENV_DIR: ${{ github.workspace }}/.venv
run: |
python TheRock/build_tools/setup_venv.py ${VENV_DIR} \
--activate-in-future-github-actions-steps \
--use-uv

- name: Install test requirements
run: |
uv pip install -r TheRock/requirements-test.txt
uv pip freeze

- name: Download and Unpack Artifacts
env:
OUTPUT_ARTIFACTS_DIR: ${{ github.workspace }}/TheRock/build-coverage
ARTIFACT_GROUP: ${{ inputs.amdgpu_families }}
AMDGPU_TARGETS: ""
ARTIFACT_RUN_ID: ${{ github.run_id }}
FETCH_ARTIFACT_ARGS: ""
RELEASE_TYPE: ""
run: |
python ./TheRock/build_tools/install_rocm_from_artifacts.py \
--run-id=${ARTIFACT_RUN_ID} \
--artifact-group=${ARTIFACT_GROUP} \
--amdgpu-targets=${AMDGPU_TARGETS} \
--output-dir=${OUTPUT_ARTIFACTS_DIR} \
${FETCH_ARTIFACT_ARGS}

- name: Driver / GPU sanity check
timeout-minutes: 3
run: |
python ./TheRock/build_tools/print_driver_gpu_info.py

- name: Reconfigure CMake for coverage
env:
amdgpu_families: ${{ inputs.amdgpu_families }}
package_version: ADHOCBUILD
extra_cmake_options: >-
-DTHEROCK_ROCM_LIBRARIES_SOURCE_DIR=../rocm-libraries/
-D${{ inputs.project_name }}_ENABLE_COVERAGE=ON
-DLLVM_TOOLS_SEARCH_PREFIX=${{ github.workspace }}/TheRock/build-coverage/dist/rocm/lib/llvm
${{ inputs.cmake_options }}
BUILD_DIR: build-coverage
working-directory: ${{ github.workspace }}/TheRock
run: |
python3 build_tools/github_actions/build_configure.py

- name: Run tests to generate profraw files
working-directory: ${{ github.workspace }}/TheRock/build-coverage
run: |
cmake --build . --target ${{ inputs.cmake_target }}+test

- name: Generate coverage report
working-directory: ${{ github.workspace }}/TheRock/build-coverage
run: |
cmake --build . --target coverage
3 changes: 1 addition & 2 deletions .github/workflows/therock-ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ on:
build_runs_on:
type: string


permissions:
contents: read

Expand Down Expand Up @@ -154,8 +155,6 @@ jobs:
therock-test-linux:
name: Test (${{ inputs.amdgpu_families }})
needs: [therock-build-linux]
# TODO(TheRock#3288): Re-enable gfx950-dcgpu runners once we get more capacity
if: ${{ inputs.amdgpu_families != 'gfx950-dcgpu' }}
uses: ./.github/workflows/therock-test-packages.yml
with:
projects_to_test: ${{ inputs.projects_to_test }}
Expand Down
Loading
Loading