Merge "add verbose mode to new-release"

This commit is contained in:
Zuul
2018-09-21 14:28:53 +00:00
committed by Gerrit Code Review

View File

@@ -16,8 +16,10 @@ from __future__ import print_function
import argparse import argparse
import atexit import atexit
import logging
import os import os
import shutil import shutil
import sys
import tempfile import tempfile
from openstack_releases import gitutils from openstack_releases import gitutils
@@ -27,6 +29,8 @@ from openstack_releases import yamlutils
# Release models that support release candidates. # Release models that support release candidates.
_USES_RCS = ['cycle-with-milestones', 'cycle-trailing'] _USES_RCS = ['cycle-with-milestones', 'cycle-trailing']
LOG = logging.getLogger('')
def get_deliverable_data(series, deliverable): def get_deliverable_data(series, deliverable):
deliverable_filename = 'deliverables/%s/%s.yaml' % ( deliverable_filename = 'deliverables/%s/%s.yaml' % (
@@ -117,16 +121,18 @@ def get_release_history(series, deliverable):
else: else:
status = series_status.SeriesStatus.default() status = series_status.SeriesStatus.default()
all_series = list(status.names) all_series = list(status.names)
LOG.debug('all series %s', all_series)
included_series = all_series[all_series.index(series):] included_series = all_series[all_series.index(series):]
release_history = [] release_history = []
LOG.debug('building release history')
for current_series in included_series: for current_series in included_series:
try: try:
deliv_info = get_deliverable_data(current_series, deliverable) deliv_info = get_deliverable_data(current_series, deliverable)
releases = deliv_info['releases'] releases = deliv_info['releases']
except (IOError, OSError, KeyError): except (IOError, OSError, KeyError):
print('No releases for %s in %s, yet.' % (
deliverable, series))
releases = [] releases = []
LOG.debug('%s releases: %s', current_series,
[r['version'] for r in releases])
release_history.append(releases) release_history.append(releases)
return release_history return release_history
@@ -134,7 +140,10 @@ def get_release_history(series, deliverable):
def get_last_release(release_history, deliverable, release_type): def get_last_release(release_history, deliverable, release_type):
depth = 0 depth = 0
for releases in release_history: for releases in release_history:
LOG.debug('looking for previous version in %s',
[r['version'] for r in releases])
if releases: if releases:
LOG.debug('using %s', releases[-1]['version'])
return dict({'depth': depth}, **releases[-1]) return dict({'depth': depth}, **releases[-1])
elif release_type == 'bugfix': elif release_type == 'bugfix':
raise RuntimeError( raise RuntimeError(
@@ -156,7 +165,12 @@ def main():
'deliverable', 'deliverable',
help='the base name of the deliverable file', help='the base name of the deliverable file',
) )
# FIXME(dhellmann): Add milestone and rc types. parser.add_argument(
'-v', '--verbose',
default=False,
action='store_true',
help='be more chatty',
)
parser.add_argument( parser.add_argument(
'release_type', 'release_type',
choices=('bugfix', 'feature', 'major', 'milestone', 'rc', choices=('bugfix', 'feature', 'major', 'milestone', 'rc',
@@ -191,12 +205,20 @@ def main():
) )
args = parser.parse_args() args = parser.parse_args()
# Set up logging, including making some loggers quiet.
logging.basicConfig(
format='%(levelname)7s: %(message)s',
stream=sys.stdout,
level=logging.DEBUG if args.verbose else logging.INFO,
)
logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING)
is_procedural = args.release_type == 'procedural' is_procedural = args.release_type == 'procedural'
is_eol = args.release_type == 'eol' is_eol = args.release_type == 'eol'
force_tag = args.force force_tag = args.force
workdir = tempfile.mkdtemp(prefix='releases-') workdir = tempfile.mkdtemp(prefix='releases-')
print('creating temporary files in %s' % workdir) LOG.info('creating temporary files in %s', workdir)
def error(msg): def error(msg):
if args.debug: if args.debug:
@@ -233,6 +255,7 @@ def main():
except RuntimeError as err: except RuntimeError as err:
error(err) error(err)
last_version = last_release['version'].split('.') last_version = last_release['version'].split('.')
LOG.debug('last_version %r', last_version)
add_stable_branch = args.stable_branch or is_procedural add_stable_branch = args.stable_branch or is_procedural
if args.release_type in ('milestone', 'rc'): if args.release_type in ('milestone', 'rc'):
@@ -242,6 +265,8 @@ def main():
deliverable_info['release-model'], args.deliverable)) deliverable_info['release-model'], args.deliverable))
new_version_parts = increment_milestone_version( new_version_parts = increment_milestone_version(
last_version, args.release_type) last_version, args.release_type)
LOG.debug('computed new version %s release type %s',
new_version_parts, args.release_type)
# We are going to take some special steps for the first # We are going to take some special steps for the first
# release candidate, so figure out if that is what this # release candidate, so figure out if that is what this
# release will be. # release will be.
@@ -276,7 +301,7 @@ def main():
series) series)
) )
if last_version != last_branch_base: if last_version != last_branch_base:
print('WARNING: last_version {} branch base {}'.format( LOG.warning('last_version {} branch base {}'.format(
'.'.join(last_version), '.'.join(last_branch_base))) '.'.join(last_version), '.'.join(last_branch_base)))
for r in prev_info['releases']: for r in prev_info['releases']:
if r['version'] == '.'.join(last_branch_base): if r['version'] == '.'.join(last_branch_base):
@@ -304,6 +329,7 @@ def main():
'major': (1, 0, 0), 'major': (1, 0, 0),
}[args.release_type] }[args.release_type]
new_version_parts = increment_version(last_version, increment) new_version_parts = increment_version(last_version, increment)
LOG.debug('computed new version %s', new_version_parts)
if new_version_parts is not None: if new_version_parts is not None:
# The EOL tag version string is computed above and the parts # The EOL tag version string is computed above and the parts
@@ -313,12 +339,12 @@ def main():
if 'releases' not in deliverable_info: if 'releases' not in deliverable_info:
deliverable_info['releases'] = [] deliverable_info['releases'] = []
print('going from %s to %s' % (last_version, new_version)) LOG.info('going from %s to %s' % (last_version, new_version))
projects = [] projects = []
changes = 0 changes = 0
for repo in deliverable_info['repository-settings'].keys(): for repo in deliverable_info['repository-settings'].keys():
print('processing {}'.format(repo)) LOG.info('processing {}'.format(repo))
# Look for the most recent time the repo was tagged and use # Look for the most recent time the repo was tagged and use
# that info as the old sha. # that info as the old sha.
@@ -330,7 +356,7 @@ def main():
if project['repo'] == repo: if project['repo'] == repo:
previous_sha = project.get('hash') previous_sha = project.get('hash')
previous_tag = release['version'] previous_tag = release['version']
print('last tagged as {} at {}'.format( LOG.info('last tagged as {} at {}'.format(
previous_tag, previous_sha)) previous_tag, previous_sha))
found = True found = True
break break
@@ -359,7 +385,7 @@ def main():
if is_procedural: if is_procedural:
changes += 1 changes += 1
print('re-tagging %s at %s (%s)' % (repo, sha, LOG.info('re-tagging %s at %s (%s)' % (repo, sha,
previous_tag)) previous_tag))
new_project = { new_project = {
'repo': repo, 'repo': repo,
@@ -372,7 +398,7 @@ def main():
if is_eol: if is_eol:
changes += 1 changes += 1
print('tagging %s EOL at %s' % (repo, sha)) LOG.info('tagging %s EOL at %s' % (repo, sha))
new_project = { new_project = {
'repo': repo, 'repo': repo,
'hash': sha, 'hash': sha,
@@ -383,7 +409,7 @@ def main():
elif previous_sha != sha or force_tag: elif previous_sha != sha or force_tag:
changes += 1 changes += 1
print('advancing %s from %s (%s) to %s' % (repo, LOG.info('advancing %s from %s (%s) to %s' % (repo,
previous_sha, previous_sha,
previous_tag, previous_tag,
sha)) sha))
@@ -396,7 +422,7 @@ def main():
projects.append(new_project) projects.append(new_project)
else: else:
print('{} already tagged at most recent commit, skipping'.format( LOG.info('{} already tagged at most recent commit, skipping'.format(
repo)) repo))
deliverable_info['releases'].append({ deliverable_info['releases'].append({
@@ -411,13 +437,13 @@ def main():
if 'branches' in deliverable_info: if 'branches' in deliverable_info:
for branch in deliverable_info['branches']: for branch in deliverable_info['branches']:
if branch.get('name') == branch_name: if branch.get('name') == branch_name:
print('Branch {} already existes, skipping'.format( LOG.debug('Branch {} already exists, skipping'.format(
branch_name)) branch_name))
add_stable_branch = False add_stable_branch = False
break break
if add_stable_branch: if add_stable_branch:
print('adding stable branch at {}'.format(new_version)) LOG.info('adding stable branch at {}'.format(new_version))
deliverable_info.setdefault('branches', []).append({ deliverable_info.setdefault('branches', []).append({
'name': branch_name, 'name': branch_name,
'location': new_version, 'location': new_version,