Merge "Extract announce info from deliverable file"

This commit is contained in:
Zuul 2019-03-27 11:00:37 +00:00 committed by Gerrit Code Review
commit e3675b362a

View File

@ -25,6 +25,7 @@ from reno import formatter
from reno import loader from reno import loader
from openstack_releases import rst2txt from openstack_releases import rst2txt
from openstack_releases import yamlutils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -103,7 +104,7 @@ Download the package from:
{% endif %} {% endif %}
{% if bug_url %} {% if bug_url %}
Please report issues through launchpad: Please report issues through:
{{ bug_url }} {{ bug_url }}
{% endif %} {% endif %}
@ -158,13 +159,13 @@ cycle is available! You can find the source code tarball at:
Unless release-critical issues are found that warrant a release Unless release-critical issues are found that warrant a release
candidate respin, this candidate will be formally released as the candidate respin, this candidate will be formally released as the
final {{series|capitalize}} release. You are therefore strongly final {{series|capitalize}} release. You are therefore strongly encouraged
encouraged to test and validate this tarball! to test and validate this tarball!
Alternatively, you can directly test the stable/{{series|lower}} release Alternatively, you can directly test the stable/{{series|lower}} release
branch at: branch at:
https://git.openstack.org/cgit/openstack/{{publishing_dir_name}}/log/?h=stable/{{series|lower}} {{source_url}}/log/?h=stable/{{series|lower}}
Release notes for {{project}} can be found at: Release notes for {{project}} can be found at:
@ -182,39 +183,46 @@ release crew's attention.
""" """
def parse_readme(repo_path): def parse_deliverable(series, repo):
"""Parse useful information out of the deliverable file.
Currently only parses the bug URL, but could potentially be expanded to get
other useful settings.
:param series: The release series being processed.
:param repo: The name of the deliverable.
"""
release_repo = os.path.realpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
deliverable_path = os.path.join(
release_repo, 'deliverables', series.lower(), "%s.yaml" % repo)
# Hard coding source URL for now
sections = { sections = {
'bug_url': '', 'bug_url': '',
'source_url': '', 'source_url': 'https://git.openstack.org/cgit/openstack/%s' % repo,
} }
readme_formats = ['rst', 'md']
for k in readme_formats: try:
readme_path = os.path.join(repo_path, 'README.%s' % k) with open(deliverable_path, 'r') as d:
try: deliverable_info = yamlutils.loads(d)
f = open(readme_path, 'r', encoding='utf-8') except Exception:
f.close() # TODO(smcginnis): If the deliverable doesn't match the repo name, we
break # can try to find it by loading all deliverable data and iterating on
except IOError: # each deliverables repos to find it.
continue LOG.warning('Unable to parse %s %s deliverable file', repo, series)
else:
LOG.warning("No README file found in %s\n"
% repo_path)
return sections return sections
with open(readme_path, 'r', encoding='utf-8') as fh: if deliverable_info.get('launchpad'):
for line in fh: sections['bug_url'] = (
for (name, key_name) in [("Bugs:", "bug_url"), 'https://bugs.launchpad.net/%s/+bugs' %
("Source:", 'source_url')]: deliverable_info['launchpad'])
pieces = line.split(name, 1) elif deliverable_info.get('storyboard'):
if len(pieces) == 2: sections['bug_url'] = (
candidate = pieces[1].strip() 'https://storyboard.openstack.org/#!/project/%s' %
if 'http' in candidate: deliverable_info['storyboard'])
sections[key_name] = candidate
for (k, v) in sections.items():
if not v:
what = k.replace("_", " ")
LOG.warning("No %s found in '%s'\n"
% (what, readme_path))
return sections return sections
@ -326,8 +334,8 @@ def generate_release_notes(repo, repo_path,
continue continue
diff_stats.append(line) diff_stats.append(line)
# Extract + valdiate needed sections from readme... # Extract + valdiate needed sections...
readme_sections = parse_readme(repo_path) sections = parse_deliverable(series, publishing_dir_name)
change_header = ["Changes in %s %s" % (repo_name, git_range)] change_header = ["Changes in %s %s" % (repo_name, git_range)]
change_header.append("-" * len(change_header[0])) change_header.append("-" * len(change_header[0]))
@ -368,7 +376,7 @@ def generate_release_notes(repo, repo_path,
elif is_release_candidate: elif is_release_candidate:
email_to = 'openstack-discuss@lists.openstack.org' email_to = 'openstack-discuss@lists.openstack.org'
params = dict(readme_sections) params = dict(sections)
params.update({ params.update({
'project': repo_name, 'project': repo_name,
'description': description, 'description': description,