12 from termcolor
import cprint
15 def print_blue(x):
return cprint(x,
'blue', attrs=[
'bold'])
16 def print_cyan(x):
return cprint(x,
'cyan', attrs=[
'bold'])
19 def print_red(x):
return cprint(x,
'red', attrs=[
'bold'])
23 REPO_URL =
'https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config' 25 INDEX_FILE =
'index.yaml' 29 test_name =
"%(ros_distro)s_%(os_distro)s_%(os_release)s_%(arch)s" % target
32 config[
'branch'] = branch
33 config[
'test_name'] = test_name
40 print(
"Generating prerelease scripts...")
41 generate_prerelease_command =
""" 42 generate_prerelease_script.py \\ 43 https://raw.githubusercontent.com/ros-infrastructure/ros_buildfarm_config/production/index.yaml \\ 44 %(ros_distro)s default %(os_distro)s %(os_release)s %(arch)s \\ 46 async_com__custom-1:git:https://github.com/dpkoch/async_comm.git:%(branch)s \\ 51 with open(
"../%s-generate.log" % (test_name),
'w')
as log_file:
52 process = subprocess.run(
53 generate_prerelease_command, shell=
True, stdout=log_file, stderr=subprocess.STDOUT)
54 if process.returncode != 0:
61 print(
"Running prerelease tests...")
62 with open(
"../%s-test.log" % (test_name),
'w')
as log_file:
63 process = subprocess.run(
64 "./prerelease.sh", stdout=log_file, stderr=subprocess.STDOUT)
66 if process.returncode == 0:
75 url =
'/'.join([REPO_URL, BRANCH, repo_path])
76 with urllib.request.urlopen(url)
as response:
77 return response.read()
83 for ros_distro
in distros:
84 config_files = index_yaml[
'distributions'][ros_distro][
'release_builds']
85 for file_path
in config_files.values():
87 for os_distro
in config_yaml[
'targets']:
88 for os_release
in config_yaml[
'targets'][os_distro]:
89 for arch
in config_yaml[
'targets'][os_distro][os_release]:
90 targets.append({
'ros_distro': ros_distro,
91 'os_distro': os_distro,
92 'os_release': os_release,
98 def check_attribute(value, keys):
104 filtered_targets = []
105 for target
in targets:
106 if check_attribute(target[
'os_distro'], os_distro) \
107 and check_attribute(target[
'os_release'], os_release) \
108 and check_attribute(target[
'arch'], arch):
109 filtered_targets.append(target)
111 return filtered_targets
116 print_magenta(
"Running all tests for the \"%s\" branch" % (args.branch))
119 print_magenta(
"Running tests for the following ROS distros:")
120 for distro
in args.distro:
124 print(
"Retrieving release targets...")
126 args.distro), args.os, args.release, args.arch)
130 print_magenta(
"The following release targets will be tested:")
131 for target
in targets:
132 print(
"%(ros_distro)s %(os_distro)s %(os_release)s %(arch)s" % target)
139 for target
in targets:
142 "Testing %(ros_distro)s %(os_distro)s %(os_release)s %(arch)s" % target)
143 if not run_test(target, args.branch):
149 print_red(
"Failed %d of %d tests." % (failed_tests, len(targets)))
156 if __name__ ==
'__main__':
159 parser = argparse.ArgumentParser(description=
'Run ROS prerelease tests')
161 'branch', help=
'The branch for which to run the prerelease tests')
162 parser.add_argument(
'--distro',
165 default=[
'kinetic',
'melodic',
'noetic'],
166 help=
'A list of one or more ROS distros for which to run the prerelease tests (default: %(default)s)')
167 parser.add_argument(
'--os',
171 help=
'A list of one or more OS distros (e.g. ubuntu, debian) for which to run the prerelease tests')
172 parser.add_argument(
'--release',
176 help=
'A list of one or more OS releases (e.g. bionic, stretch) for which to run the prerelease tests')
177 parser.add_argument(
'--arch',
181 help=
'A list of one or more architectures (e.g. amd64, armhf) for which to run the prerelease tests')
183 args = parser.parse_args()
187 print(
"Non-empty directory; please run in an empty directory. Aborting.")
def run_test(target, branch)
def run_prerelease_tests(args)
def get_prerelease_targets(distros)
def filter_prerelease_targets(targets, os_distro, os_release, arch)
def get_repo_file(repo_path)