Ignore non-directory entries in roles/

The check for whether a README.rst exists would naively look for
files like __init__.py/README.rst if there were files in the roles/
directory.  Only look for role directories instead.

Change-Id: I80268047a08b1294ccef841cd59894ec7133d16d
This commit is contained in:
James E. Blair 2018-09-05 10:18:18 -07:00
parent 6106a9051f
commit 8f1cecfd74
2 changed files with 5 additions and 0 deletions

3
tests/roles/__init__.py Normal file
View File

@ -0,0 +1,3 @@
# Stestr discovery in zuul-jobs requires a fully importable filesystem
# hierarchy, so simulate that by including a __init__.py file in the
# roles dir.

View File

@ -180,6 +180,8 @@ class ZuulDirective(Directive):
roles = env.domaindata['zuul']['role_paths'] roles = env.domaindata['zuul']['role_paths']
for d in role_dirs: for d in role_dirs:
for p in os.listdir(d): for p in os.listdir(d):
if not os.path.isdir(os.path.join(d, p)):
continue
role_readme = os.path.join(d, p, 'README.rst') role_readme = os.path.join(d, p, 'README.rst')
if os.path.exists(role_readme): if os.path.exists(role_readme):
roles[p] = role_readme roles[p] = role_readme