1
0
mirror of https://github.com/konpa/devicon.git synced 2025-08-15 19:14:05 +02:00

Feature: Peek and Build-Bot Upgrade (#806)

* Refactored peek script into a class

* Post-peek workflow now upload the new screenshots

* Refactored BuildSeleniumRunner into a class

* Updated build_icons.yml to reflect new changes

* Fixed issue with building icons that were already in the app

* Build script will take screenshot of new icons

* Update post peek yaml message

* Added alerts

* Peek script now check for strokes in icons

* Updated post_peek's strokes in svgs message

* Updated post_peek script's message

* Updated post_peek's message

* Refactored get_release_message into icomoon_build

* Change devicon.css name to devicon-base.css

* Updated post_peek message

* Added update icon as a valid PR title for bot-peek

* Add \n char to SVG after it gets optimized

* Fixed error with 'update icon' regex

* Build script now batch issues when upload SVG

* Addressed build-bot's screenshot order

* Apply suggestions from code review

Co-authored-by: David Leal <halfpacho@gmail.com>

Co-authored-by: David Leal <halfpacho@gmail.com>
This commit is contained in:
Thomas Bui
2021-08-13 11:51:22 -07:00
committed by GitHub
parent e5aa8a9cad
commit 08aa325a84
17 changed files with 822 additions and 408 deletions

View File

@@ -9,7 +9,7 @@ from typing import List, Dict
# pycharm complains that build_assets is an unresolved ref
# don't worry about it, the script still runs
from build_assets.SeleniumRunner import SeleniumRunner
from build_assets.selenium_runner.BuildSeleniumRunner import BuildSeleniumRunner
from build_assets import filehandler, arg_getters, util, api_handler
@@ -26,24 +26,29 @@ def main():
print(f"There are {len(new_icons)} icons to be build. Here are they:", *new_icons, sep = "\n")
print("Begin optimizing files")
print("Begin optimizing files...")
optimize_svgs(new_icons, args.icons_folder_path)
print("Updating the icomoon json")
print("Updating the icomoon json...")
update_icomoon_json(new_icons, args.icomoon_json_path)
print("Start the building icons process...")
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)
screenshot_folder = filehandler.create_screenshot_folder("./")
runner = BuildSeleniumRunner(args.download_path,
args.geckodriver_path, args.headless)
runner.build_icons(args.icomoon_json_path, zip_path,
icon_svgs, screenshot_folder)
filehandler.extract_files(str(zip_path), args.download_path)
filehandler.rename_extracted_files(args.download_path)
print("Creating the release message by querying the GitHub API...")
get_release_message(args.token)
print("Task completed.")
except TimeoutException as e:
util.exit_with_err("Selenium Time Out Error: \n" + str(e))
@@ -60,6 +65,8 @@ def get_icons_for_building(icomoon_json_path: str, devicon_json_path: str, token
: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.
:return a list of dict containing info on the icons. These are
from the `devicon.json`.
"""
devicon_json = filehandler.get_json_file_content(devicon_json_path)
pull_reqs = api_handler.get_merged_pull_reqs_since_last_release(token)
@@ -72,6 +79,7 @@ def get_icons_for_building(icomoon_json_path: str, devicon_json_path: str, token
new_icons.append(filtered_icon)
# get any icons that might not have been found by the API
# sometimes happen due to the PR being opened before the latest build release
new_icons_from_devicon_json = filehandler.find_new_icons_in_devicon_json(
devicon_json_path, icomoon_json_path)
@@ -136,5 +144,40 @@ def find_icomoon_icon_not_in_new_icons(icomoon_icon: Dict, new_icons: List, mess
return True
def get_release_message(token):
"""
Get the release message for the latest build and write
the result in a file.
:param token: the GitHub API token to access the API.
"""
# fetch first page by default
data = api_handler.get_merged_pull_reqs_since_last_release(token)
newIcons = []
features = []
print("Parsing through the pull requests...")
for pullData in data:
authors = api_handler.find_all_authors(pullData, token)
markdown = f"- [{pullData['title']}]({pullData['html_url']}) by {authors}."
if api_handler.is_feature_icon(pullData):
newIcons.append(markdown)
else:
features.append(markdown)
print("Constructing message...")
thankYou = "A huge thanks to all our maintainers and contributors for making this release possible!"
iconTitle = f"**{len(newIcons)} New Icons**"
featureTitle = f"**{len(features)} New Features**"
finalString = "{0}\n\n {1}\n{2}\n\n {3}\n{4}".format(thankYou,
iconTitle, "\n".join(newIcons),
featureTitle, "\n".join(features))
print("--------------Here is the build message--------------\n", finalString)
release_message_path = "./release_message.txt"
filehandler.write_to_file(release_message_path, finalString)
print("Script finished")
if __name__ == "__main__":
main()