From 0486aa765a0d4d4c7871158cc772310dfd6aee74 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Thu, 17 Jun 2021 18:22:01 -0700 Subject: [PATCH 1/3] Build bot now check both PR and devicon.json --- .github/scripts/build_assets/filehandler.py | 2 +- .github/scripts/build_assets/util.py | 2 +- .github/scripts/icomoon_build.py | 56 ++++++++++++--------- .github/scripts/icomoon_peek.py | 2 +- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/.github/scripts/build_assets/filehandler.py b/.github/scripts/build_assets/filehandler.py index a73433500..012706a2e 100644 --- a/.github/scripts/build_assets/filehandler.py +++ b/.github/scripts/build_assets/filehandler.py @@ -6,7 +6,7 @@ import re -def find_new_icons(devicon_json_path: str, icomoon_json_path: str): +def find_new_icons_in_devicon_json(devicon_json_path: str, icomoon_json_path: str): """ Find the newly added icons by finding the difference between the devicon.json and the icomoon.json. diff --git a/.github/scripts/build_assets/util.py b/.github/scripts/build_assets/util.py index 415fba6e6..9d1a77011 100644 --- a/.github/scripts/build_assets/util.py +++ b/.github/scripts/build_assets/util.py @@ -46,7 +46,7 @@ def set_env_var(key: str, value: str, delimiter: str='~'): raise Exception("This function doesn't support this platform: " + platform.system()) -def find_object_added_in_this_pr(icons: List[dict], pr_title: str): +def find_object_added_in_pr(icons: List[dict], pr_title: str): """ Find the icon name from the PR title. :param icons, a list of the font objects found in the devicon.json. diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index 23e49b0b9..e279d2f51 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -20,31 +20,31 @@ def main(): runner = None try: args = arg_getters.get_selenium_runner_args() - new_icons = get_icons_for_building(args.devicon_json_path, args.token) + new_icons = get_icons_for_building(args.icomoon_json_path, args.devicon_json_path, args.token) if len(new_icons) == 0: sys.exit("No files need to be uploaded. Ending script...") print(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n") - print("Begin optimizing files") - optimize_svgs(new_icons, args.icons_folder_path) - - print("Updating the icomoon json") - update_icomoon_json(new_icons, args.icomoon_json_path) - - icon_svgs = filehandler.get_svgs_paths( - new_icons, args.icons_folder_path, icon_versions_only=True) - runner = SeleniumRunner(args.download_path, - args.geckodriver_path, args.headless) - runner.upload_icomoon(args.icomoon_json_path) - runner.upload_svgs(icon_svgs) - - zip_name = "devicon-v1.0.zip" - zip_path = Path(args.download_path, zip_name) - runner.download_icomoon_fonts(zip_path) - filehandler.extract_files(str(zip_path), args.download_path) - filehandler.rename_extracted_files(args.download_path) - print("Task completed.") + # print("Begin optimizing files") + # optimize_svgs(new_icons, args.icons_folder_path) + + # print("Updating the icomoon json") + # update_icomoon_json(new_icons, args.icomoon_json_path) + + # icon_svgs = filehandler.get_svgs_paths( + # new_icons, args.icons_folder_path, icon_versions_only=True) + # runner = SeleniumRunner(args.download_path, + # args.geckodriver_path, args.headless) + # runner.upload_icomoon(args.icomoon_json_path) + # runner.upload_svgs(icon_svgs) + + # zip_name = "devicon-v1.0.zip" + # zip_path = Path(args.download_path, zip_name) + # runner.download_icomoon_fonts(zip_path) + # filehandler.extract_files(str(zip_path), args.download_path) + # filehandler.rename_extracted_files(args.download_path) + # print("Task completed.") except TimeoutException as e: util.exit_with_err("Selenium Time Out Error: \n" + str(e)) except Exception as e: @@ -54,21 +54,31 @@ def main(): runner.close() -def get_icons_for_building(devicon_json_path: str, token: str): +def get_icons_for_building(icomoon_json_path: str, devicon_json_path: str, token: str): """ Get the icons for building. + :param icomoon_json_path - the path to the `icomoon.json`. :param devicon_json_path - the path to the `devicon.json`. :param token - the token to access the GitHub API. """ - all_icons = filehandler.get_json_file_content(devicon_json_path) + devicon_json = filehandler.get_json_file_content(devicon_json_path) pull_reqs = api_handler.get_merged_pull_reqs_since_last_release(token) new_icons = [] for pull_req in pull_reqs: if api_handler.is_feature_icon(pull_req): - filtered_icon = util.find_object_added_in_this_pr(all_icons, pull_req["title"]) + filtered_icon = util.find_object_added_in_pr(devicon_json, pull_req["title"]) if filtered_icon not in new_icons: new_icons.append(filtered_icon) + + # get any icons that might not have been found by the API + new_icons_from_devicon_json = filehandler.find_new_icons_in_devicon_json( + devicon_json_path, icomoon_json_path) + + for icon in new_icons_from_devicon_json: + if icon not in new_icons: + new_icons.append(icon) + return new_icons diff --git a/.github/scripts/icomoon_peek.py b/.github/scripts/icomoon_peek.py index 454f53ab2..1d132c218 100644 --- a/.github/scripts/icomoon_peek.py +++ b/.github/scripts/icomoon_peek.py @@ -17,7 +17,7 @@ def main(): new_icons = filehandler.get_json_file_content(args.devicon_json_path) # get only the icon object that has the name matching the pr title - filtered_icon = util.find_object_added_in_this_pr(new_icons, args.pr_title) + filtered_icon = util.find_object_added_in_pr(new_icons, args.pr_title) check_devicon_object(filtered_icon) print("Icon being checked:", filtered_icon, sep = "\n", end='\n\n') From e23d295d379ebdb187d04c7293dea4112a358673 Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Thu, 17 Jun 2021 18:22:29 -0700 Subject: [PATCH 2/3] Moved stale workflow into draft --- .github/{workflows => drafts}/stale.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflows => drafts}/stale.yml (100%) diff --git a/.github/workflows/stale.yml b/.github/drafts/stale.yml similarity index 100% rename from .github/workflows/stale.yml rename to .github/drafts/stale.yml From 2f116f1ed528bc9283f4dcf6820a912de2ec871b Mon Sep 17 00:00:00 2001 From: Thomas Bui Date: Fri, 18 Jun 2021 10:42:25 -0700 Subject: [PATCH 3/3] Uncomment test code --- .github/scripts/icomoon_build.py | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/scripts/icomoon_build.py b/.github/scripts/icomoon_build.py index e279d2f51..c4484fb58 100644 --- a/.github/scripts/icomoon_build.py +++ b/.github/scripts/icomoon_build.py @@ -26,25 +26,25 @@ def main(): print(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n") - # print("Begin optimizing files") - # optimize_svgs(new_icons, args.icons_folder_path) - - # print("Updating the icomoon json") - # update_icomoon_json(new_icons, args.icomoon_json_path) - - # icon_svgs = filehandler.get_svgs_paths( - # new_icons, args.icons_folder_path, icon_versions_only=True) - # runner = SeleniumRunner(args.download_path, - # args.geckodriver_path, args.headless) - # runner.upload_icomoon(args.icomoon_json_path) - # runner.upload_svgs(icon_svgs) - - # zip_name = "devicon-v1.0.zip" - # zip_path = Path(args.download_path, zip_name) - # runner.download_icomoon_fonts(zip_path) - # filehandler.extract_files(str(zip_path), args.download_path) - # filehandler.rename_extracted_files(args.download_path) - # print("Task completed.") + print("Begin optimizing files") + optimize_svgs(new_icons, args.icons_folder_path) + + print("Updating the icomoon json") + update_icomoon_json(new_icons, args.icomoon_json_path) + + icon_svgs = filehandler.get_svgs_paths( + new_icons, args.icons_folder_path, icon_versions_only=True) + runner = SeleniumRunner(args.download_path, + args.geckodriver_path, args.headless) + runner.upload_icomoon(args.icomoon_json_path) + runner.upload_svgs(icon_svgs) + + zip_name = "devicon-v1.0.zip" + zip_path = Path(args.download_path, zip_name) + runner.download_icomoon_fonts(zip_path) + filehandler.extract_files(str(zip_path), args.download_path) + filehandler.rename_extracted_files(args.download_path) + print("Task completed.") except TimeoutException as e: util.exit_with_err("Selenium Time Out Error: \n" + str(e)) except Exception as e: