Merge ~sylvain-pineau/hwcert-jenkins-tools:tf-checklist-links-to-summary into hwcert-jenkins-tools:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 6a3ad93cbf1eef33b8cf943767e12c23dda5d25d
Merged at revision: 71248b23b399ea6b073aec10bc740fedc4e375c2
Proposed branch: ~sylvain-pineau/hwcert-jenkins-tools:tf-checklist-links-to-summary
Merge into: hwcert-jenkins-tools:master
Diff against target: 77 lines (+19/-20)
1 file modified
trello-board-updater.py (+19/-20)
Reviewer Review Type Date Requested Status
Jonathan Cave Approve
Review via email: mp+381648@code.launchpad.net

Description of the change

For easy reviews, let's add links to summary from checklist items.

E.g for stlouis (added manually this time): https://trello.com/c/ecdU9XFm/2013-core-16-2442-9013-latest

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

+1, should be a real time saver

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/trello-board-updater.py b/trello-board-updater.py
2index 985d57e..22dd69a 100755
3--- a/trello-board-updater.py
4+++ b/trello-board-updater.py
5@@ -44,20 +44,17 @@ def find_or_create_checklist(card, checklist_name, items=[]):
6 return checklist
7
8
9-def change_checklist_item(checklist, name, checked=False):
10- # keep the trailing space so that we don't match the wrong thing later
11- r = re.match('\[*(.* )\(', name)
12- if r:
13- snapname = r.group(1)
14- for item in checklist.items:
15- if snapname in item.get('name'):
16- checklist.rename_checklist_item(item.get('name'), name)
17- checklist.set_checklist_item(name, checked)
18- return True
19- else:
20- return False
21+def change_checklist_item(checklist, name, content, checked=False):
22+ for item in checklist.items:
23+ if (
24+ name + ' ' in item.get('name') or
25+ name + ']' in item.get('name')
26+ ):
27+ checklist.rename_checklist_item(item.get('name'), content)
28+ checklist.set_checklist_item(content, checked)
29+ return True
30 else:
31- print('WARNING: Invalid name specified', name)
32+ return False
33
34
35 def no_new_fails_or_skips(summary_data):
36@@ -232,7 +229,8 @@ def main():
37 summary_data = args.summary.read()
38 summary += summary_data
39 summary += '\n```\n'
40- card.comment(summary)
41+ comment = card.comment(summary)
42+ comment_link = "{}#comment-{}".format(card.url, comment['id'])
43 else:
44 summary_data = ""
45 attach_labels(board, card, snap_labels)
46@@ -244,24 +242,25 @@ def main():
47 expected_tests = expected_tests.get(track, [])
48 checklist = find_or_create_checklist(card, 'Testflinger', expected_tests)
49 if args.cardonly:
50- item_name = "{} ({})".format(args.name, 'In progress')
51+ item_content = "{} ({})".format(args.name, 'In progress')
52 else:
53- item_name = "{} ({})".format(args.name, datetime.utcnow().isoformat())
54+ item_content = "[{}]({}) ({})".format(
55+ args.name, comment_link, datetime.utcnow().isoformat())
56 if jenkins_link:
57- item_name += " [[JENKINS]({})]".format(jenkins_link)
58+ item_content += " [[JENKINS]({})]".format(jenkins_link)
59 if c3_link:
60- item_name += " [[C3]({})]".format(c3_link)
61+ item_content += " [[C3]({})]".format(c3_link)
62 elif not args.cardonly:
63 # If there was no c3_link, it's because the submission failed
64 attach_labels(board, card, ['TESTFLINGER CRASH'])
65
66 if not change_checklist_item(
67- checklist, item_name,
68+ checklist, args.name, item_content,
69 checked=no_new_fails_or_skips(summary_data)):
70 if args.name.endswith('spread'):
71 checklist_spread = find_or_create_checklist(card, 'Spread')
72 if not change_checklist_item(
73- checklist_spread, item_name,
74+ checklist_spread, args.name, item_content,
75 checked=no_new_fails_or_skips(summary_data)):
76 checklist_spread.add_checklist_item(
77 item_name, checked=no_new_fails_or_skips(summary_data))

Subscribers

People subscribed via source and target branches