def main(): with open('dependabot/resources/github_users_encrypted.csv', 'rb') as enc_file: encrypted_csv = enc_file.read() decrypted = fernet.decrypt(encrypted_csv) with open('dependabot/resources/github_users_decrypted.csv', 'wb') as dec_file: dec_file.write(decrypted) if str(sys.argv[5]) == "a": if str(sys.argv[3]) == "" or str(sys.argv[4]) == "": print("Missing required fields for adding") else: add_field(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) committed = commit_notify_work() if committed: utils.open_pr_and_merge('ballerina-release', '[Automated] Add an userid field', 'Add new userid to the encrypted csv', constants.USERID_UPDATE_BRANCH) else: print('No changes to the encrypted csv file') elif str(sys.argv[5]) == "r": remove_field(sys.argv[1], sys.argv[2]) committed = commit_notify_work() if committed: utils.open_pr_and_merge('ballerina-release', '[Automated] Remove an userid field ', 'Remove a userid from encrypted csv', constants.USERID_UPDATE_BRANCH) else: print('No changes to the encrypted csv file') else: print("Invalid operation")
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')
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': notify_chat.send_reminder(lag_reminder_modules) else: print('No changes to ' + README_FILE + ' file')
def main(): module_name_list = sort_module_name_list() print('Fetched module name list') module_details_json = initialize_module_details(module_name_list) print('Initialized module details') module_details_json = get_immediate_dependents(module_name_list, module_details_json) print('Fetched immediate dependents of each module') module_details_json = calculate_levels(module_name_list, module_details_json) print('Generated module dependency graph and updated module levels') module_details_json['modules'].sort(key=lambda s: s['level']) module_details_json = remove_modules_not_included_in_distribution( module_details_json) print('Removed central only modules and updated the list') try: utils.write_json_file(constants.EXTENSIONS_FILE, module_details_json) except Exception as e: print('Failed to write to extensions.json', e) sys.exit() print('Updated module details successfully') try: updated_file_content = open(constants.EXTENSIONS_FILE, 'r').read() update = utils.commit_file( 'ballerina-release', constants.EXTENSIONS_FILE, updated_file_content, constants.EXTENSIONS_UPDATE_BRANCH, '[Automated] Update Extensions Dependencies')[0] if update: utils.open_pr_and_merge( 'ballerina-release', '[Automated] Update Extensions Dependencies', 'Update dependencies in extensions.json', constants.EXTENSIONS_UPDATE_BRANCH) else: print('No changes to ' + constants.EXTENSIONS_FILE + ' file') except GithubException as e: print('Error occurred while committing extensions.json', e) sys.exit(1) print("Updated module details in 'ballerina-release' successfully")
def main(): global dependencies global stdlib_modules_by_level global stdlib_modules_json_file read_stdlib_modules() if dependencies: create_graph(stdlib_modules_by_level, dependencies) updated_file_content = open(graph_file_path, 'r').read() update = utils.commit_file('ballerina-release', graph_file_path, updated_file_content, constants.EXTENSIONS_UPDATE_BRANCH, '[Automated] Update Stdlib Dependency Graph')[0] if update: utils.open_pr_and_merge('ballerina-release', '[Automated] Update Stdlib Dependency Graph', 'Update dependency graph in stdlib_graph.gv', constants.EXTENSIONS_UPDATE_BRANCH) else: print('No changes to ' + graph_file_path + ' file')
def main(): update_lang_version() updated_readme = get_updated_readme() try: update, commit = utils.commit_file( 'ballerina-release', README_FILE, updated_readme, constants.DASHBOARD_UPDATE_BRANCH, '[Automated] Update extension dependency dashboard') if update: utils.open_pr_and_merge( 'ballerina-release', '[Automated] Update Extension Dependency Dashboard', 'Update extension dependency dashboard', constants.DASHBOARD_UPDATE_BRANCH) notify_chat.notify_lag_update(commit) else: print('No changes to ' + README_FILE + ' file') except GithubException as e: print('Error occurred while committing README.md', e) sys.exit(1)
def main(): global lang_version global extensions_file global all_modules global current_level_modules try: extensions_file = utils.read_json_file(constants.EXTENSIONS_FILE) except Exception as e: print('[Error] Error while loading modules list ', e) sys.exit(1) print("Workflow invoked of type '" + event_type + "'") if event_type == 'schedule' and not extensions_file['auto_bump']: print( "Schedule workflow invoked, exiting script as 'auto_bump' flag in modules_list.json is false." ) return if override_ballerina_version != '': lang_version = override_ballerina_version else: lang_version = utils.get_latest_lang_version() bal_version = {'version': lang_version} try: utils.write_json_file(constants.LANG_VERSION_FILE, bal_version) except Exception as e: print('Failed to write to file latest_ballerina_lang_version.json', e) sys.exit() try: updated_file_content = open(constants.LANG_VERSION_FILE, 'r').read() update = utils.commit_file( 'ballerina-release', constants.LANG_VERSION_FILE, updated_file_content, constants.EXTENSIONS_UPDATE_BRANCH, '[Automated] Update Workflow Lang Version')[0] if update: utils.open_pr_and_merge( 'ballerina-release', '[Automated] Update Dependency Bump Workflow Triggered Version', 'Update bumped ballerina lang version', constants.EXTENSIONS_UPDATE_BRANCH) else: print('No changes to ' + constants.LANG_VERSION_FILE + ' file') except GithubException as e: print( 'Error occurred while committing latest_ballerinalang_version.md', e) sys.exit(1) print('Workflow started with Ballerina Lang version : ' + lang_version) all_modules = extensions_file['modules'] last_level = all_modules[-1]['level'] print( 'Start dependency bump to extensions packed in ballerina-distribution') for i in range(last_level): current_level = i + 1 current_level_modules = list( filter(lambda s: s['level'] == current_level, all_modules)) for idx, module in enumerate(current_level_modules): print("[Info] Check lang dependency in module '" + module['name'] + "'") update_module(idx, current_level) if auto_merge_pull_requests.lower() == 'true': wait_for_current_level_build(current_level) print( 'Successfully bumped dependencies in extensions packed in ballerina-distribution' ) central_module_level = extensions_file['central_modules'][-1]['level'] print('Start dependency bump to extensions available only in central') for j in range(last_level, central_module_level): current_level = j + 1 current_level_modules = list( filter(lambda s: s['level'] == current_level, extensions_file['central_modules'])) for idx, module in enumerate(current_level_modules): print("[Info] Check lang dependency in module '" + module['name'] + "'") update_module(idx, current_level) if auto_merge_pull_requests.lower() == 'true': wait_for_current_level_build(current_level) print( 'Successfully bumped dependencies in extensions available in central')