def get_chat_message(modules, log_start, pr_link): print_log_modules = list( filter(lambda s: s['send_notification'] is False, modules)) if len(print_log_modules) > 0: print(log_start + '\n') for failed_module in print_log_modules: if pr_link: link = failed_module[MODULE_CREATED_PR].html_url else: link = constants.BALLERINA_ORG_URL + failed_module['name'] + "/actions/workflows/" + \ failed_module[MODULE_BUILD_ACTION_FILE] + ".yml" print(failed_module['name'] + ' (' + link + ')') print() send_chat = False chat_message = '' notification_modules = list( filter(lambda s: s['send_notification'] is True, modules)) if len(notification_modules) > 0: send_chat = True chat_message = log_start + '\n' for notification_module in notification_modules: if pr_link: link = notification_module[MODULE_CREATED_PR].html_url else: link = constants.BALLERINA_ORG_URL + notification_module['name'] + "/actions/workflows/" + \ notification_module[MODULE_BUILD_ACTION_FILE] + ".yml" chat_message += utils.get_module_message(notification_module, link) chat_message += '\n' return send_chat, chat_message
def main(): global send_reminder_chat global lag_reminder_modules update_lang_version() updated_readme = get_updated_readme() # Write to local README file f = open(README_FILE, 'w') f.write(updated_readme) f.close() try: update_readme, commit = utils.commit_file( 'ballerina-release', README_FILE, updated_readme, constants.DASHBOARD_UPDATE_BRANCH, '[Automated] Update extension dependency dashboard') except GithubException as e: print('Error occurred while committing README.md', e) sys.exit(1) try: image = Image.open(constants.PIE_CHART_IMAGE, mode='r') img_byte_arr = io.BytesIO() image.save(img_byte_arr, format='JPEG') if update_readme: utils.commit_image_file('ballerina-release', constants.PIE_CHART_IMAGE, img_byte_arr.getvalue(), constants.DASHBOARD_UPDATE_BRANCH, '[Automated] Update status pie chart') except GithubException as e: print('Error occurred while committing status pie chart', e) sys.exit(1) if update_readme: utils.open_pr_and_merge( 'ballerina-release', '[Automated] Update Extension Dependency Dashboard', 'Update extension dependency dashboard', constants.DASHBOARD_UPDATE_BRANCH) if send_reminder_chat == 'true' and len(lag_reminder_modules) > 0: chat_message = distribution_lag_statement.replace( '<code>ballerina-distribution</code>', '*ballerina-distribution*') + ".\n\n" chat_message += "*Reminder* on the following modules\' dependency update..." + "\n" for module in lag_reminder_modules: lag_status_link = module[MODULE_PULL_REQUEST] if lag_status_link == "": lag_status_link = constants.BALLERINA_ORG_URL + module[ MODULE_NAME] chat_message += utils.get_module_message( module, lag_status_link) print("\n" + utils.get_sanitised_chat_message(chat_message)) notify_chat.send_message(chat_message) else: print('No changes to ' + README_FILE + ' file')