From b6bcacee655b93f4777c7ac8270a889de7cb4aea Mon Sep 17 00:00:00 2001 From: melanie witt Date: Mon, 19 Jul 2021 18:49:50 +0000 Subject: [PATCH] Set launchpad bug Fix Released after adding comment This adds a step in the launchpad interaction during a release to set the bug task status to "Fix Released" for the series being released. Change-Id: I9fbbed3131e2ebfd590f27c569603add15bc969d --- ...py => launchpad_add_comment_set_status.py} | 25 ++++++++++++++++++- .../files/release-tools/release.sh | 7 ++++-- 2 files changed, 29 insertions(+), 3 deletions(-) rename roles/copy-release-tools-scripts/files/release-tools/{launchpad_add_comment.py => launchpad_add_comment_set_status.py} (72%) diff --git a/roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment.py b/roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment_set_status.py similarity index 72% rename from roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment.py rename to roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment_set_status.py index 7f548f44f2..784e325160 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment.py +++ b/roles/copy-release-tools-scripts/files/release-tools/launchpad_add_comment_set_status.py @@ -19,6 +19,7 @@ import argparse import os +import re import launchpadlib.launchpad import lazr.restfulclient.errors @@ -31,6 +32,8 @@ def main(): default='Comment added by add_comment') parser.add_argument('--content', help='The comment content', default='Comment added by add_comment') + parser.add_argument('--series', help='The series being released. Will set ' + 'the bug status to Fix Released when specified') lp_grp = parser.add_argument_group('launchpad') lp_grp.add_argument( "--test", @@ -63,7 +66,7 @@ def main(): credentials_file=args.lp_creds_file, ) - # Add comment + # Add comment and optionally set status to "Fix Released" for bugid in args.bugs: print("Adding comment to #%d..." % bugid, end='') try: @@ -75,6 +78,26 @@ def main(): except Exception as e: print(" ERROR during save ! (%s)" % e) + # Skip setting the bug status if --series was not specified + if not args.series: + continue + + print("Setting #%d to 'Fix Released' on %s..." % (bugid, args.series), + end='') + try: + bug = launchpad.bugs[bugid] + for task in bug.bug_tasks: + # Find '\bSERIES$' in the bug_target_name + if re.findall(r'\b%s$' % args.series, task.bug_target_name): + task.status = "Fix Released" + task.lp_save() + print(" done.") + break + except lazr.restfulclient.errors.ServerError: + print(" TIMEOUT during save !") + except Exception as e: + print(" ERROR during save ! (%s)" % e) + if __name__ == '__main__': main() diff --git a/roles/copy-release-tools-scripts/files/release-tools/release.sh b/roles/copy-release-tools-scripts/files/release-tools/release.sh index 3307fe97f9..019693c881 100755 --- a/roles/copy-release-tools-scripts/files/release-tools/release.sh +++ b/roles/copy-release-tools-scripts/files/release-tools/release.sh @@ -94,9 +94,12 @@ BUGS=$(git log $PREVIOUS..$VERSION | egrep -i "Closes(.| )Bug:" | egrep -o "[0-9 if [[ -z "$BUGS" ]]; then echo "No bugs found $PREVIOUS .. $VERSION" else - python3 -u $TOOLSDIR/launchpad_add_comment.py \ + # Capitalize the series name for the comment message. Requires >= bash 4.0. + $NAME=$(echo ${SERIES^}) + python3 -u $TOOLSDIR/launchpad_add_comment_set_status.py \ --subject="Fix included in $REPO $VERSION" \ - --content="This issue was fixed in the $REPO $VERSION $RELEASETYPE." \ + --content="This issue was fixed in the $REPO $VERSION $NAME $RELEASETYPE." \ + --series="$SERIES" \ $BUGS fi