forked from ros/rosdistro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_build_caches.py
64 lines (55 loc) · 2.61 KB
/
test_build_caches.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from collections import OrderedDict
import os
from catkin_pkg.package import parse_package_string
from ros_buildfarm.common import topological_order_packages
from rosdistro import get_index
from rosdistro.distribution_cache_generator import generate_distribution_cache
from scripts import eol_distro_names
from .fold_block import Fold
INDEX_YAML = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'index.yaml'))
def test_build_caches():
with Fold():
print("""Checking if the 'package.xml' files for all packages are fetchable.
If this fails you can run 'rosdistro_build_cache index.yaml' to perform the same check locally.
""")
index = 'file://' + os.path.abspath(INDEX_YAML)
index = get_index(index)
dist_names = sorted(index.distributions.keys())
dist_names = [n for n in dist_names if n not in eol_distro_names]
errors = []
caches = OrderedDict()
for dist_name in dist_names:
with Fold():
try:
cache = generate_distribution_cache(index, dist_name)
except RuntimeError as e:
errors.append(str(e))
else:
caches[dist_name] = cache
# also check topological order to prevent circular dependencies
for dist_name, cache in caches.items():
# This fold is here since github actions doesn't support nested groups.
# We should remove it once it's supported.
# See: https://github.com/actions/toolkit/issues/1001
with Fold():
pkgs = {}
print("Parsing manifest files for '%s'" % dist_name)
for pkg_name, pkg_xml in cache.release_package_xmls.items():
# Collect parsing warnings and fail if version convention
# are not respected
warnings = []
pkgs[pkg_name] = parse_package_string(
pkg_xml, warnings=warnings
)
for warning in warnings:
if 'version conventions' in warning:
errors.append('%s: %s' % (pkg_name, warning))
else:
print('%s: WARNING: %s' % (pkg_name, warning))
print("Order all packages in '%s' topologically" % dist_name)
try:
topological_order_packages(pkgs)
except RuntimeError as e:
errors.append('%s: %s' % (dist_name, e))
if errors:
raise RuntimeError('\n'.join(errors))