CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
313 lines
9.2 KiB
Python
Executable File
313 lines
9.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import argparse
|
|
import multiprocessing
|
|
import os
|
|
import re
|
|
import shutil
|
|
import socket
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def which(cmd, require):
|
|
v = shutil.which(cmd)
|
|
if require and v is None:
|
|
raise RuntimeError(f"{cmd} not found")
|
|
return v if v is not None else ""
|
|
|
|
|
|
def generate_custom(args, cmake_args, ctest_args):
|
|
if not os.path.exists(args.binary_dir):
|
|
os.makedirs(args.binary_dir)
|
|
|
|
NAME = args.name
|
|
SITE = args.site
|
|
BUILD_JOBS = args.build_jobs
|
|
SUBMIT_URL = args.submit_url
|
|
SOURCE_DIR = os.path.realpath(args.source_dir)
|
|
BINARY_DIR = os.path.realpath(args.binary_dir)
|
|
CMAKE_ARGS = " ".join(cmake_args)
|
|
CTEST_ARGS = " ".join(ctest_args)
|
|
|
|
GIT_CMD = which("git", require=True)
|
|
GCOV_CMD = which("gcov", require=False)
|
|
CMAKE_CMD = which("cmake", require=True)
|
|
_ = which("ctest", require=True)
|
|
|
|
# For Continuous builds transform to PR_XXXX format and include the actor
|
|
match = re.match(r"(.*)-([0-9]+)/merge(.*)", NAME)
|
|
if match and args.actor:
|
|
NAME = f"[{args.actor}] PR_{match.group(2)}_{match.group(1)}{match.group(3)}"
|
|
elif match:
|
|
NAME = f"PR_{match.group(2)}_{match.group(1)}{match.group(3)}"
|
|
|
|
return f"""
|
|
set(CTEST_PROJECT_NAME "rocprofiler-compute")
|
|
set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC")
|
|
|
|
set(CTEST_DROP_METHOD "http")
|
|
set(CTEST_DROP_SITE_CDASH TRUE)
|
|
set(CTEST_SUBMIT_URL "https://{SUBMIT_URL}")
|
|
|
|
set(CTEST_UPDATE_TYPE git)
|
|
set(CTEST_UPDATE_VERSION_ONLY TRUE)
|
|
set(CTEST_GIT_INIT_SUBMODULES TRUE)
|
|
|
|
set(CTEST_OUTPUT_ON_FAILURE TRUE)
|
|
set(CTEST_USE_LAUNCHERS TRUE)
|
|
set(CMAKE_CTEST_ARGUMENTS --output-on-failure {CTEST_ARGS})
|
|
|
|
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS "100")
|
|
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS "100")
|
|
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "51200")
|
|
set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/usr/.*;.*external/.*;.*examples/.*")
|
|
|
|
set(CTEST_SITE "{SITE}")
|
|
set(CTEST_BUILD_NAME "{NAME}")
|
|
|
|
set(CTEST_SOURCE_DIRECTORY {SOURCE_DIR})
|
|
set(CTEST_BINARY_DIRECTORY {BINARY_DIR})
|
|
|
|
set(CTEST_UPDATE_COMMAND {GIT_CMD})
|
|
set(CTEST_CONFIGURE_COMMAND "{CMAKE_CMD} -B {BINARY_DIR} {SOURCE_DIR} \
|
|
{CMAKE_ARGS}")
|
|
set(CTEST_BUILD_COMMAND "{CMAKE_CMD} --build {BINARY_DIR} --target all \
|
|
--parallel {BUILD_JOBS}")
|
|
set(CTEST_COVERAGE_COMMAND {GCOV_CMD})
|
|
"""
|
|
|
|
|
|
def generate_dashboard_script(args):
|
|
CODECOV = 1 if args.coverage else 0
|
|
DASHBOARD_MODE = args.mode
|
|
SOURCE_DIR = os.path.realpath(args.source_dir)
|
|
BINARY_DIR = os.path.realpath(args.binary_dir)
|
|
|
|
_script = """
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/CTestCustom.cmake")
|
|
|
|
macro(handle_error _message _ret)
|
|
if(NOT ${${_ret}} EQUAL 0)
|
|
ctest_submit(PARTS Done RETURN_VALUE _submit_ret)
|
|
message(FATAL_ERROR "${_message} failed: ${${_ret}}")
|
|
endif()
|
|
endmacro()
|
|
"""
|
|
|
|
_script += f"""
|
|
ctest_start({DASHBOARD_MODE})
|
|
ctest_update(SOURCE "{SOURCE_DIR}")
|
|
ctest_configure(BUILD "{BINARY_DIR}" RETURN_VALUE _configure_ret)
|
|
ctest_submit(PARTS Start Update Configure RETURN_VALUE _submit_ret)
|
|
|
|
handle_error("Configure" _configure_ret)
|
|
|
|
ctest_build(BUILD "{BINARY_DIR}" RETURN_VALUE _build_ret)
|
|
ctest_submit(PARTS Build RETURN_VALUE _submit_ret)
|
|
|
|
handle_error("Build" _build_ret)
|
|
|
|
ctest_test(BUILD "{BINARY_DIR}" RETURN_VALUE _test_ret)
|
|
ctest_submit(PARTS Test RETURN_VALUE _submit_ret)
|
|
|
|
if("{CODECOV}" GREATER 0)
|
|
ctest_coverage(
|
|
BUILD "{BINARY_DIR}"
|
|
RETURN_VALUE _coverage_ret
|
|
CAPTURE_CMAKE_ERROR _coverage_err)
|
|
ctest_submit(PARTS Coverage RETURN_VALUE _submit_ret)
|
|
endif()
|
|
|
|
ctest_submit(PARTS Done RETURN_VALUE _submit_ret)
|
|
|
|
# After all submissions complete, fail if tests failed
|
|
if(NOT ${{_test_ret}} EQUAL 0)
|
|
message(FATAL_ERROR "Some tests failed (see CDash for details)")
|
|
endif()
|
|
"""
|
|
return _script
|
|
|
|
|
|
def parse_cdash_args(args):
|
|
BUILD_JOBS = multiprocessing.cpu_count()
|
|
DASHBOARD_MODE = "Continuous"
|
|
DASHBOARD_STAGES = [
|
|
"Start",
|
|
"Update",
|
|
"Configure",
|
|
"Build",
|
|
"Test",
|
|
"Coverage",
|
|
"Submit",
|
|
]
|
|
SOURCE_DIR = os.getcwd()
|
|
BINARY_DIR = os.path.join(SOURCE_DIR, "build")
|
|
SITE = socket.gethostname()
|
|
SUBMIT_URL = "my.cdash.org/submit.php?project=rocprofiler-compute"
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument(
|
|
"-n", "--name", help="Job name", default=None, type=str, required=True
|
|
)
|
|
parser.add_argument(
|
|
"-a",
|
|
"--actor",
|
|
help="GitHub actor/username (included in Continuous builds)",
|
|
default=None,
|
|
type=str,
|
|
)
|
|
parser.add_argument("-s", "--site", help="Site name", default=SITE, type=str)
|
|
parser.add_argument(
|
|
"-c", "--coverage", help="Enable code coverage", action="store_true"
|
|
)
|
|
parser.add_argument(
|
|
"-j", "--build-jobs", help="Number of build tasks", default=BUILD_JOBS, type=int
|
|
)
|
|
parser.add_argument(
|
|
"-B", "--binary-dir", help="Build directory", default=BINARY_DIR, type=str
|
|
)
|
|
parser.add_argument(
|
|
"-S", "--source-dir", help="Source directory", default=SOURCE_DIR, type=str
|
|
)
|
|
parser.add_argument(
|
|
"-M",
|
|
"--mode",
|
|
help="Dashboard mode",
|
|
default=DASHBOARD_MODE,
|
|
choices=("Continuous", "Nightly", "Experimental"),
|
|
type=str,
|
|
)
|
|
parser.add_argument(
|
|
"-T",
|
|
"--stages",
|
|
help="Dashboard stages",
|
|
nargs="+",
|
|
default=DASHBOARD_STAGES,
|
|
choices=DASHBOARD_STAGES,
|
|
type=str,
|
|
)
|
|
parser.add_argument(
|
|
"--submit-url", help="CDash submission site", default=SUBMIT_URL, type=str
|
|
)
|
|
parser.add_argument(
|
|
"--repeat-until-pass",
|
|
help="<N> for --repeat until-pass:<N>",
|
|
default=3,
|
|
type=int,
|
|
)
|
|
parser.add_argument(
|
|
"--repeat-until-fail",
|
|
help="<N> for --repeat until-fail:<N>",
|
|
default=None,
|
|
type=int,
|
|
)
|
|
parser.add_argument(
|
|
"--repeat-after-timeout",
|
|
help="<N> for --repeat after-timeout:<N>",
|
|
default=2,
|
|
type=int,
|
|
)
|
|
|
|
return parser.parse_args(args)
|
|
|
|
|
|
def parse_args(args=None):
|
|
if args is None:
|
|
args = sys.argv[1:]
|
|
|
|
index = 0
|
|
input_args = []
|
|
ctest_args = []
|
|
cmake_args = []
|
|
data = [input_args, cmake_args, ctest_args]
|
|
|
|
for itr in args:
|
|
if itr == "--":
|
|
index += 1
|
|
if index > 2:
|
|
raise RuntimeError("Usage: <options> -- <ctest-args> -- <cdash-args>")
|
|
else:
|
|
data[index].append(itr)
|
|
|
|
cdash_args = parse_cdash_args(input_args)
|
|
|
|
if cdash_args.coverage:
|
|
cmake_args += ["-DENABLE_COVERAGE=ON"]
|
|
|
|
def get_repeat_val(_param):
|
|
_value = getattr(cdash_args, f"repeat_{_param}".replace("-", "_"))
|
|
return [f"{_param}:{_value}"] if _value is not None and _value > 1 else []
|
|
|
|
repeat_args = (
|
|
get_repeat_val("until-pass")
|
|
+ get_repeat_val("until-fail")
|
|
+ get_repeat_val("after-timeout")
|
|
)
|
|
ctest_args += ["--repeat"] + repeat_args if len(repeat_args) > 0 else []
|
|
|
|
return [cdash_args, cmake_args, ctest_args]
|
|
|
|
|
|
def run(*args, **kwargs):
|
|
import subprocess
|
|
|
|
return subprocess.run(*args, **kwargs)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args, cmake_args, ctest_args = parse_args()
|
|
|
|
if not os.path.exists(args.binary_dir):
|
|
os.makedirs(args.binary_dir)
|
|
|
|
from textwrap import dedent
|
|
|
|
_config = dedent(generate_custom(args, cmake_args, ctest_args))
|
|
_script = dedent(generate_dashboard_script(args))
|
|
|
|
with open(os.path.join(args.binary_dir, "CTestCustom.cmake"), "w") as f:
|
|
f.write(f"{_config}\n")
|
|
|
|
with open(os.path.join(args.binary_dir, "dashboard.cmake"), "w") as f:
|
|
f.write(f"{_script}\n")
|
|
|
|
CTEST_CMD = which("ctest", require=True)
|
|
|
|
dashboard_args = ["-D"]
|
|
for itr in args.stages:
|
|
dashboard_args.append(f"{args.mode}{itr}")
|
|
|
|
try:
|
|
run(
|
|
[CTEST_CMD]
|
|
+ dashboard_args
|
|
+ [
|
|
"-S",
|
|
os.path.join(args.binary_dir, "dashboard.cmake"),
|
|
"--output-on-failure",
|
|
"-V",
|
|
]
|
|
+ ctest_args,
|
|
check=True,
|
|
)
|
|
finally:
|
|
if "-VV" not in ctest_args:
|
|
for file in Path(args.binary_dir, "Testing").rglob("*"):
|
|
if not file.is_file():
|
|
continue
|
|
print(f"\n\n\n###### Reading {file}... ######\n\n\n")
|
|
fdata = file.read_text()
|
|
if "LastTest" not in str(file) and "Coverage" not in str(file):
|
|
print(fdata)
|
|
oname = file.name
|
|
if oname.endswith(".log"):
|
|
oname += ".log"
|
|
out_path = Path(args.binary_dir) / oname
|
|
print(f"\n\n###### Writing {oname}... ######\n\n")
|
|
out_path.write_text(fdata)
|