From e4c03dad6b2e0bf806bfcaeaaa5eaaab94abdf3f Mon Sep 17 00:00:00 2001 From: Zimmerberger Markus Date: Thu, 19 Sep 2024 06:35:14 +0200 Subject: [PATCH] Add config.yaml, enhance Sub-Task generation (DoD) --- JIRA_SubTasks_byComments.py | 63 +++++++++++++++++++++++++++++-------- config.yaml | 16 +++------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/JIRA_SubTasks_byComments.py b/JIRA_SubTasks_byComments.py index 56b826f..513e997 100644 --- a/JIRA_SubTasks_byComments.py +++ b/JIRA_SubTasks_byComments.py @@ -8,6 +8,7 @@ import re import csv import xlsxwriter import logging +import yaml from bisect import bisect_left from datetime import date @@ -31,7 +32,7 @@ def take_closest(myList, myNumber): def get_assignee(type, issue): # isBuergerfrontend = False - if (type == 'Dev Backend' or type.startswith('Dev Unit')): + if (type == 'Dev Backend' or type.startswith('Dev Unit') or type == 'DoD SA/DEV'): # use assignee of story return 'rab9001' #return issue.fields.assignee.name @@ -42,16 +43,21 @@ def get_assignee(type, issue): return 'thh9001' elif type == 'Dev Citizen-Frontend': return 'reu9001' - elif type.startswith('Test-Anpassung'): + elif type.startswith('Test-Anpassung') or type == 'DoD Test': if issue.key.startswith('WRGWR-'): return 'ada9001' else: return 'osm9005' + elif type == 'DoD PO': + return 'kom9010' -def create_subtask(issue, parent, type, subtask_sp, estimation_remark): +def create_subtask(issue, parent, type, subtask_sp=0, estimation_remark="", no_unit_test=False): escaped = issue.fields.summary.replace('"', r'\"') logging.info(f'summary ~ \"{escaped}\"') + assignee = get_assignee(type, issue) + description = get_description(type) + try: subtask = jira_server.search_issues(f'summary ~ \"{type} {escaped}\"') if subtask: @@ -61,7 +67,7 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark): #subtask.fields('timetracking': {'originalEstimate'}).Value() = subtask_sp single_issue = jira_server.issue(subtask[0].key) try: - single_issue.update(fields={'timetracking': {'originalEstimate': '{}d'.format(subtask_sp)}}) + single_issue.update(fields={'timetracking': {'originalEstimate': '{}d'.format(subtask_sp)}, 'description': description, 'assignee': {'name': assignee}}) except Exception as e: logging.info(e) @@ -69,9 +75,7 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark): return issue_type = 'Sub-task' - - assignee = get_assignee(type, issue) - description = 's. Story' + if estimation_remark != "": description += "\nEstimation remark: {}".format(estimation_remark) @@ -98,12 +102,26 @@ def create_subtask(issue, parent, type, subtask_sp, estimation_remark): logging.info('Created Sub-Task {}'.format(new_issue)) +def get_description(type): + if (type == 'DoD SA/DEV'): + description = cfg['subtask_desc_dev'] + elif (type == 'DoD Test'): + description = cfg['subtask_desc_test'] + elif (type == 'DoD PO'): + description = cfg['subtask_desc_po'] + else: + description = 's. Story' + return description + logging.basicConfig(filename='sub_task_generator.log', filemode='a', format='%(asctime)s - %(levelname)s: %(message)s', level=logging.INFO, encoding='utf-8') +with open("config.yaml", encoding='utf8') as f: + cfg = yaml.load(f, Loader=yaml.FullLoader) + host = "https://jira.wien.gv.at/" pat = "OTAyMTM3MjY0MjE0Ovz6bu0ti1TlEdSegmmiWiJ2wGeD" sprint = 6 @@ -126,7 +144,8 @@ for issue in issues_Jql: sp_sum = 0 # only Issues with empty (or 0) story-points - sp = 0 + sp = 0 + no_unit_test = False if hasattr(issue.fields, 'customfield_10022'): sp = xsp(issue.fields.customfield_10022) @@ -170,11 +189,15 @@ for issue in issues_Jql: if comment_line_parts[0][:15] != "Test-Ausführung": create_subtask(issue, - issue.key, - comment_line_parts[0], - subtask_ph, - estimation_remark) - sp_sum += subtask_ph / 0.5 + issue.key, + comment_line_parts[0], + subtask_ph, + estimation_remark) + sp_sum += subtask_ph / 0.5 + else: + logging.info(f'Sub-task creation skipped {comment_line_parts[0]} equals \'NN\'') + if "Unit-Test" in comment_line_parts[0]: + no_unit_test = True # find corresponding sub-task # issuelinks.inwardIssue @@ -189,6 +212,20 @@ for issue in issues_Jql: finally: logging.info('Done {}'.format(issue.key)) + #create standard sub-tasks + for type in ['DoD SA/DEV','DoD Test','DoD PO']: + create_subtask(issue, + issue.key, + type, + no_unit_test=no_unit_test + ) + + #add or remove label #Unit-Test on story-level + if no_unit_test == False: + #issue.remove_field_value("labels", u'unit_test') + issue.add_field_value("labels", u'unit_test') + #issue.update(fields={"labels": issue.fields.labels}) + #print('{}: {}, SP: {}'.format(issue.key, issue.fields.summary, sp)) #print('Summe {}: {}'.format(assignee, sp_sum)) diff --git a/config.yaml b/config.yaml index c122916..8642536 100644 --- a/config.yaml +++ b/config.yaml @@ -1,13 +1,5 @@ {'maintainer': 'Markus Zimmerberger', - 'pca_params': {'n_components': 224}, - 'umap_params': {'metrics': ['euclidean', 'l1', 'manhattan'], - 'min_dist': [0.01, 0.1, 0.5], - 'spread': 1.0}, - 'visualize_params': {'median_threshold': 6}, - 'spreadsheet_name': 'Zeiterfassung alle Projekte', - 'worksheet_name': 'September 2024', - 'week': [37], - 'name': 'Markus Zimmerberger', - 'username': 'ZIM9003', - 'ansprechpartner_username': 'GRM0003', - 'ansprechpartner_name': 'Marlene Griesser'} \ No newline at end of file + 'subtask_desc_dev': "||Definition of Done||Verantwortung||\r\n|Code eingechecked und steht unter Versionsverwaltung|DEV|\r\n|Der Code ist vollständig implementiert und kommentiert|DEV|\r\n|Deployment Scripts fertig (wo notwendig, Story mit Label versehen)|DEV|\r\n|Code reviewed|SA/DEV|\r\n|Die Coding Standards _(Confluence Link einfügen)_ und die internen Konventionen _(Verweis)_ wurden eingehalten. (optional)|SA/DEV|\r\n|Alle Akzeptanzkriterien werden erfüllt|DEV|\r\n|Die Unit-Tests wurden durchgeführt und bestanden (wo notwendig, Story mit Label versehen)|DEV|\r\n|Dokumentationen sind aktualisiert|SA/DEV|", + 'subtask_desc_test': "||Definition of Done||Verantwortung||\r\n|Tests laut Testkonzept abgeschlossen|TE|\r\n|Deployed auf Testumgebungen|TE|\r\n|Dokumentationen sind aktualisiert|TE|\r\n|Im Review akzeptiert (bei Bugs und defects)|TE|", + 'subtask_desc_po': "||Definition of Done||Verantwortung||\r\n|Im Review akzeptiert|PO|" +} \ No newline at end of file