10 from termcolor
import cprint
11 print_blue =
lambda x: cprint(x,
'blue', attrs=[
'bold'])
12 print_cyan =
lambda x: cprint(x,
'cyan', attrs=[
'bold'])
13 print_green =
lambda x: cprint(x,
'green', attrs=[
'bold'])
14 print_magenta =
lambda x: cprint(x,
'magenta', attrs=[
'bold'])
15 print_red =
lambda x: cprint(x,
'red', attrs=[
'bold'])
16 print_yellow =
lambda x: cprint(x,
'yellow', attrs=[
'bold'])
18 ROS_DISTROS = [
'kinetic',
'lunar',
'melodic']
20 REPO_URL =
'https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config' 22 INDEX_FILE =
'index.yaml' 25 test_name =
"%(ros_distro)s_%(os_distro)s_%(os_release)s_%(arch)s" % target
28 config[
'branch'] = branch
29 config[
'test_name'] = test_name
36 print(
"Generating prerelease scripts...")
37 generate_prerelease_command =
""" 38 generate_prerelease_script.py \\ 39 https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/production/index.yaml \\ 40 %(ros_distro)s default %(os_distro)s %(os_release)s %(arch)s \\ 42 async_com__custom-2:git:https://github.com/dpkoch/async_comm.git:%(branch)s \\ 47 with open(
"../%s-generate.log" % (test_name),
'w')
as log_file:
48 process = subprocess.run(generate_prerelease_command, shell=
True, stdout=log_file, stderr=subprocess.STDOUT)
49 if process.returncode != 0:
56 print(
"Running prerelease tests...")
57 with open(
"../%s-test.log" % (test_name),
'w')
as log_file:
58 process = subprocess.run(
"./prerelease.sh", stdout=log_file, stderr=subprocess.STDOUT)
60 if process.returncode == 0:
68 url =
'/'.join([REPO_URL, BRANCH, repo_path])
69 with urllib.request.urlopen(url)
as response:
70 return response.read()
75 for ros_distro
in ROS_DISTROS:
76 config_files = index_yaml[
'distributions'][ros_distro][
'release_builds']
77 for file_path
in config_files.values():
79 for os_distro
in config_yaml[
'targets']:
80 for os_release
in config_yaml[
'targets'][os_distro]:
81 for arch
in config_yaml[
'targets'][os_distro][os_release]:
82 targets.append({
'ros_distro': ros_distro, \
83 'os_distro': os_distro, \
84 'os_release': os_release, \
90 print_magenta(
"Running all tests for the \"%s\" branch" % (branch))
94 for distro
in ROS_DISTROS:
98 print(
"Retrieving release targets...")
102 print_magenta(
"The following release targets will be tested:")
103 for target
in targets:
104 print(
"%(ros_distro)s %(os_distro)s %(os_release)s %(arch)s" % target)
108 for target
in targets:
110 print_blue(
"Testing %(ros_distro)s %(os_distro)s %(os_release)s %(arch)s" % target)
117 print_red(
"Failed %d of %d tests." % (failed_tests, len(targets)))
123 if __name__ ==
'__main__':
126 if len(sys.argv) != 2:
127 print(
"Usage: %s <branch>" % (sys.argv[0]))
133 print(
"Non-empty directory, please run in an empty directory. Aborting.")
def run_test(target, branch)
def run_prerelease_tests(branch)
def get_prerelease_targets()
def get_repo_file(repo_path)